Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
opencompass
Commits
f83e125e
Unverified
Commit
f83e125e
authored
Jul 18, 2023
by
Hubert
Committed by
GitHub
Jul 18, 2023
Browse files
[Feat] Support CValues Responsibility dataset (#78)
* [Feat] support CValues * minor fix
parent
26e2f171
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
0 deletions
+67
-0
configs/datasets/cvalues/cvalues_responsibility_gen.py
configs/datasets/cvalues/cvalues_responsibility_gen.py
+4
-0
configs/datasets/cvalues/cvalues_responsibility_gen_4aec9f.py
...igs/datasets/cvalues/cvalues_responsibility_gen_4aec9f.py
+37
-0
opencompass/datasets/__init__.py
opencompass/datasets/__init__.py
+1
-0
opencompass/datasets/cvalues.py
opencompass/datasets/cvalues.py
+25
-0
No files found.
configs/datasets/cvalues/cvalues_responsibility_gen.py
0 → 100644
View file @
f83e125e
from
mmengine.config
import
read_base
with
read_base
():
from
.cvalues_responsibility_gen_4aec9f
import
cvalues_datasets
# noqa: F401, F403
configs/datasets/cvalues/cvalues_responsibility_gen_4aec9f.py
0 → 100644
View file @
f83e125e
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
CValuesDataset
from
opencompass.utils.text_postprocessors
import
first_capital_postprocess
cvalues_reader_cfg
=
dict
(
input_columns
=
[
'prompt'
],
output_column
=
'label'
,
train_split
=
'train'
,
test_split
=
'train'
,
)
cvalues_infer_cfg
=
dict
(
prompt_template
=
dict
(
type
=
PromptTemplate
,
template
=
dict
(
round
=
[
dict
(
role
=
"HUMAN"
,
prompt
=
"{prompt}请直接给出答案:
\n
"
)])),
retriever
=
dict
(
type
=
ZeroRetriever
),
inferencer
=
dict
(
type
=
GenInferencer
))
cvalues_eval_cfg
=
dict
(
evaluator
=
dict
(
type
=
AccEvaluator
),
pred_role
=
"BOT"
,
pred_postprocessor
=
dict
(
type
=
first_capital_postprocess
),
)
cvalues_datasets
=
[
dict
(
abbr
=
'CValues-Responsibility'
,
type
=
CValuesDataset
,
path
=
'data/cvalues_responsibility_mc.jsonl'
,
reader_cfg
=
cvalues_reader_cfg
,
infer_cfg
=
cvalues_infer_cfg
,
eval_cfg
=
cvalues_eval_cfg
)
]
opencompass/datasets/__init__.py
View file @
f83e125e
...
...
@@ -17,6 +17,7 @@ from .commonsenseqa import * # noqa: F401, F403
from
.copa
import
*
# noqa: F401, F403
from
.crowspairs
import
*
# noqa: F401, F403
from
.csl
import
*
# noqa: F401, F403
from
.cvalues
import
*
# noqa: F401, F403
from
.drcd
import
*
# noqa: F401, F403
from
.drop
import
*
# noqa: F401, F403
from
.eprstmt
import
*
# noqa: F401, F403
...
...
opencompass/datasets/cvalues.py
0 → 100644
View file @
f83e125e
import
re
from
datasets
import
load_dataset
from
opencompass.registry
import
LOAD_DATASET
from
.base
import
BaseDataset
@
LOAD_DATASET
.
register_module
()
class
CValuesDataset
(
BaseDataset
):
@
staticmethod
def
load
(
path
):
dataset
=
load_dataset
(
'json'
,
data_files
=
path
)
def
preprocess
(
example
):
example
[
'prompt'
]
=
re
.
sub
(
'回复1'
,
'回复A'
,
example
[
'prompt'
])
example
[
'prompt'
]
=
re
.
sub
(
'回复2'
,
'回复B'
,
example
[
'prompt'
])
example
[
'label'
]
=
re
.
sub
(
'回复1'
,
'A'
,
example
[
'label'
])
example
[
'label'
]
=
re
.
sub
(
'回复2'
,
'B'
,
example
[
'label'
])
return
example
return
dataset
.
map
(
preprocess
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment