MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / process_results

Method process_results

test/general/lm_eval/tasks/squad.py:114–169  ·  view source on GitHub ↗

Take a single document and the LM results and evaluates, returning a dict where keys are the names of submetrics and values are the values of the metric for that one document :param doc: The document as returned from training_docs, validation_docs, or test_docs.

(self, doc, results)

Source from the content-addressed store, hash-verified

112 return continuation, is_unanswerable
113
114 def process_results(self, doc, results):
115 """Take a single document and the LM results and evaluates, returning a
116 dict where keys are the names of submetrics and values are the values of
117 the metric for that one document
118
119 :param doc:
120 The document as returned from training_docs, validation_docs, or test_docs.
121 :param results:
122 The results of the requests created in construct_requests.
123 """
124 continuation, (logprob_unanswerable, _) = results
125
126 no_answer_probability = exp(logprob_unanswerable)
127
128 predictions = {
129 "id": doc["id"],
130 "prediction_text": continuation,
131 "no_answer_probability": no_answer_probability,
132 }
133
134 references = {
135 "id": doc["id"],
136 "answers": doc["answers"],
137 }
138
139 return {
140 "exact": (
141 predictions,
142 references,
143 ), # Exact match (the normalized answer exactly match the gold answer)
144 "f1": (
145 predictions,
146 references,
147 ), # The F-score of predicted tokens versus the gold answer
148 "HasAns_exact": (
149 predictions,
150 references,
151 ), # Exact match (the normalized answer exactly match the gold answer)
152 "HasAns_f1": (
153 predictions,
154 references,
155 ), # The F-score of predicted tokens versus the gold answer
156 "NoAns_exact": (
157 predictions,
158 references,
159 ), # Exact match (the normalized answer exactly match the gold answer)
160 "NoAns_f1": (
161 predictions,
162 references,
163 ), # The F-score of predicted tokens versus the gold answer
164 "best_exact": (
165 predictions,
166 references,
167 ), # Best exact match (with varying threshold)
168 "best_f1": (predictions, references), # Best F1 (with varying threshold)
169 }
170
171 def aggregation(self):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected