Unverified Commit aa2dd2b5 authored by Fengzhe Zhou's avatar Fengzhe Zhou Committed by GitHub
Browse files

[Format] Add config lints (#892)

parent 3dbba119
...@@ -6,9 +6,9 @@ from opencompass.datasets import piqaDataset_V2 ...@@ -6,9 +6,9 @@ from opencompass.datasets import piqaDataset_V2
from opencompass.utils.text_postprocessors import first_option_postprocess from opencompass.utils.text_postprocessors import first_option_postprocess
piqa_reader_cfg = dict( piqa_reader_cfg = dict(
input_columns=["goal", "sol1", "sol2"], input_columns=['goal', 'sol1', 'sol2'],
output_column="answer", output_column='answer',
test_split="validation") test_split='validation')
piqa_infer_cfg = dict( piqa_infer_cfg = dict(
prompt_template=dict( prompt_template=dict(
...@@ -16,8 +16,8 @@ piqa_infer_cfg = dict( ...@@ -16,8 +16,8 @@ piqa_infer_cfg = dict(
template=dict( template=dict(
round=[ round=[
dict( dict(
role="HUMAN", role='HUMAN',
prompt="{goal}\nA. {sol1}\nB. {sol2}\nAnswer:") prompt='{goal}\nA. {sol1}\nB. {sol2}\nAnswer:')
], ), ], ),
), ),
retriever=dict(type=ZeroRetriever), retriever=dict(type=ZeroRetriever),
...@@ -26,13 +26,13 @@ piqa_infer_cfg = dict( ...@@ -26,13 +26,13 @@ piqa_infer_cfg = dict(
piqa_eval_cfg = dict( piqa_eval_cfg = dict(
evaluator=dict(type=AccEvaluator), evaluator=dict(type=AccEvaluator),
pred_role="BOT", pred_role='BOT',
pred_postprocessor=dict(type=first_option_postprocess, options='AB'), pred_postprocessor=dict(type=first_option_postprocess, options='AB'),
) )
piqa_datasets = [ piqa_datasets = [
dict( dict(
abbr="piqa", abbr='piqa',
type=piqaDataset_V2, type=piqaDataset_V2,
path='./data/piqa', path='./data/piqa',
reader_cfg=piqa_reader_cfg, reader_cfg=piqa_reader_cfg,
......
...@@ -13,11 +13,11 @@ piqa_infer_cfg = dict( ...@@ -13,11 +13,11 @@ piqa_infer_cfg = dict(
prompt_template=dict( prompt_template=dict(
type=PromptTemplate, type=PromptTemplate,
template={ template={
"0": dict( '0': dict(
round=[dict(role="HUMAN", prompt="{goal} {sol1}")] round=[dict(role='HUMAN', prompt='{goal} {sol1}')]
), ),
"1": dict( '1': dict(
round=[dict(role="HUMAN", prompt="{goal} {sol2}")] round=[dict(role='HUMAN', prompt='{goal} {sol2}')]
), ),
} }
), ),
......
...@@ -16,14 +16,14 @@ piqa_infer_cfg = dict( ...@@ -16,14 +16,14 @@ piqa_infer_cfg = dict(
0: 0:
dict( dict(
round=[ round=[
dict(role="HUMAN", prompt="{goal}"), dict(role='HUMAN', prompt='{goal}'),
dict(role="BOT", prompt="{sol1}") dict(role='BOT', prompt='{sol1}')
], ), ], ),
1: 1:
dict( dict(
round=[ round=[
dict(role="HUMAN", prompt="{goal}"), dict(role='HUMAN', prompt='{goal}'),
dict(role="BOT", prompt="{sol2}") dict(role='BOT', prompt='{sol2}')
], ) ], )
}), }),
retriever=dict(type=ZeroRetriever), retriever=dict(type=ZeroRetriever),
......
...@@ -9,16 +9,16 @@ iwslt2017_reader_cfg = dict( ...@@ -9,16 +9,16 @@ iwslt2017_reader_cfg = dict(
input_columns='en', output_column='de', train_split='validation') input_columns='en', output_column='de', train_split='validation')
original_prompt_list = [ original_prompt_list = [
"Translate the provided sentence from English to German while maintaining the original meaning and context:", 'Translate the provided sentence from English to German while maintaining the original meaning and context:',
"Convert the following sentence from its original English language to the target language German:", 'Convert the following sentence from its original English language to the target language German:',
"Given the sentence below, perform a machine translation from English to German:", 'Given the sentence below, perform a machine translation from English to German:',
"Translate the subsequent sentence from its source language English into the desired language German:", 'Translate the subsequent sentence from its source language English into the desired language German:',
"Accurately translate the sentence from English to German, ensuring the meaning remains intact:", 'Accurately translate the sentence from English to German, ensuring the meaning remains intact:',
"Please perform a translation of the given sentence, converting it from English to German:", 'Please perform a translation of the given sentence, converting it from English to German:',
"Translate the following text from the source language English to the target language German:", 'Translate the following text from the source language English to the target language German:',
"Using machine translation, convert the given sentence from English into the German language:", 'Using machine translation, convert the given sentence from English into the German language:',
"Translate the subsequent text passage from its original English language to the German language:", 'Translate the subsequent text passage from its original English language to the German language:',
"Perform a machine translation for the provided sentence, changing it from English to German:", 'Perform a machine translation for the provided sentence, changing it from English to German:',
] ]
iwslt2017_infer_cfg = dict( iwslt2017_infer_cfg = dict(
......
...@@ -6,16 +6,16 @@ from opencompass.datasets import MATHDataset, MATHEvaluator, math_postprocess ...@@ -6,16 +6,16 @@ from opencompass.datasets import MATHDataset, MATHEvaluator, math_postprocess
math_reader_cfg = dict(input_columns=['problem'], output_column='solution') math_reader_cfg = dict(input_columns=['problem'], output_column='solution')
original_prompt_list = [ original_prompt_list = [
"Solve the following math question about", 'Solve the following math question about',
"Determine the solution to this mathematical problem related to", 'Determine the solution to this mathematical problem related to',
"Calculate the answer to the following math query about", 'Calculate the answer to the following math query about',
"Find the solution for this mathematical challenge with", 'Find the solution for this mathematical challenge with',
"Compute the result of this math task concerning", 'Compute the result of this math task concerning',
"Resolve the following mathematical question associated with", 'Resolve the following mathematical question associated with',
"Work out the answer to this math problem featuring", 'Work out the answer to this math problem featuring',
"Figure out the solution for the following mathematical task with", 'Figure out the solution for the following mathematical task with',
"Obtain the result for this math question regarding", 'Obtain the result for this math question regarding',
"Evaluate the following mathematical problem that includes", 'Evaluate the following mathematical problem that includes',
] ]
math_infer_cfg = dict( math_infer_cfg = dict(
...@@ -23,8 +23,8 @@ math_infer_cfg = dict( ...@@ -23,8 +23,8 @@ math_infer_cfg = dict(
type=PromptTemplate, type=PromptTemplate,
template=dict(round=[ template=dict(round=[
dict( dict(
role="HUMAN", role='HUMAN',
prompt="{adv_prompt} {problem}:"), prompt='{adv_prompt} {problem}:'),
]), ]),
), ),
retriever=dict(type=ZeroRetriever), retriever=dict(type=ZeroRetriever),
......
...@@ -30,7 +30,7 @@ wnli_infer_cfg = dict( ...@@ -30,7 +30,7 @@ wnli_infer_cfg = dict(
type=PromptTemplate, type=PromptTemplate,
template=dict(round=[ template=dict(round=[
dict( dict(
role="HUMAN", role='HUMAN',
prompt="""{adv_prompt} prompt="""{adv_prompt}
Sentence 1: {sentence1} Sentence 1: {sentence1}
Sentence 2: {sentence2} Sentence 2: {sentence2}
...@@ -45,7 +45,7 @@ Answer:"""), ...@@ -45,7 +45,7 @@ Answer:"""),
wnli_eval_cfg = dict( wnli_eval_cfg = dict(
evaluator=dict(type=AccEvaluator), evaluator=dict(type=AccEvaluator),
pred_role="BOT", pred_role='BOT',
pred_postprocessor=dict(type=first_option_postprocess, options='AB'), pred_postprocessor=dict(type=first_option_postprocess, options='AB'),
) )
...@@ -58,4 +58,4 @@ wnli_datasets = [ ...@@ -58,4 +58,4 @@ wnli_datasets = [
reader_cfg=wnli_reader_cfg, reader_cfg=wnli_reader_cfg,
infer_cfg=wnli_infer_cfg, infer_cfg=wnli_infer_cfg,
eval_cfg=wnli_eval_cfg) eval_cfg=wnli_eval_cfg)
] ]
\ No newline at end of file
from mmengine.config import read_base from mmengine.config import read_base
with read_base(): with read_base():
from .py150_gen_38b13d import py150_datasets # noqa: F401, F403 from .py150_gen_38b13d import py150_datasets # noqa: F401, F403
\ No newline at end of file
...@@ -7,8 +7,8 @@ from opencompass.utils.text_postprocessors import first_capital_postprocess ...@@ -7,8 +7,8 @@ from opencompass.utils.text_postprocessors import first_capital_postprocess
py150_reader_cfg = dict( py150_reader_cfg = dict(
input_columns="input", input_columns='input',
output_column="gt", output_column='gt',
) )
py150_infer_cfg = dict( py150_infer_cfg = dict(
...@@ -16,8 +16,8 @@ py150_infer_cfg = dict( ...@@ -16,8 +16,8 @@ py150_infer_cfg = dict(
type=PromptTemplate, type=PromptTemplate,
template=dict( template=dict(
round=[ round=[
dict(role="HUMAN", prompt="I will give you a part of python code. Please write down what the next line of code is. Note that you only need to give the next line of code, and you don't need to give any other reply.\nCode:{input}\nNext line:"), dict(role='HUMAN', prompt="I will give you a part of python code. Please write down what the next line of code is. Note that you only need to give the next line of code, and you don't need to give any other reply.\nCode:{input}\nNext line:"),
dict(role="BOT", prompt="{gt}"), dict(role='BOT', prompt='{gt}'),
] ]
), ),
), ),
...@@ -26,16 +26,16 @@ py150_infer_cfg = dict( ...@@ -26,16 +26,16 @@ py150_infer_cfg = dict(
) )
py150_eval_cfg = dict(evaluator=dict(type=BleuEvaluator), py150_eval_cfg = dict(evaluator=dict(type=BleuEvaluator),
pred_role="BOT" pred_role='BOT'
) )
py150_datasets = [ py150_datasets = [
dict( dict(
type=Py150Dataset, type=Py150Dataset,
abbr=f"py150", abbr=f'py150',
path=f"data/py150/test.json", path=f'data/py150/test.json',
reader_cfg=py150_reader_cfg, reader_cfg=py150_reader_cfg,
infer_cfg=py150_infer_cfg, infer_cfg=py150_infer_cfg,
eval_cfg=py150_eval_cfg, eval_cfg=py150_eval_cfg,
) )
] ]
\ No newline at end of file
...@@ -12,7 +12,7 @@ qabench_reader_cfg = dict( ...@@ -12,7 +12,7 @@ qabench_reader_cfg = dict(
qabench_infer_cfg = dict( qabench_infer_cfg = dict(
prompt_template=dict( prompt_template=dict(
type=PromptTemplate, type=PromptTemplate,
template=dict(round=[dict(role="HUMAN", prompt="{prompt}")])), template=dict(round=[dict(role='HUMAN', prompt='{prompt}')])),
retriever=dict(type=ZeroRetriever), retriever=dict(type=ZeroRetriever),
inferencer=dict(type=GenInferencer)) inferencer=dict(type=GenInferencer))
...@@ -21,9 +21,9 @@ qabench_datasets = [ ...@@ -21,9 +21,9 @@ qabench_datasets = [
type=HFDataset, type=HFDataset,
path='csv', path='csv',
data_files='./data/qabench/qabench-test.qa.csv', data_files='./data/qabench/qabench-test.qa.csv',
abbr="qabench", abbr='qabench',
split='train', split='train',
reader_cfg=qabench_reader_cfg, reader_cfg=qabench_reader_cfg,
infer_cfg=qabench_infer_cfg, infer_cfg=qabench_infer_cfg,
eval_cfg=dict(ds_column="reference")) eval_cfg=dict(ds_column='reference'))
] ]
...@@ -12,7 +12,7 @@ qasper_reader_cfg = dict( ...@@ -12,7 +12,7 @@ qasper_reader_cfg = dict(
qasper_infer_cfg = dict( qasper_infer_cfg = dict(
prompt_template=dict( prompt_template=dict(
type=PromptTemplate, type=PromptTemplate,
template="{evidence}\nAnswer these questions:\nQ: {question}?\nA:"), template='{evidence}\nAnswer these questions:\nQ: {question}?\nA:'),
retriever=dict(type=ZeroRetriever), retriever=dict(type=ZeroRetriever),
inferencer=dict( inferencer=dict(
type=GenInferencer, max_out_len=50, max_seq_len=8192, batch_size=4)) type=GenInferencer, max_out_len=50, max_seq_len=8192, batch_size=4))
......
...@@ -12,7 +12,7 @@ qaspercut_reader_cfg = dict( ...@@ -12,7 +12,7 @@ qaspercut_reader_cfg = dict(
qaspercut_infer_cfg = dict( qaspercut_infer_cfg = dict(
prompt_template=dict( prompt_template=dict(
type=PromptTemplate, type=PromptTemplate,
template="{evidence}\nAnswer these questions:\nQ: {question}?\nA:"), template='{evidence}\nAnswer these questions:\nQ: {question}?\nA:'),
retriever=dict(type=ZeroRetriever), retriever=dict(type=ZeroRetriever),
inferencer=dict( inferencer=dict(
type=GenInferencer, max_out_len=50, max_seq_len=8192, batch_size=4)) type=GenInferencer, max_out_len=50, max_seq_len=8192, batch_size=4))
......
...@@ -8,8 +8,8 @@ from opencompass.utils.text_postprocessors import first_option_postprocess ...@@ -8,8 +8,8 @@ from opencompass.utils.text_postprocessors import first_option_postprocess
race_reader_cfg = dict( race_reader_cfg = dict(
input_columns=['article', 'question', 'A', 'B', 'C', 'D'], input_columns=['article', 'question', 'A', 'B', 'C', 'D'],
output_column='answer', output_column='answer',
train_split="validation", train_split='validation',
test_split="test" test_split='test'
) )
race_infer_cfg = dict( race_infer_cfg = dict(
...@@ -17,9 +17,9 @@ race_infer_cfg = dict( ...@@ -17,9 +17,9 @@ race_infer_cfg = dict(
type=PromptTemplate, type=PromptTemplate,
template=dict(round=[ template=dict(round=[
dict( dict(
role="HUMAN", role='HUMAN',
prompt= prompt=
"Read the article, and answer the question by replying A, B, C or D.\n\nArticle:\n{article}\n\nQ: {question}\n\nA. {A}\nB. {B}\nC. {C}\nD. {D}" 'Read the article, and answer the question by replying A, B, C or D.\n\nArticle:\n{article}\n\nQ: {question}\n\nA. {A}\nB. {B}\nC. {C}\nD. {D}'
), ),
])), ])),
retriever=dict(type=ZeroRetriever), retriever=dict(type=ZeroRetriever),
......
...@@ -8,8 +8,8 @@ from opencompass.utils.text_postprocessors import first_capital_postprocess ...@@ -8,8 +8,8 @@ from opencompass.utils.text_postprocessors import first_capital_postprocess
race_reader_cfg = dict( race_reader_cfg = dict(
input_columns=['article', 'question', 'A', 'B', 'C', 'D'], input_columns=['article', 'question', 'A', 'B', 'C', 'D'],
output_column='answer', output_column='answer',
train_split="validation", train_split='validation',
test_split="test" test_split='test'
) )
race_infer_cfg = dict( race_infer_cfg = dict(
......
...@@ -7,8 +7,8 @@ from opencompass.datasets import RaceDataset ...@@ -7,8 +7,8 @@ from opencompass.datasets import RaceDataset
race_reader_cfg = dict( race_reader_cfg = dict(
input_columns=['article', 'question', 'A', 'B', 'C', 'D'], input_columns=['article', 'question', 'A', 'B', 'C', 'D'],
output_column='answer', output_column='answer',
train_split="validation", train_split='validation',
test_split="test" test_split='test'
) )
race_infer_cfg = dict( race_infer_cfg = dict(
...@@ -17,8 +17,8 @@ race_infer_cfg = dict( ...@@ -17,8 +17,8 @@ race_infer_cfg = dict(
template={ template={
ans: dict( ans: dict(
round=[ round=[
dict(role="HUMAN", prompt="Article:\n{article}\nQuestion:\n{question}\nA. {A}\nB. {B}\nC. {C}\nD. {D}"), dict(role='HUMAN', prompt='Article:\n{article}\nQuestion:\n{question}\nA. {A}\nB. {B}\nC. {C}\nD. {D}'),
dict(role="BOT", prompt=f'Answer: {ans}'), dict(role='BOT', prompt=f'Answer: {ans}'),
] ]
) )
for ans in ['A', 'B', 'C', 'D'] for ans in ['A', 'B', 'C', 'D']
......
...@@ -7,8 +7,8 @@ from opencompass.datasets import RaceDataset ...@@ -7,8 +7,8 @@ from opencompass.datasets import RaceDataset
race_reader_cfg = dict( race_reader_cfg = dict(
input_columns=['article', 'question', 'A', 'B', 'C', 'D'], input_columns=['article', 'question', 'A', 'B', 'C', 'D'],
output_column='answer', output_column='answer',
train_split="validation", train_split='validation',
test_split="test" test_split='test'
) )
race_infer_cfg = dict( race_infer_cfg = dict(
...@@ -17,11 +17,11 @@ race_infer_cfg = dict( ...@@ -17,11 +17,11 @@ race_infer_cfg = dict(
template={ template={
ans: dict(round=[ ans: dict(round=[
dict( dict(
role="HUMAN", role='HUMAN',
prompt= prompt=
"Read the article, and answer the question by replying A, B, C or D.\n\nArticle:\n{article}\n\nQ: {question}\n\nA. {A}\nB. {B}\nC. {C}\nD. {D}" 'Read the article, and answer the question by replying A, B, C or D.\n\nArticle:\n{article}\n\nQ: {question}\n\nA. {A}\nB. {B}\nC. {C}\nD. {D}'
), ),
dict(role="BOT", prompt=f'A: {ans}'), dict(role='BOT', prompt=f'A: {ans}'),
]) ])
for ans in ['A', 'B', 'C', 'D'] for ans in ['A', 'B', 'C', 'D']
}), }),
......
...@@ -7,12 +7,12 @@ from opencompass.datasets import RaceDataset ...@@ -7,12 +7,12 @@ from opencompass.datasets import RaceDataset
race_reader_cfg = dict( race_reader_cfg = dict(
input_columns=['article', 'question', 'A', 'B', 'C', 'D'], input_columns=['article', 'question', 'A', 'B', 'C', 'D'],
output_column='answer', output_column='answer',
train_split="validation", train_split='validation',
test_split="test" test_split='test'
) )
hint = "Read the article, and answer the question by replying A, B, C or D." hint = 'Read the article, and answer the question by replying A, B, C or D.'
question_and_options = "{article}\n\nQ: {question}\n\nA. {A}\nB. {B}\nC. {C}\nD. {D}" question_and_options = '{article}\n\nQ: {question}\n\nA. {A}\nB. {B}\nC. {C}\nD. {D}'
race_infer_cfg = dict( race_infer_cfg = dict(
prompt_template=dict( prompt_template=dict(
type=PromptTemplate, type=PromptTemplate,
......
...@@ -14,7 +14,7 @@ realtoxicprompts_reader_cfg = dict( ...@@ -14,7 +14,7 @@ realtoxicprompts_reader_cfg = dict(
realtoxicprompts_infer_cfg = dict( realtoxicprompts_infer_cfg = dict(
prompt_template=dict( prompt_template=dict(
type=PromptTemplate, type=PromptTemplate,
template=dict(round=[dict(role="HUMAN", prompt="{prompt_text}")])), template=dict(round=[dict(role='HUMAN', prompt='{prompt_text}')])),
retriever=dict(type=ZeroRetriever), retriever=dict(type=ZeroRetriever),
inferencer=dict(type=GenInferencer)) inferencer=dict(type=GenInferencer))
......
...@@ -27,7 +27,7 @@ instruction_generalization_eng_infer_cfg = dict( ...@@ -27,7 +27,7 @@ instruction_generalization_eng_infer_cfg = dict(
) )
instruction_generalization_eng_eval_cfg = dict( instruction_generalization_eng_eval_cfg = dict(
evaluator=dict(type=RougeEvaluator), evaluator=dict(type=RougeEvaluator),
pred_role='BOT' pred_role='BOT'
) )
......
...@@ -27,7 +27,7 @@ instruction_generalization_zh_infer_cfg = dict( ...@@ -27,7 +27,7 @@ instruction_generalization_zh_infer_cfg = dict(
) )
instruction_generalization_zh_eval_cfg = dict( instruction_generalization_zh_eval_cfg = dict(
evaluator=dict(type=RougeEvaluator), evaluator=dict(type=RougeEvaluator),
pred_role='BOT' pred_role='BOT'
) )
......
...@@ -27,7 +27,7 @@ role_generalization_eng_infer_cfg = dict( ...@@ -27,7 +27,7 @@ role_generalization_eng_infer_cfg = dict(
) )
role_generalization_eng_eval_cfg = dict( role_generalization_eng_eval_cfg = dict(
evaluator=dict(type=RougeEvaluator), evaluator=dict(type=RougeEvaluator),
pred_role='BOT' pred_role='BOT'
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment