def reduce(predictions):
    """
    Takes NER model output and joins the word-tag pairs into phrase-tag pairs.
    :param predictions: prediction in the NER output format
    :return: a list of phrase-tag pairs
    """
    words, predictions = predictions[0][0], predictions[1][0]
    result = []
    w_last, p_last = "", ""

    for w, p in zip(words, predictions):
        if "I-" in p and result and p[2:] == p_last:
            result[-1] = w_last + " " + w, p_last
        elif "I-" in p or "B-" in p:
            result.append((w, p[2:]))

        if result:
            w_last, p_last = result[-1]

    return result