-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2dbe154
commit 9659063
Showing
3 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#Copyright (2024) Bytedance Ltd. | ||
import os | ||
import argparse | ||
import json | ||
import numpy as np | ||
def evaluate_exact_match_accuracy(entries): | ||
scores = [] | ||
for elem in entries: | ||
if isinstance(elem['annotation'], str): | ||
elem['annotation'] = [elem['annotation']] | ||
score = max([ | ||
(1.0 if | ||
(ann.strip().lower() in elem['answer'].strip().lower().replace(".","") ) else 0.0) | ||
for ann in elem['annotation'] | ||
]) | ||
scores.append(score) | ||
return sum(scores) / len(scores) | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--model_result_path", default='evaluation/sample_result') | ||
args = parser.parse_args() | ||
acc_items = [] | ||
for line in os.listdir(args.model_result_path): | ||
items = json.load(open(os.path.join(args.model_result_path,line))) | ||
lang_acc = evaluate_exact_match_accuracy(items) | ||
acc_items.append(lang_acc) | ||
print(line.strip('.json'), 'acc:', lang_acc) | ||
print('Average acc:', np.mean(acc_items)) |