MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / reorg_answer_file

Function reorg_answer_file

eval_general/eval_mt_bench_tgi.py:115–126  ·  view source on GitHub ↗

Sort by question id and de-duplication

(answer_file)

Source from the content-addressed store, hash-verified

113 fout.write(json.dumps(ans_json) + "\n")
114
115def reorg_answer_file(answer_file):
116 """Sort by question id and de-duplication"""
117 answers = {}
118 with open(answer_file, "r") as fin:
119 for l in fin:
120 qid = json.loads(l)["question_id"]
121 answers[qid] = l
122
123 qids = sorted(list(answers.keys()))
124 with open(answer_file, "w") as fout:
125 for qid in qids:
126 fout.write(answers[qid])
127
128
129if __name__ == "__main__":

Callers 1

Calls 2

keysMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected