mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00
[Feature] Support answer extraction of QwQ when evaluating HuProverbRea_OE (#31)
This commit is contained in:
parent
0971777348
commit
b6c8165ca3
@ -3,9 +3,9 @@ from mmengine.config import read_base
|
|||||||
with read_base():
|
with read_base():
|
||||||
from opencompass.configs.datasets.OpenHuEval.HuProverbRea.HuProverbRea_OE import HuProverbRea_datasets
|
from opencompass.configs.datasets.OpenHuEval.HuProverbRea.HuProverbRea_OE import HuProverbRea_datasets
|
||||||
|
|
||||||
# from opencompass.configs.models.openai.gpt_4o_mini_20240718 import models as gpt_4o_mini_20240718_model
|
from opencompass.configs.models.openai.gpt_4o_mini_20240718 import models as gpt_4o_mini_20240718_model
|
||||||
# from opencompass.configs.models.openai.gpt_4o_2024_11_20 import models as gpt_4o_2024_11_20_model
|
from opencompass.configs.models.openai.gpt_4o_2024_11_20 import models as gpt_4o_2024_11_20_model
|
||||||
# from opencompass.configs.models.deepseek.deepseek_v3_api_aliyun import models as deepseek_v3_api_aliyun_model
|
from opencompass.configs.models.deepseek.deepseek_v3_api_aliyun import models as deepseek_v3_api_aliyun_model
|
||||||
|
|
||||||
from opencompass.configs.models.qwen2_5.lmdeploy_qwen2_5_7b_instruct import models as lmdeploy_qwen2_5_7b_instruct_model
|
from opencompass.configs.models.qwen2_5.lmdeploy_qwen2_5_7b_instruct import models as lmdeploy_qwen2_5_7b_instruct_model
|
||||||
from opencompass.configs.models.qwen2_5.lmdeploy_qwen2_5_72b_instruct import models as lmdeploy_qwen2_5_72b_instruct_model
|
from opencompass.configs.models.qwen2_5.lmdeploy_qwen2_5_72b_instruct import models as lmdeploy_qwen2_5_72b_instruct_model
|
||||||
@ -15,8 +15,8 @@ with read_base():
|
|||||||
from opencompass.configs.models.hf_internlm.lmdeploy_internlm3_8b_instruct import models as lmdeploy_internlm3_8b_instruct_model
|
from opencompass.configs.models.hf_internlm.lmdeploy_internlm3_8b_instruct import models as lmdeploy_internlm3_8b_instruct_model
|
||||||
|
|
||||||
from opencompass.configs.models.qwq.lmdeploy_qwq_32b_preview import models as lmdeploy_qwq_32b_preview_model
|
from opencompass.configs.models.qwq.lmdeploy_qwq_32b_preview import models as lmdeploy_qwq_32b_preview_model
|
||||||
# from opencompass.configs.models.deepseek.deepseek_r1_api_aliyun import models as deepseek_r1_api_aliyun_model
|
from opencompass.configs.models.deepseek.deepseek_r1_api_aliyun import models as deepseek_r1_api_aliyun_model
|
||||||
# from opencompass.configs.models.openai.o1_mini_2024_09_12 import models as o1_mini_2024_09_12_model
|
from opencompass.configs.models.openai.o1_mini_2024_09_12 import models as o1_mini_2024_09_12_model
|
||||||
# from opencompass.configs.models.openai.o3_mini_2025_01_31 import models as o3_mini_2025_01_31_model
|
# from opencompass.configs.models.openai.o3_mini_2025_01_31 import models as o3_mini_2025_01_31_model
|
||||||
|
|
||||||
datasets = HuProverbRea_datasets
|
datasets = HuProverbRea_datasets
|
||||||
@ -30,6 +30,12 @@ for model in models:
|
|||||||
'type': 'rm_<think>_before_eval'
|
'type': 'rm_<think>_before_eval'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if model['abbr'].startswith('QwQ'):
|
||||||
|
model['pred_postprocessor'] = {
|
||||||
|
'OpenHuEval_*': {
|
||||||
|
'type': 'extract_qwq_answer_before_eval'
|
||||||
|
}
|
||||||
|
}
|
||||||
del model
|
del model
|
||||||
|
|
||||||
work_dir = './outputs/' + __file__.split('/')[-1].split('.')[0] + '/' # do NOT modify this line, yapf: disable, pylint: disable
|
work_dir = './outputs/' + __file__.split('/')[-1].split('.')[0] + '/' # do NOT modify this line, yapf: disable, pylint: disable
|
||||||
|
@ -241,3 +241,26 @@ def remove_reasoning_part_before_evaluation(text: str):
|
|||||||
return text[reasoning_end + 8:]
|
return text[reasoning_end + 8:]
|
||||||
else:
|
else:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
@TEXT_POSTPROCESSORS.register_module('extract_qwq_answer_before_eval')
|
||||||
|
def extract_answer_before_evaluation(text: str):
|
||||||
|
"""Overall, there are three situations in responses of QWQ:
|
||||||
|
|
||||||
|
1. There is a **Final Answer** title in the whole context.
|
||||||
|
2. There is only one sentence in the context.
|
||||||
|
3. There are more than one sentences in the context, \
|
||||||
|
and the last one is the answer.
|
||||||
|
"""
|
||||||
|
if '**Final Answer**' in text:
|
||||||
|
answer = text.split('\n\n**Final Answer**\n\n')[-1]
|
||||||
|
else:
|
||||||
|
if '\n\nHuman' in text:
|
||||||
|
text = text.split('\n\nHuman')[0]
|
||||||
|
|
||||||
|
text_split = text.split('.')
|
||||||
|
if text_split[-1] == '':
|
||||||
|
answer = text_split[-2] + '.'
|
||||||
|
else:
|
||||||
|
answer = text_split[-1] + '.'
|
||||||
|
return answer
|
||||||
|
Loading…
Reference in New Issue
Block a user