MCPcopy Create free account
hub / github.com/Alpha-VLLM/LLaMA2-Accessory / extract_ans

Function extract_ans

light-eval/src/eval_bbh.py:95–114  ·  view source on GitHub ↗
(ans, mode)

Source from the content-addressed store, hash-verified

93 return model
94
95def extract_ans(ans, mode):
96 ans_line = re.split("Q:", ans, flags=re.IGNORECASE)[0]
97 ans_line = re.split('answer is ', ans_line, flags=re.IGNORECASE)
98 # Expect to see 'answer is'. If not return whole string
99 if len(ans_line) == 1:
100 return ans
101 else:
102 ans = ans_line[-1].strip()
103
104 if mode == 'multiple_choice':
105 match = re.search(r'\(([A-Z])\)*', ans)
106 if match:
107 return match.group(1)
108 match = re.search(r'([A-Z])', ans)
109 if match:
110 return match.group(1)
111 return ans
112 elif mode == 'free_form':
113 ans = re.split(r'[.#]', ans)[0]
114 return ans
115
116def batch_data(prompts, batch_size=1):
117 batch_data = []

Callers 1

run_evalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected