2023-12-13 19:59:30 +08:00
|
|
|
from mmengine.config import read_base
|
2024-02-05 15:55:58 +08:00
|
|
|
|
2023-12-13 19:59:30 +08:00
|
|
|
with read_base():
|
2024-01-16 18:03:11 +08:00
|
|
|
from .datasets.subjective.alignbench.alignbench_judgeby_critiquellm import subjective_datasets
|
2023-12-13 19:59:30 +08:00
|
|
|
|
2024-03-22 19:54:19 +08:00
|
|
|
from opencompass.models import HuggingFaceCausalLM, HuggingFace, HuggingFaceChatGLM3, OpenAI
|
2024-01-16 18:03:11 +08:00
|
|
|
from opencompass.partitioners import NaivePartitioner, SizePartitioner
|
2023-12-13 19:59:30 +08:00
|
|
|
from opencompass.partitioners.sub_naive import SubjectiveNaivePartitioner
|
2024-01-16 18:03:11 +08:00
|
|
|
from opencompass.partitioners.sub_size import SubjectiveSizePartitioner
|
2023-12-13 19:59:30 +08:00
|
|
|
from opencompass.runners import LocalRunner
|
|
|
|
from opencompass.runners import SlurmSequentialRunner
|
|
|
|
from opencompass.tasks import OpenICLInferTask
|
|
|
|
from opencompass.tasks.subjective_eval import SubjectiveEvalTask
|
|
|
|
from opencompass.summarizers import AlignmentBenchSummarizer
|
|
|
|
|
2024-02-05 15:55:58 +08:00
|
|
|
api_meta_template = dict(
|
|
|
|
round=[
|
|
|
|
dict(role='HUMAN', api_role='HUMAN'),
|
|
|
|
dict(role='BOT', api_role='BOT', generate=True),
|
|
|
|
]
|
|
|
|
)
|
2023-12-14 18:24:21 +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,
|
|
|
|
abbr='chatglm3-6b-hf',
|
|
|
|
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,
|
2024-04-02 11:52:06 +08:00
|
|
|
batch_size=8,
|
2024-02-05 15:55:58 +08:00
|
|
|
run_cfg=dict(num_gpus=1, num_procs=1),
|
|
|
|
)
|
|
|
|
]
|
2023-12-14 18:24:21 +08:00
|
|
|
|
2024-02-05 15:55:58 +08:00
|
|
|
datasets = [*subjective_datasets]
|
2023-12-13 19:59:30 +08:00
|
|
|
|
2023-12-14 18:24:21 +08:00
|
|
|
# -------------Evalation Stage ----------------------------------------
|
|
|
|
|
|
|
|
## ------------- JudgeLLM Configuration
|
2024-04-02 11:52:06 +08:00
|
|
|
judge_models = [dict(
|
2024-02-05 15:55:58 +08:00
|
|
|
abbr='GPT4-Turbo',
|
2024-03-22 19:54:19 +08:00
|
|
|
type=OpenAI,
|
2024-02-05 15:55:58 +08:00
|
|
|
path='gpt-4-1106-preview',
|
|
|
|
key='xxxx', # The key will be obtained from $OPENAI_API_KEY, but you can write down your key here as well
|
|
|
|
meta_template=api_meta_template,
|
|
|
|
query_per_second=16,
|
|
|
|
max_out_len=2048,
|
|
|
|
max_seq_len=2048,
|
|
|
|
batch_size=8,
|
|
|
|
temperature=0,
|
2024-04-02 11:52:06 +08:00
|
|
|
)]
|
2023-12-13 19:59:30 +08:00
|
|
|
|
2023-12-14 18:24:21 +08:00
|
|
|
## ------------- Evaluation Configuration
|
2023-12-13 19:59:30 +08:00
|
|
|
eval = dict(
|
|
|
|
partitioner=dict(
|
2024-04-02 11:52:06 +08:00
|
|
|
type=SubjectiveSizePartitioner, max_task_size=1000, mode='singlescore', models=models, judge_models=judge_models,
|
2024-02-05 15:55:58 +08:00
|
|
|
),
|
2024-04-02 11:52:06 +08:00
|
|
|
runner=dict(type=LocalRunner, max_num_workers=2, task=dict(type=SubjectiveEvalTask)),
|
2023-12-13 19:59:30 +08:00
|
|
|
)
|
|
|
|
|
2024-02-05 15:55:58 +08:00
|
|
|
summarizer = dict(type=AlignmentBenchSummarizer, judge_type='general')
|
2023-12-14 18:24:21 +08:00
|
|
|
|
|
|
|
work_dir = 'outputs/alignment_bench/'
|