|
| 1 | +from opencompass.openicl.icl_prompt_template import PromptTemplate |
| 2 | +from opencompass.openicl.icl_retriever import ZeroRetriever |
| 3 | +from opencompass.openicl.icl_inferencer import GenInferencer |
| 4 | +from opencompass.evaluator import GenericLLMEvaluator |
| 5 | +from opencompass.datasets import generic_llmjudge_postprocess |
| 6 | +from opencompass.datasets import HLEDataset |
| 7 | + |
| 8 | +# ----------------------------- Detailed Config ----------------------------- |
| 9 | + |
| 10 | +math_reader_cfg = dict(input_columns=['problem'], output_column='answer') |
| 11 | + |
| 12 | +math_infer_cfg = dict( |
| 13 | + prompt_template=dict( |
| 14 | + type=PromptTemplate, |
| 15 | + template=dict( |
| 16 | + round=[ |
| 17 | + dict(role='HUMAN', prompt='{problem}\nRemember to put your final answer within \\boxed{}.'), |
| 18 | + ] |
| 19 | + ), |
| 20 | + ), |
| 21 | + retriever=dict(type=ZeroRetriever), |
| 22 | + inferencer=dict(type=GenInferencer), |
| 23 | +) |
| 24 | + |
| 25 | +GRADER_TEMPLATE = """ |
| 26 | + Please as a grading expert, judge whether the final answers given by the candidates below are consistent with the standard answers, that is, whether the candidates answered correctly. |
| 27 | + |
| 28 | + Here are some evaluation criteria: |
| 29 | + 1. Please refer to the given standard answer. You don't need to re-generate the answer to the question because the standard answer has been given. You only need to judge whether the candidate's answer is consistent with the standard answer according to the form of the question. Don't try to answer the original question. You can assume that the standard answer is definitely correct. |
| 30 | + 2. Because the candidate's answer may be different from the standard answer in the form of expression, before making a judgment, please understand the question and the standard answer first, and then judge whether the candidate's answer is correct, but be careful not to try to answer the original question. |
| 31 | + 3. Some answers may contain multiple items, such as multiple-choice questions, multiple-select questions, fill-in-the-blank questions, etc. As long as the answer is the same as the standard answer, it is enough. For multiple-select questions and multiple-blank fill-in-the-blank questions, the candidate needs to answer all the corresponding options or blanks correctly to be considered correct. |
| 32 | + 4. Some answers may be expressed in different ways, such as some answers may be a mathematical expression, some answers may be a textual description, as long as the meaning expressed is the same. And some formulas are expressed in different ways, but they are equivalent and correct. |
| 33 | + 5. If the prediction is given with \\boxed{}, please ignore the \\boxed{} and only judge whether the candidate's answer is consistent with the standard answer. |
| 34 | +
|
| 35 | + Please judge whether the following answers are consistent with the standard answer based on the above criteria. Grade the predicted answer of this new question as one of: |
| 36 | + A: CORRECT |
| 37 | + B: INCORRECT |
| 38 | + Just return the letters "A" or "B", with no text around it. |
| 39 | +
|
| 40 | + Here is your task. Simply reply with either CORRECT, INCORRECT. Don't apologize or correct yourself if there was a mistake; we are just trying to grade the answer. |
| 41 | +
|
| 42 | +
|
| 43 | + <Original Question Begin>: \n{problem}\n<Original Question End>\n\n |
| 44 | + <Gold Target Begin>: \n{answer}\n<Gold Target End>\n\n |
| 45 | + <Predicted Answer Begin>: \n{prediction}\n<Predicted End>\n\n |
| 46 | + |
| 47 | + Judging the correctness of candidates' answers: |
| 48 | +""".strip() |
| 49 | + |
| 50 | +# Evaluation configuration |
| 51 | +math_eval_cfg = dict( |
| 52 | + evaluator=dict( |
| 53 | + type=GenericLLMEvaluator, |
| 54 | + prompt_template=dict( |
| 55 | + type=PromptTemplate, |
| 56 | + template=dict( |
| 57 | + begin=[ |
| 58 | + dict( |
| 59 | + role='SYSTEM', |
| 60 | + fallback_role='HUMAN', |
| 61 | + prompt="You are a helpful assistant who evaluates the correctness and quality of models' outputs.") |
| 62 | + ], |
| 63 | + round=[ |
| 64 | + dict( |
| 65 | + role='HUMAN', |
| 66 | + prompt = GRADER_TEMPLATE |
| 67 | + ), |
| 68 | + ]), |
| 69 | + ), |
| 70 | + dataset_cfg=dict( |
| 71 | + type=HLEDataset, |
| 72 | + path='cais/hle', |
| 73 | + reader_cfg=math_reader_cfg, |
| 74 | + ), |
| 75 | + judge_cfg=dict(), |
| 76 | + dict_postprocessor=dict(type=generic_llmjudge_postprocess), |
| 77 | + ), |
| 78 | + pred_role='BOT', |
| 79 | +) |
| 80 | + |
| 81 | + |
| 82 | +hle_datasets = [ |
| 83 | + dict( |
| 84 | + type=HLEDataset, |
| 85 | + abbr='hle_llmjudge', |
| 86 | + path='cais/hle', |
| 87 | + reader_cfg=math_reader_cfg, |
| 88 | + infer_cfg=math_infer_cfg, |
| 89 | + eval_cfg=math_eval_cfg, |
| 90 | + ) |
| 91 | +] |
0 commit comments