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

Function get_f1

tasks/seq2seq/evaluate.py:128–141  ·  view source on GitHub ↗
(text_a, text_b)

Source from the content-addressed store, hash-verified

126
127
128def get_f1(text_a, text_b):
129 tokens_a = text_a.lower().split()
130 tokens_b = text_b.lower().split()
131 if len(tokens_a) == 0 or len(tokens_b) == 0:
132 return 1 if len(tokens_a) == len(tokens_b) else 0
133 set_a = count_tokens(tokens_a)
134 set_b = count_tokens(tokens_b)
135 match = 0
136 for token in set_a.keys():
137 if token in set_b.keys():
138 match += min(set_a[token], set_b[token])
139 p = match / len(tokens_a)
140 r = match / len(tokens_b)
141 return 2.0 * p * r / (p + r + 1e-5)
142
143
144def remove_duplicate(l_list, duplicate_rate):

Callers 1

rouge_metricFunction · 0.85

Calls 1

count_tokensFunction · 0.85

Tested by

no test coverage detected