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
7c393192
Unverified
Commit
7c393192
authored
Aug 11, 2023
by
Hubert
Committed by
GitHub
Aug 11, 2023
Browse files
[Fix] fix bug for postprocessor (#195)
* [Fix] fix bug for postprocessor * minor fix
parent
10cbc2b1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
9 deletions
+7
-9
configs/datasets/collections/chat_medium.py
configs/datasets/collections/chat_medium.py
+1
-1
opencompass/tasks/openicl_eval.py
opencompass/tasks/openicl_eval.py
+5
-7
opencompass/utils/text_postprocessors.py
opencompass/utils/text_postprocessors.py
+1
-1
No files found.
configs/datasets/collections/chat_medium.py
View file @
7c393192
...
@@ -52,7 +52,7 @@ with read_base():
...
@@ -52,7 +52,7 @@ with read_base():
from
..nq.nq_gen_c788f6
import
nq_datasets
from
..nq.nq_gen_c788f6
import
nq_datasets
from
..triviaqa.triviaqa_gen_2121ce
import
triviaqa_datasets
from
..triviaqa.triviaqa_gen_2121ce
import
triviaqa_datasets
from
..flores.flores_gen_806ede
import
flores_datasets
from
..flores.flores_gen_806ede
import
flores_datasets
from
..crowspairs.crowspairs_gen_
21f7cb
import
crowspairs_datasets
from
..crowspairs.crowspairs_gen_
381af0
import
crowspairs_datasets
from
..civilcomments.civilcomments_clp_a3c5fd
import
civilcomments_datasets
from
..civilcomments.civilcomments_clp_a3c5fd
import
civilcomments_datasets
from
..jigsawmultilingual.jigsawmultilingual_clp_fe50d8
import
jigsawmultilingual_datasets
from
..jigsawmultilingual.jigsawmultilingual_clp_fe50d8
import
jigsawmultilingual_datasets
from
..realtoxicprompts.realtoxicprompts_gen_7605e4
import
realtoxicprompts_datasets
from
..realtoxicprompts.realtoxicprompts_gen_7605e4
import
realtoxicprompts_datasets
...
...
opencompass/tasks/openicl_eval.py
View file @
7c393192
...
@@ -58,13 +58,11 @@ class OpenICLEvalTask(BaseTask):
...
@@ -58,13 +58,11 @@ class OpenICLEvalTask(BaseTask):
test_set
=
build_dataset_from_cfg
(
self
.
dataset_cfg
).
test
test_set
=
build_dataset_from_cfg
(
self
.
dataset_cfg
).
test
# Postprocess dataset if necessary
# Postprocess dataset if necessary
if
'dataset_postprocessor'
in
self
.
eval_cfg
:
if
'dataset_postprocessor'
in
self
.
eval_cfg
:
TEXT_POSTPROCESSORS
.
get
(
proc
=
TEXT_POSTPROCESSORS
.
get
(
self
.
eval_cfg
[
'dataset_postprocessor'
][
'type'
])
self
.
eval_cfg
[
'dataset_postprocessor'
][
'type'
])
def
postprocess
(
sample
):
def
postprocess
(
sample
):
s
=
sample
[
self
.
output_column
]
s
=
sample
[
self
.
output_column
]
proc
=
TEXT_POSTPROCESSORS
.
get
(
self
.
eval_cfg
[
'dataset_postprocessor'
][
'type'
])
sample
[
self
.
output_column
]
=
proc
(
s
)
sample
[
self
.
output_column
]
=
proc
(
s
)
return
sample
return
sample
...
@@ -130,13 +128,13 @@ class OpenICLEvalTask(BaseTask):
...
@@ -130,13 +128,13 @@ class OpenICLEvalTask(BaseTask):
# Postprocess predictions if necessary
# Postprocess predictions if necessary
if
'pred_postprocessor'
in
self
.
eval_cfg
:
if
'pred_postprocessor'
in
self
.
eval_cfg
:
proc
=
TEXT_POSTPROCESSORS
.
get
(
kwargs
=
self
.
eval_cfg
[
'pred_postprocessor'
]
self
.
eval_cfg
[
'pred_postprocessor'
][
'type'
]
)
proc
=
TEXT_POSTPROCESSORS
.
get
(
kwargs
.
pop
(
'type'
)
)
if
sc_size
is
not
None
:
if
sc_size
is
not
None
:
pred_strs
=
[[
proc
(
s
)
for
s
in
preds
]
pred_strs
=
[[
proc
(
s
,
**
kwargs
)
for
s
in
preds
]
for
preds
in
pred_strs
]
for
preds
in
pred_strs
]
else
:
else
:
pred_strs
=
[
proc
(
s
)
for
s
in
pred_strs
]
pred_strs
=
[
proc
(
s
,
**
kwargs
)
for
s
in
pred_strs
]
# Get majority voting predictions if use self-consistency
# Get majority voting predictions if use self-consistency
if
sc_size
is
not
None
:
if
sc_size
is
not
None
:
...
...
opencompass/utils/text_postprocessors.py
View file @
7c393192
...
@@ -48,7 +48,7 @@ def first_capital_postprocess(text: str) -> str:
...
@@ -48,7 +48,7 @@ def first_capital_postprocess(text: str) -> str:
return
''
return
''
def
first_option_postprocess
(
text
:
str
,
options
)
->
str
:
def
first_option_postprocess
(
text
:
str
,
options
:
str
)
->
str
:
"""Find first valid option for text."""
"""Find first valid option for text."""
patterns
=
[
patterns
=
[
...
...
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