mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-06 11:32:10 +00:00
fix ColossalEval (#4992)
Co-authored-by: Xu Yuanchen <yuanchen.xu00@gmail.com>
This commit is contained in:
@@ -443,6 +443,20 @@ def multi_choice_accuracy(prediction, reference, **kwargs):
|
||||
return score
|
||||
|
||||
|
||||
def accuracy_by_options(question, prediction, reference):
|
||||
pattern = r"[A-Z]\. [^\n]+"
|
||||
options = re.findall(pattern, question)
|
||||
answer = prediction.split("\n\n")[0]
|
||||
|
||||
for option in options:
|
||||
choice, content = option.split(". ", 1)
|
||||
|
||||
if choice == reference and content == answer:
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def combined_single_choice_accuracy(prediction, reference, **kwargs):
|
||||
return single_choice_accuracy(prediction, reference, **kwargs)
|
||||
|
||||
|
Reference in New Issue
Block a user