File size: 817 Bytes
8a11f7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import pandas as pd
import argparse
import os

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Analyze the evaluation results.")
    parser.add_argument("--result_file_path", type=str, required=True, help="Path to the result file (.jsonl).")
    parser.add_argument("--answer_key", type=str, required=True, help="The key for the model's response in the result file.")
    
    args = parser.parse_args()

    data = pd.read_json(args.result_file_path, lines=True)

    acc = (data['answer'].str.upper() == data[args.answer_key].str.upper()).mean()
    print(f"Accuracy for {args.answer_key} is: {acc:.2%}")

    with open(f"{os.path.dirname(args.result_file_path)}/{args.answer_key}.log", "w", encoding='utf-8') as fout:
        fout.write(f"Accuracy for {args.answer_key} is: {acc:.2%}")