forked from open-compass/opencompass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:open-compass/opencompass into github
- Loading branch information
Showing
142 changed files
with
5,004 additions
and
897 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 was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
configs/datasets/CHARM/charm_reason_cot_only_gen_f7b7d3.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,50 @@ | ||
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 CharmDataset, charm_reason_postprocess, CharmReasonEvaluator | ||
|
||
with read_base(): | ||
from .charm_reason_settings import charm_tasks, settings | ||
|
||
settings = [s for s in settings if s[0] in ['ZH-CoT', 'EN-CoT']] | ||
|
||
charm_reason_datasets = [] | ||
|
||
for _cot, _cot_prefix, dataset_path, fewshot_example_path, prompt_template in settings: | ||
for _task in charm_tasks: | ||
_fewshot_example_file = os.path.join(fewshot_example_path, f'{_task}_{_cot}.txt') | ||
with open(_fewshot_example_file, 'r') as f: | ||
_hint = f.read() | ||
|
||
charm_reason_reader_cfg = dict(input_columns=['input'], output_column='target') | ||
|
||
charm_reason_infer_cfg = dict( | ||
prompt_template=dict( | ||
type=PromptTemplate, | ||
template=dict(round=[dict(role='HUMAN', prompt=prompt_template.format(_hint=_hint) + _cot_prefix)]), | ||
), | ||
retriever=dict(type=ZeroRetriever), | ||
inferencer=dict(type=GenInferencer, max_out_len=512), | ||
) | ||
|
||
charm_reason_eval_cfg = dict( | ||
evaluator=dict(type=CharmReasonEvaluator), | ||
pred_role='BOT', | ||
pred_postprocessor=dict(type=charm_reason_postprocess), | ||
dataset_postprocessor=dict(type=charm_reason_postprocess), | ||
) | ||
|
||
charm_reason_datasets.append( | ||
dict( | ||
type=CharmDataset, | ||
path=dataset_path, | ||
name=_task, | ||
abbr='charm-reason-' + _task + '_' + _cot, | ||
reader_cfg=charm_reason_reader_cfg, | ||
infer_cfg=charm_reason_infer_cfg.copy(), | ||
eval_cfg=charm_reason_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,4 @@ | ||
from mmengine.config import read_base | ||
|
||
with read_base(): | ||
from .charm_reason_gen_f8fca2 import charm_reason_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,49 @@ | ||
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 CharmDataset, charm_reason_postprocess, CharmReasonEvaluator | ||
|
||
with read_base(): | ||
from .charm_reason_settings import charm_tasks, settings | ||
|
||
|
||
charm_reason_datasets = [] | ||
|
||
for _cot, _cot_prefix, dataset_path, fewshot_example_path, prompt_template in settings: | ||
for _task in charm_tasks: | ||
_fewshot_example_file = os.path.join(fewshot_example_path, f'{_task}_{_cot}.txt') | ||
with open(_fewshot_example_file, 'r') as f: | ||
_hint = f.read() | ||
|
||
charm_reason_reader_cfg = dict(input_columns=['input'], output_column='target') | ||
|
||
charm_reason_infer_cfg = dict( | ||
prompt_template=dict( | ||
type=PromptTemplate, | ||
template=dict(round=[dict(role='HUMAN', prompt=prompt_template.format(_hint=_hint) + _cot_prefix)]), | ||
), | ||
retriever=dict(type=ZeroRetriever), | ||
inferencer=dict(type=GenInferencer, max_out_len=512), | ||
) | ||
|
||
charm_reason_eval_cfg = dict( | ||
evaluator=dict(type=CharmReasonEvaluator), | ||
pred_role='BOT', | ||
pred_postprocessor=dict(type=charm_reason_postprocess), | ||
dataset_postprocessor=dict(type=charm_reason_postprocess), | ||
) | ||
|
||
charm_reason_datasets.append( | ||
dict( | ||
type=CharmDataset, | ||
path=dataset_path, | ||
name=_task, | ||
abbr='charm-reason-' + _task + '_' + _cot, | ||
reader_cfg=charm_reason_reader_cfg, | ||
infer_cfg=charm_reason_infer_cfg.copy(), | ||
eval_cfg=charm_reason_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
Oops, something went wrong.