Skip to content

Commit

Permalink
Update kaoshi
Browse files Browse the repository at this point in the history
  • Loading branch information
liushz committed Sep 13, 2023
1 parent 757b24e commit 324287e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion configs/datasets/Kaoshi/Kaoshi_gen_6666.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'判断题': ['职业-证券'],
'填空题': ['考研-数学']}

zh2en = {'单选题': 'single_choice', '多选题': 'multiple_choice', '完形填空': 'multi_question_choice', '判断题': 'judgment', '填空题': 'cloze', '七选五': 'five_out_of_seven'}
zh2en = {'单选题': 'single_choice', '多选题': 'multi_choice', '完形填空': 'multi_question_choice', '判断题': 'judgment', '填空题': 'cloze', '七选五': 'five_out_of_seven'}

Kaoshi_datasets = []

Expand Down
12 changes: 6 additions & 6 deletions opencompass/datasets/Kaoshi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
def get_number(options):

result_string = ''
for i, percentage in enumerate(options,
start=65):
for i, percentage in enumerate(options, start=65):
result_string += f'{chr(i)}. {percentage}\n'
return result_string

Expand All @@ -34,6 +33,7 @@ def load(path: str, name: str):
data_list.append(data)
return Dataset.from_list(data_list)


valid_kaoshi_question_types = [
'single_choice', 'multi_choice', 'multi_question_choice',
'five_out_of_seven', 'cloze', 'judgment'
Expand Down Expand Up @@ -91,7 +91,7 @@ def do_predictions_postprocess(self, model_output, answer_lenth=None):
if len(temp) > 0:
for k in range(min(5, len(temp))):
model_answer.append(temp[k])

elif self.question_type in ['cloze', 'judgment']:
model_answer = []
temp = re.findall(r'【答案】(.*?) ', model_output)
Expand All @@ -107,7 +107,7 @@ def ensure_same_length(self, pred, refr):

def score(self, predictions, references):
if self.question_type not in valid_kaoshi_question_types:
return {'score': 0}
return {'score': 100}
elif self.question_type == 'multi_choice':
correct_score, total_score = 0, 0
for pred, refr in zip(predictions, references):
Expand Down Expand Up @@ -145,8 +145,8 @@ def score(self, predictions, references):
# fix classic closure problem
def _kaoshi_register(question_type):
ICL_EVALUATORS.register_module(
name='KaoshiEvaluator' + "_" + question_type,
name='KaoshiEvaluator' + '_' + question_type,
module=lambda *args, **kwargs: KaoshiEvaluator(
question_type=question_type, *args, **kwargs))

_kaoshi_register(question_type)
_kaoshi_register(question_type)

0 comments on commit 324287e

Please sign in to comment.