Skip to content

Commit

Permalink
Merge pull request FlagAI-Open#491 from NoahRe1/master
Browse files Browse the repository at this point in the history
Fixed an accuracy calculation error in test_eval_gsm.py
  • Loading branch information
BAAI-OpenPlatform authored Jul 12, 2023
2 parents a9852c0 + c1be5d5 commit 41b8b86
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions examples/Aquila/test/test_eval_gsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def parse_answer_file(answer_file):
accuracy = 0
last_number = 0
should_find_answer = True
should_find_reference_answer = False

for i, l in enumerate(lines):
try:
Expand All @@ -52,14 +53,16 @@ def parse_answer_file(answer_file):
except:
pass

if l.startswith('####'):
if should_find_reference_answer and l.startswith('####'):
reference_answer = l.split('####')[1].strip()
if reference_answer == last_number:
accuracy += 1
elif l.startswith('===== CASE'):
should_find_answer = True
should_find_reference_answer = False
elif l.startswith('Reference Answer'):
should_find_answer = False
should_find_reference_answer = True

print('Accuracy: ', accuracy / len(gsm8k_test['question']) * 100)

Expand Down Expand Up @@ -95,4 +98,4 @@ def main(args):

if __name__ == '__main__':
args = parser.parse_args()
main(args)
main(args)

0 comments on commit 41b8b86

Please sign in to comment.