-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Add huggingface apply_chat_template (#1098)
* add TheoremQA with 5-shot * add huggingface_above_v4_33 classes * use num_worker partitioner in cli * update theoremqa * update TheoremQA * add TheoremQA * rename theoremqa -> TheoremQA * update TheoremQA output path * rewrite many model configs * update huggingface * further update * refine configs * update configs * update configs * add configs/eval_llama3_instruct.py * add summarizer multi faceted * update bbh datasets * update configs/models/hf_llama/lmdeploy_llama3_8b_instruct.py * rename class * update readme * update hf above v4.33
- Loading branch information
Showing
186 changed files
with
1,949 additions
and
2,912 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from mmengine.config import read_base | ||
|
||
with read_base(): | ||
from ..datasets.mmlu.mmlu_gen_4d595a import mmlu_datasets | ||
from ..datasets.cmmlu.cmmlu_gen_c13365 import cmmlu_datasets | ||
from ..datasets.ceval.ceval_gen_5f30c7 import ceval_datasets | ||
from ..datasets.GaokaoBench.GaokaoBench_no_subjective_gen_4c31db import GaokaoBench_datasets | ||
from ..datasets.triviaqa.triviaqa_wiki_1shot_gen_eaf81e import triviaqa_datasets | ||
from ..datasets.nq.nq_open_1shot_gen_01cf41 import nq_datasets | ||
from ..datasets.race.race_gen_69ee4f import race_datasets | ||
from ..datasets.winogrande.winogrande_5shot_gen_b36770 import winogrande_datasets | ||
from ..datasets.hellaswag.hellaswag_10shot_gen_e42710 import hellaswag_datasets | ||
from ..datasets.bbh.bbh_gen_2879b0 import bbh_datasets | ||
from ..datasets.gsm8k.gsm8k_gen_1d7fe4 import gsm8k_datasets | ||
from ..datasets.math.math_0shot_gen_393424 import math_datasets | ||
from ..datasets.TheoremQA.TheoremQA_5shot_gen_6f0af8 import TheoremQA_datasets | ||
from ..datasets.humaneval.humaneval_gen_8e312c import humaneval_datasets | ||
from ..datasets.mbpp.sanitized_mbpp_gen_830460 import sanitized_mbpp_datasets | ||
from ..datasets.gpqa.gpqa_gen_4baadb import gpqa_datasets | ||
from ..datasets.IFEval.IFEval_gen_3321a3 import ifeval_datasets | ||
|
||
datasets = sum((v for k, v in locals().items() if k.endswith("_datasets")), []) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
from mmengine.config import read_base | ||
from opencompass.openicl.icl_prompt_template import PromptTemplate | ||
from opencompass.openicl.icl_retriever import ZeroRetriever | ||
from opencompass.openicl.icl_inferencer import GenInferencer | ||
from opencompass.datasets import BBHDataset, bbh_mcq_postprocess, BBHEvaluator, BBHEvaluator_mcq | ||
|
||
with read_base(): | ||
from .bbh_subset_settings import settings | ||
|
||
bbh_datasets = [] | ||
for name, test_type in settings: | ||
with open(os.path.join(os.path.dirname(__file__), 'lib_prompt', f'{name}.txt'), 'r') as f: | ||
hint = f.read() | ||
|
||
task_prompt, body = hint.split('\n\nQ:', 1) | ||
sections = ('Q:' + body).split('\n\n') | ||
prompt_rounds = [] | ||
for index, section in enumerate(sections): | ||
question, answer = section.split('\nA:') | ||
answer = 'A:' + answer | ||
if index == 0: | ||
desc = task_prompt.strip() + '\n' | ||
else: | ||
desc = '' | ||
prompt_rounds.append(dict(role="HUMAN", prompt=f"{desc}{question.strip()}")) | ||
prompt_rounds.append(dict(role="BOT", prompt=answer.strip())) | ||
prompt_rounds.append(dict(role="HUMAN", prompt="Q: {input}")) | ||
|
||
bbh_reader_cfg = dict(input_columns=["input"], output_column="target") | ||
|
||
bbh_infer_cfg = dict( | ||
prompt_template=dict(type=PromptTemplate, template=dict(round=prompt_rounds)), | ||
retriever=dict(type=ZeroRetriever), | ||
inferencer=dict(type=GenInferencer, max_out_len=512)) | ||
|
||
if test_type == 'mcq': | ||
bbh_eval_cfg = dict( | ||
evaluator=dict(type=BBHEvaluator_mcq), | ||
pred_role="BOT", | ||
pred_postprocessor=dict(type=bbh_mcq_postprocess), | ||
dataset_postprocessor=dict(type=bbh_mcq_postprocess)) | ||
else: | ||
bbh_eval_cfg = dict( | ||
evaluator=dict(type=BBHEvaluator), | ||
pred_role="BOT") | ||
|
||
bbh_datasets.append( | ||
dict( | ||
type=BBHDataset, | ||
path="./data/BBH/data", | ||
name=name, | ||
abbr='bbh-' + name, | ||
reader_cfg=bbh_reader_cfg.copy(), | ||
infer_cfg=bbh_infer_cfg.copy(), | ||
eval_cfg=bbh_eval_cfg.copy())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
settings = [ | ||
('temporal_sequences', 'mcq'), | ||
('disambiguation_qa', 'mcq'), | ||
('date_understanding', 'mcq'), | ||
('tracking_shuffled_objects_three_objects', 'mcq'), | ||
('penguins_in_a_table', 'mcq'), | ||
('geometric_shapes', 'mcq'), | ||
('snarks', 'mcq'), | ||
('ruin_names', 'mcq'), | ||
('tracking_shuffled_objects_seven_objects', 'mcq'), | ||
('tracking_shuffled_objects_five_objects', 'mcq'), | ||
('logical_deduction_three_objects', 'mcq'), | ||
('hyperbaton', 'mcq'), | ||
('logical_deduction_five_objects', 'mcq'), | ||
('logical_deduction_seven_objects', 'mcq'), | ||
('movie_recommendation', 'mcq'), | ||
('salient_translation_error_detection', 'mcq'), | ||
('reasoning_about_colored_objects', 'mcq'), | ||
('multistep_arithmetic_two', 'free_form'), | ||
('navigate', 'free_form'), | ||
('dyck_languages', 'free_form'), | ||
('word_sorting', 'free_form'), | ||
('sports_understanding', 'free_form'), | ||
('boolean_expressions', 'free_form'), | ||
('object_counting', 'free_form'), | ||
('formal_fallacies', 'free_form'), | ||
('causal_judgement', 'free_form'), | ||
('web_of_lies', 'free_form'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
46 changes: 46 additions & 0 deletions
46
configs/datasets/winogrande/winogrande_5shot_gen_b36770.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from opencompass.openicl.icl_prompt_template import PromptTemplate | ||
from opencompass.openicl.icl_retriever import FixKRetriever | ||
from opencompass.openicl.icl_inferencer import GenInferencer | ||
from opencompass.openicl.icl_evaluator import AccEvaluator | ||
from opencompass.datasets import winograndeDataset_V3 | ||
from opencompass.utils.text_postprocessors import first_option_postprocess | ||
|
||
winogrande_reader_cfg = dict( | ||
input_columns=["prompt", "only_option1", "only_option2"], | ||
output_column="answer", | ||
train_split="train_xs", | ||
test_split="dev", | ||
) | ||
|
||
winogrande_infer_cfg = dict( | ||
ice_template=dict( | ||
type=PromptTemplate, | ||
template=dict( | ||
begin="</E>", | ||
round=[ | ||
dict(role="HUMAN", prompt="Question: {prompt}\nA. {only_option1}\nB. {only_option2}\nAnswer:"), | ||
dict(role="BOT", prompt="{answer}"), | ||
] | ||
), | ||
ice_token="</E>", | ||
), | ||
retriever=dict(type=FixKRetriever, fix_id_list=[0, 2, 4, 6, 8]), | ||
inferencer=dict(type=GenInferencer), | ||
) | ||
|
||
winogrande_eval_cfg = dict( | ||
evaluator=dict(type=AccEvaluator), | ||
pred_role="BOT", | ||
pred_postprocessor=dict(type=first_option_postprocess, options="AB"), | ||
) | ||
|
||
winogrande_datasets = [ | ||
dict( | ||
abbr="winogrande", | ||
type=winograndeDataset_V3, | ||
path="./data/winogrande", | ||
reader_cfg=winogrande_reader_cfg, | ||
infer_cfg=winogrande_infer_cfg, | ||
eval_cfg=winogrande_eval_cfg, | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from mmengine.config import read_base | ||
|
||
with read_base(): | ||
from .winogrande_gen_a9ede5 import winogrande_datasets # noqa: F401, F403 | ||
from .winogrande_gen_458220 import winogrande_datasets # noqa: F401, F403 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from opencompass.openicl.icl_prompt_template import PromptTemplate | ||
from opencompass.openicl.icl_retriever import ZeroRetriever | ||
from opencompass.openicl.icl_inferencer import GenInferencer | ||
from opencompass.openicl.icl_evaluator import AccEvaluator | ||
from opencompass.datasets import winograndeDataset_V2 | ||
from opencompass.utils.text_postprocessors import first_option_postprocess | ||
|
||
winogrande_reader_cfg = dict( | ||
input_columns=["prompt", "only_option1", "only_option2"], | ||
output_column="answer", | ||
) | ||
|
||
winogrande_infer_cfg = dict( | ||
prompt_template=dict( | ||
type=PromptTemplate, | ||
template=dict( | ||
round=[ | ||
dict(role="HUMAN", prompt="Question: {prompt}\nA. {only_option1}\nB. {only_option2}\nAnswer:"), | ||
] | ||
), | ||
), | ||
retriever=dict(type=ZeroRetriever), | ||
inferencer=dict(type=GenInferencer), | ||
) | ||
|
||
winogrande_eval_cfg = dict( | ||
evaluator=dict(type=AccEvaluator), | ||
pred_role="BOT", | ||
pred_postprocessor=dict(type=first_option_postprocess, options='AB'), | ||
) | ||
|
||
winogrande_datasets = [ | ||
dict( | ||
abbr="winogrande", | ||
type=winograndeDataset_V2, | ||
path='./data/winogrande', | ||
reader_cfg=winogrande_reader_cfg, | ||
infer_cfg=winogrande_infer_cfg, | ||
eval_cfg=winogrande_eval_cfg, | ||
) | ||
] |
Oops, something went wrong.