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.
- Loading branch information
liushz
committed
Aug 28, 2023
1 parent
b2d602f
commit 0bf908e
Showing
7 changed files
with
2,908 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from mmengine.config import read_base | ||
|
||
with read_base(): | ||
from .toolbench_gen_3131 import toolbench_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,31 @@ | ||
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 ToolBenchDataset, ToolBenchEvaluator | ||
|
||
toolbench_reader_cfg = dict( | ||
input_columns=['query', 'avaliable_tools'], | ||
output_column='answer' | ||
) | ||
|
||
toolbench_infer_cfg = dict( | ||
retriever=dict(type=ZeroRetriever), | ||
inferencer=dict(type=GenInferencer)) | ||
|
||
toolbench_eval_cfg = dict( | ||
evaluator=dict(type=ToolBenchEvaluator), pred_postprocessor=dict(type='toolbench')) # use the same processor to find answer | ||
|
||
splits = ['G1_answer_converted','G2_answer_converted', 'G3_answer_converted'] | ||
|
||
toolbench_datasets = [] | ||
|
||
for split in splits: | ||
toolbench_datasets.append( | ||
dict( | ||
abbr='toolbench_{}'.format(split), | ||
type=ToolBenchDataset, | ||
path='./data/ToolBench', | ||
name = split, | ||
reader_cfg=toolbench_reader_cfg, | ||
infer_cfg=toolbench_infer_cfg, | ||
eval_cfg=toolbench_eval_cfg)) |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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,39 @@ | ||
from opencompass.registry import TEXT_POSTPROCESSORS, LOAD_DATASET, ICL_EVALUATORS | ||
from .base import BaseDataset | ||
from opencompass.openicl.icl_evaluator import BaseEvaluator | ||
|
||
import os | ||
import json | ||
|
||
from datasets import Dataset, load_dataset, DatasetDict | ||
|
||
|
||
@TEXT_POSTPROCESSORS.register_module('toolbench_dataset') | ||
def toolbench_dataset_postprocess(text: str) -> str: | ||
pass | ||
|
||
|
||
@ICL_EVALUATORS.register_module() | ||
class ToolBenchEvaluator(BaseEvaluator): | ||
|
||
def score(self, predictions, references): | ||
pass | ||
|
||
|
||
@LOAD_DATASET.register_module() | ||
class ToolBenchDataset(BaseDataset): | ||
|
||
@staticmethod | ||
def load(path: str, name: str): | ||
dataset = [] | ||
# splits = ['G1_answer_converted', 'G1_answer_converted', 'G1_answer_converted'] | ||
if '.json' not in name: | ||
name += '.json' | ||
path = os.path.join(path, name) | ||
with open(path, 'r') as f: | ||
all_data = json.load(f) | ||
dataset = list(all_data.values()) | ||
|
||
return Dataset.from_list(dataset) | ||
|
||
|