MCPcopy Create free account
hub / github.com/InternScience/SciReason / bbeh_freeform_postprocess

Function bbeh_freeform_postprocess

opencompass/datasets/bbeh.py:33–57  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

31
32@TEXT_POSTPROCESSORS.register_module('bbeh_freeform')
33def bbeh_freeform_postprocess(text: str) -> str:
34 # Extract answer using specified prefixes
35 prefixes = [
36 'The answer is: ', 'The answer is ', 'The final answer is: ',
37 'The final answer is '
38 ]
39 answer = text
40 for prefix in prefixes:
41 if prefix in text:
42 answer = text.split(prefix)[-1]
43 break
44
45 # Remove formatting markup
46 if '\\boxed' in answer:
47 answer = re.sub(r'\\boxed{(.*?)}', r'\1', answer) # latex box
48 if '\\text' in answer:
49 answer = re.sub(r'\\text(?:tt)?{(.*?)}', r'\1', answer) # text/texttt
50 if '**' in answer:
51 answer = re.sub(r'\*\*(.*?)\*\*', r'\1', answer) # bold
52
53 # Take first line and clean
54 if '\n' in answer:
55 answer = answer.split('\n')[0].strip()
56
57 return answer.strip().lower()
58
59
60@TEXT_POSTPROCESSORS.register_module('bbeh_mcq')

Callers 1

scoreMethod · 0.85

Calls 1

lowerMethod · 0.45

Tested by

no test coverage detected