2024-02-04 14:18:36 +08:00
|
|
|
from mmengine.config import read_base
|
2024-02-05 15:55:58 +08:00
|
|
|
|
2024-02-04 14:18:36 +08:00
|
|
|
with read_base():
|
|
|
|
from .datasets.subjective.alpaca_eval.alpacav2_judgeby_gpt4 import subjective_datasets as alpacav2
|
|
|
|
|
|
|
|
from opencompass.models import HuggingFaceCausalLM, HuggingFace, HuggingFaceChatGLM3
|
|
|
|
from opencompass.models.openai_api import OpenAI, OpenAIAllesAPIN
|
|
|
|
from opencompass.partitioners import NaivePartitioner, SizePartitioner
|
|
|
|
from opencompass.partitioners.sub_naive import SubjectiveNaivePartitioner
|
|
|
|
from opencompass.partitioners.sub_size import SubjectiveSizePartitioner
|
|
|
|
from opencompass.runners import LocalRunner
|
|
|
|
from opencompass.runners import SlurmSequentialRunner
|
|
|
|
from opencompass.tasks import OpenICLInferTask
|
2024-03-28 16:49:04 +08:00
|
|
|
from opencompass.tasks.outer_eval.alpacaeval import AlpacaEvalTask
|
2024-02-04 14:18:36 +08:00
|
|
|
from opencompass.summarizers import AlpacaSummarizer
|
|
|
|
|
|
|
|
api_meta_template = dict(
|
|
|
|
round=[
|
|
|
|
dict(role='HUMAN', api_role='HUMAN'),
|
2024-02-05 15:55:58 +08:00
|
|
|
dict(role='BOT', api_role='BOT', generate=True),
|
2024-02-04 14:18:36 +08:00
|
|
|
],
|
2024-02-05 15:55:58 +08:00
|
|
|
reserved_roles=[dict(role='SYSTEM', api_role='SYSTEM')],
|
2024-02-04 14:18:36 +08:00
|
|
|
)
|
|
|
|
|
2024-02-05 15:55:58 +08:00
|
|
|
# -------------Inference Stage ----------------------------------------
|
|
|
|
|
|
|
|
# For subjective evaluation, we often set do sample for models
|
|
|
|
models = [
|
|
|
|
dict(
|
|
|
|
type=HuggingFaceChatGLM3,
|
2024-03-28 16:49:04 +08:00
|
|
|
abbr='chatglm3-6b',
|
2024-02-05 15:55:58 +08:00
|
|
|
path='THUDM/chatglm3-6b',
|
|
|
|
tokenizer_path='THUDM/chatglm3-6b',
|
|
|
|
model_kwargs=dict(
|
|
|
|
device_map='auto',
|
|
|
|
trust_remote_code=True,
|
|
|
|
),
|
|
|
|
tokenizer_kwargs=dict(
|
|
|
|
padding_side='left',
|
|
|
|
truncation_side='left',
|
|
|
|
trust_remote_code=True,
|
|
|
|
),
|
|
|
|
generation_kwargs=dict(
|
|
|
|
do_sample=True,
|
|
|
|
),
|
|
|
|
meta_template=api_meta_template,
|
|
|
|
max_out_len=2048,
|
|
|
|
max_seq_len=4096,
|
|
|
|
batch_size=1,
|
|
|
|
run_cfg=dict(num_gpus=1, num_procs=1),
|
|
|
|
)
|
|
|
|
]
|
|
|
|
|
|
|
|
datasets = [*alpacav2]
|
|
|
|
|
|
|
|
# -------------Evalation Stage ----------------------------------------
|
|
|
|
|
|
|
|
## ------------- JudgeLLM Configuration
|
2024-03-28 16:49:04 +08:00
|
|
|
gpt4_judge = dict(
|
2024-02-05 15:55:58 +08:00
|
|
|
abbr='GPT4-Turbo',
|
|
|
|
path='gpt-4-1106-preview',
|
|
|
|
key='', # The key will be obtained from $OPENAI_API_KEY, but you can write down your key here as well
|
2024-03-28 16:49:04 +08:00
|
|
|
config='weighted_alpaca_eval_gpt4_turbo'
|
2024-02-04 14:18:36 +08:00
|
|
|
)
|
2024-02-05 15:55:58 +08:00
|
|
|
## ------------- Evaluation Configuration
|
2024-02-04 14:18:36 +08:00
|
|
|
eval = dict(
|
|
|
|
partitioner=dict(
|
2024-03-28 16:49:04 +08:00
|
|
|
type=NaivePartitioner
|
2024-02-04 14:18:36 +08:00
|
|
|
),
|
|
|
|
runner=dict(
|
2024-03-28 16:49:04 +08:00
|
|
|
type=LocalRunner,
|
2024-02-04 14:18:36 +08:00
|
|
|
max_num_workers=256,
|
2024-03-28 16:49:04 +08:00
|
|
|
task=dict(type=AlpacaEvalTask, judge_cfg=gpt4_judge),
|
|
|
|
)
|
2024-02-04 14:18:36 +08:00
|
|
|
)
|
|
|
|
work_dir = 'outputs/alpaca/'
|