def qa_metrics(targets, predictions):
    """Computes exact match and f1 QA scores, expecting pre-normalized text."""
    if len(targets) != len(predictions):
        raise ValueError("Number of targets and predictions must match.")
    em_scores = [
        _metric_max_over_ground_truths(_exact_match_score, t, p)
        for p, t in zip(predictions, targets)
    ]
    em = np.mean(em_scores)

    f1_scores = [
        _metric_max_over_ground_truths(_f1_score, t, p)
        for p, t in zip(predictions, targets)
    ]
    f1 = np.mean(f1_scores)
    em *= 100
    f1 *= 100
    # logging.info("EM = %.2f, F1 = %.2f", em, f1)
    return em, f1, em_scores, f1_scores
Computes exact match and f1 QA scores, expecting pre-normalized text.
corag/src/inference/qa_utils.py