MCPcopy
hub / github.com/Tele-AI/Telechat / get_capital_answer

Function get_capital_answer

evaluation/score_MMLU.py:33–51  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

31 return data
32# post process
33def get_capital_answer(text):
34 patterns = [
35 "the answer is ([A-E])",
36 "the answer is([A-E])",
37 "Answer: ([A-E])",
38 "Answer: \(([A-E])\)",
39 "Option \(([A-E])\)",
40 "Answer:([A-E])",
41 "Option ([A-E])",
42 "Opt ([A-E])"
43 ]
44 for pattern in patterns:
45 match = re.search(pattern,text,re.IGNORECASE)
46 if match:
47 return match.group(1)
48 match = re.findall("[A-D]", text)
49 if match:
50 return match[0]
51 return ""
52if __name__ == "__main__":
53 tokenizer = AutoTokenizer.from_pretrained(PATH)
54 model = AutoModelForCausalLM.from_pretrained(PATH, trust_remote_code=True, device_map="auto",

Callers 1

score_MMLU.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected