| 59 | |
| 60 | @TEXT_POSTPROCESSORS.register_module('bbeh_mcq') |
| 61 | def bbeh_mcq_postprocess(text: str) -> str: |
| 62 | # Extract answer using specified prefixes |
| 63 | prefixes = [ |
| 64 | 'The answer is: ', 'The answer is ', 'The final answer is: ', |
| 65 | 'The final answer is ' |
| 66 | ] |
| 67 | answer = text |
| 68 | for prefix in prefixes: |
| 69 | if prefix in text: |
| 70 | answer = text.split(prefix)[-1] |
| 71 | break |
| 72 | |
| 73 | # Remove parentheses if present |
| 74 | answer = answer.strip('()') |
| 75 | |
| 76 | # Take first line and clean |
| 77 | if '\n' in answer: |
| 78 | answer = answer.split('\n')[0].strip() |
| 79 | |
| 80 | return answer.strip().lower() |
| 81 | |
| 82 | |
| 83 | @ICL_EVALUATORS.register_module() |