MCPcopy Create free account
hub / github.com/THUDM/GLM / f1_score

Function f1_score

tasks/superglue/evaluate.py:36–46  ·  view source on GitHub ↗
(prediction, ground_truth)

Source from the content-addressed store, hash-verified

34
35
36def f1_score(prediction, ground_truth):
37 prediction_tokens = normalize_answer(prediction).split()
38 ground_truth_tokens = normalize_answer(ground_truth).split()
39 common = Counter(prediction_tokens) & Counter(ground_truth_tokens)
40 num_same = sum(common.values())
41 if num_same == 0:
42 return 0
43 precision = 1.0 * num_same / len(prediction_tokens)
44 recall = 1.0 * num_same / len(ground_truth_tokens)
45 f1 = (2 * precision * recall) / (precision + recall)
46 return f1
47
48
49def exact_match_score(prediction, ground_truth):

Callers 2

f1_metricFunction · 0.85
f1_macro_metricFunction · 0.85

Calls 1

normalize_answerFunction · 0.85

Tested by

no test coverage detected