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

Function acc_all

test/general/lm_eval/metrics.py:48–64  ·  view source on GitHub ↗
(items)

Source from the content-addressed store, hash-verified

46
47
48def acc_all(items):
49 # Only count as correct if all answers are labeled correctly for each question
50 question_scoring_dict = {}
51 preds = list(zip(*items))[0]
52 docs = list(zip(*items))[1]
53
54 for doc, pred in zip(docs, preds):
55 paragraph_id = doc["idx"]["paragraph"]
56 question_id = doc["idx"]["question"]
57 if (paragraph_id, question_id) not in question_scoring_dict:
58 question_scoring_dict[(paragraph_id, question_id)] = []
59
60 gold_label = doc["label"] == 1
61
62 question_scoring_dict[(paragraph_id, question_id)].append(gold_label == pred)
63 acc = np.mean([int(all(x)) for x in question_scoring_dict.values()])
64 return acc
65
66
67def acc_all_stderr(items):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected