mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00
[Fix] fix bug for postprocessor (#195)
* [Fix] fix bug for postprocessor * minor fix
This commit is contained in:
parent
10cbc2b175
commit
7c393192af
@ -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
|
||||||
|
@ -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):
|
|||||||
|
|
||||||
# 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:
|
||||||
|
@ -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 = [
|
||||||
|
Loading…
Reference in New Issue
Block a user