-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevaluate_example.py
More file actions
63 lines (47 loc) · 1.57 KB
/
evaluate_example.py
File metadata and controls
63 lines (47 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
评估使用示例
"""
from evaluate import TableQAEvaluator
# 示例1: 使用EM评估(不需要模型)
def example_em_only():
"""仅使用精确匹配评估"""
evaluator = TableQAEvaluator()
metrics = evaluator.evaluate_dataset(
input_file="results/qa_results.json", # 你的输入文件路径
output_dir="judge_res",
use_llm=False # 不使用LLM评估
)
print("评估完成!")
return metrics
# 示例2: 使用EM和LLM评估(使用deepseek-v3)
def example_with_llm_deepseek():
"""使用EM和LLM评估,使用DeepSeek模型"""
evaluator = TableQAEvaluator(
model="deepseek-v3-250324" # 使用DeepSeek V3模型
)
metrics = evaluator.evaluate_dataset(
input_file="results/qa_results.json", # 你的输入文件路径
output_dir="judge_res",
use_llm=True # 使用LLM评估
)
print("评估完成!")
return metrics
# 示例3: 使用其他模型
def example_with_other_model():
"""使用其他模型进行评估"""
evaluator = TableQAEvaluator(
model="gpt-4" # 或其他支持的模型
)
metrics = evaluator.evaluate_dataset(
input_file="results/qa_results.json",
output_dir="judge_res",
use_llm=True
)
return metrics
if __name__ == "__main__":
# 运行仅EM评估的示例
print("运行EM评估示例...")
example_em_only()
# 如果需要LLM评估,取消下面的注释
# print("\n运行LLM评估示例(DeepSeek)...")
# example_with_llm_deepseek()