mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00

* support nejm ai benchmark * add dataset files * revise gen name * revise gen name * revise class name & remove csv file & add dataset-index.yml info * update * update --------- Co-authored-by: MaiziXiao <xxllcc1993@gmail.com>
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
from opencompass.datasets import NejmaibenchDataset, NejmaibenchEvaluator
|
|
from opencompass.openicl.icl_inferencer import GenInferencer
|
|
from opencompass.openicl.icl_prompt_template import PromptTemplate
|
|
from opencompass.openicl.icl_retriever import ZeroRetriever
|
|
|
|
import os
|
|
|
|
SYSTEM_PROMPT = 'You are a helpful medical assistant.\n\n' # Where to put this?
|
|
ZERO_SHOT_PROMPT = 'Q: {question}\n Please select the correct answer from the options above and output only the corresponding letter (A, B, C, D, or E) without any explanation or additional text.\n'
|
|
|
|
# Reader configuration
|
|
reader_cfg = dict(
|
|
input_columns=[
|
|
'question',
|
|
'options',
|
|
'Subject',
|
|
'prompt_mode',
|
|
|
|
],
|
|
output_column='label',
|
|
)
|
|
|
|
# Inference configuration
|
|
infer_cfg = dict(
|
|
prompt_template=dict(
|
|
type=PromptTemplate,
|
|
template=dict(
|
|
begin=[
|
|
dict(role='SYSTEM', fallback_role='HUMAN', prompt=SYSTEM_PROMPT),
|
|
],
|
|
round=[
|
|
dict(
|
|
role='HUMAN',
|
|
prompt=ZERO_SHOT_PROMPT, # prompt mode: zero-shot
|
|
),
|
|
],
|
|
),
|
|
),
|
|
retriever=dict(type=ZeroRetriever),
|
|
inferencer=dict(type=GenInferencer),
|
|
)
|
|
|
|
# Evaluation configuration
|
|
eval_cfg = dict(
|
|
evaluator=dict(type=NejmaibenchEvaluator),
|
|
pred_role='BOT',
|
|
)
|
|
nejmaibench_dataset = dict(
|
|
type=NejmaibenchDataset,
|
|
abbr='nejmaibench',
|
|
path='opencompass/nejmaibench',
|
|
prompt_mode='zero-shot',
|
|
reader_cfg=reader_cfg,
|
|
infer_cfg=infer_cfg,
|
|
eval_cfg=eval_cfg,
|
|
|
|
)
|
|
|
|
nejmaibench_datasets = [nejmaibench_dataset]
|