happyme531
commited on
Commit
•
1e012a3
1
Parent(s):
76ead7a
Upload 5 files
Browse files- README.md +188 -3
- compare_results.py +251 -0
- evaluate_poetry.py +349 -0
- generate_report.py +195 -0
- poetry_benchmark.jsonl +70 -0
README.md
CHANGED
@@ -1,3 +1,188 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## English Readme see below
|
2 |
+
(README由Claude 3.5 Sonnet生成)
|
3 |
+
|
4 |
+
# 中国古诗词大模型评测基准
|
5 |
+
|
6 |
+
### 简介
|
7 |
+
这是一个专门用于评测大语言模型在中国古诗词理解和生成方面能力的基准测试集。该基准包含了一个多样化的测试数据集和完整的评测框架,可用于系统性地评估和比较不同模型在古诗词领域的表现。
|
8 |
+
|
9 |
+
### 数据集说明
|
10 |
+
数据集(`poetry_benchmark.jsonl`)包含70个测试样本,涵盖以下维度:
|
11 |
+
|
12 |
+
- **题型分布**:
|
13 |
+
- 对联补全
|
14 |
+
- 诗句填空
|
15 |
+
- 诗词识别
|
16 |
+
- 提示词补全
|
17 |
+
- 首尾互补
|
18 |
+
|
19 |
+
- **难度等级**:
|
20 |
+
- 简单(easy)
|
21 |
+
- 中等(medium)
|
22 |
+
- 困难(hard)
|
23 |
+
|
24 |
+
- **朝代覆盖**:
|
25 |
+
- 先秦至近现代
|
26 |
+
- 包括唐、宋、元、明、清等重要朝代
|
27 |
+
|
28 |
+
### 评测维度
|
29 |
+
评测框架从以下维度对模型进行全面评估:
|
30 |
+
|
31 |
+
1. 整体准确率
|
32 |
+
2. 不同题型的表现
|
33 |
+
3. 不同难度等级的表现
|
34 |
+
4. 不同朝代诗词的掌握程度
|
35 |
+
|
36 |
+
|
37 |
+
### 评测结果
|
38 |
+
|
39 |
+
| 模型 | blank_filling | couplet | find_poetry | first_last_words | hint_words | 总计 | 总正确率 |
|
40 |
+
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|
41 |
+
| deepseek-chat | 7/15 | 9/20 | 0/15 | 7/10 | 0/10 | 23/70 | 32.86% |
|
42 |
+
| yi-lightning | 6/15 | 10/20 | 0/15 | 4/10 | 2/10 | 22/70 | 31.43% |
|
43 |
+
| qwen2.5-72b | 6/15 | 7/20 | 0/15 | 4/10 | 0/10 | 17/70 | 24.29% |
|
44 |
+
| gpt-4o-2024-08-06 | 5/15 | 6/20 | 0/15 | 4/10 | 1/10 | 16/70 | 22.86% |
|
45 |
+
| gemini-1.5-flash | 0/15 | 4/20 | 0/15 | 2/10 | 0/10 | 6/70 | 8.57% |
|
46 |
+
|
47 |
+
### 项目结构
|
48 |
+
```
|
49 |
+
.
|
50 |
+
├── poetry_benchmark.jsonl # 测试数据集
|
51 |
+
├── compare_results.py # 结果对比和可视化脚本
|
52 |
+
└── evaluation_results/ # 评测结果目录
|
53 |
+
├── evaluation_report.json # 评测报告
|
54 |
+
└── detailed_results.jsonl # 详细结果
|
55 |
+
```
|
56 |
+
|
57 |
+
### 使用方法
|
58 |
+
|
59 |
+
1. 运行评测:
|
60 |
+
```bash
|
61 |
+
python evaluate_poetry.py --model <model_name> --output_dir evaluation_results
|
62 |
+
```
|
63 |
+
|
64 |
+
2. 对比分析:
|
65 |
+
```bash
|
66 |
+
python compare_results.py
|
67 |
+
```
|
68 |
+
|
69 |
+
3. 查看结果:
|
70 |
+
评测脚本会生成以下可视化结果:
|
71 |
+
- accuracy_comparison.html: 整体准确率对比
|
72 |
+
- accuracy_by_type.html: 不同题型准确率对比
|
73 |
+
- accuracy_by_difficulty.html: 不同难度准确率对比
|
74 |
+
- accuracy_by_dynasty.html: 不同朝代准确率对比
|
75 |
+
- radar_comparison.html: 多维度能力雷达图
|
76 |
+
|
77 |
+
### 输出格式
|
78 |
+
评测报告(evaluation_report.json)包含以下内容:
|
79 |
+
```json
|
80 |
+
{
|
81 |
+
"overall": {
|
82 |
+
"total": 70,
|
83 |
+
"correct": 45,
|
84 |
+
"accuracy": 0.643
|
85 |
+
},
|
86 |
+
"by_type": {
|
87 |
+
"couplet": {...},
|
88 |
+
"blank_filling": {...},
|
89 |
+
...
|
90 |
+
},
|
91 |
+
"by_difficulty": {...},
|
92 |
+
"by_dynasty": {...}
|
93 |
+
}
|
94 |
+
```
|
95 |
+
|
96 |
+
--------
|
97 |
+
|
98 |
+
(README generated by Claude 3.5 Sonnet)
|
99 |
+
# Classical Chinese Poetry Benchmark for LLMs
|
100 |
+
|
101 |
+
### Introduction
|
102 |
+
This is a benchmark designed to evaluate large language models' capabilities in understanding and generating Classical Chinese poetry. It includes a diverse test dataset and a comprehensive evaluation framework for systematically assessing and comparing different models' performance in the domain of Classical Chinese poetry.
|
103 |
+
|
104 |
+
### Dataset Description
|
105 |
+
The dataset (`poetry_benchmark.jsonl`) contains 70 test samples covering the following dimensions:
|
106 |
+
|
107 |
+
- **Question Types**:
|
108 |
+
- Couplet completion
|
109 |
+
- Poetry line filling
|
110 |
+
- Poetry identification
|
111 |
+
- Hint-based completion
|
112 |
+
- First-last word completion
|
113 |
+
|
114 |
+
- **Difficulty Levels**:
|
115 |
+
- Easy
|
116 |
+
- Medium
|
117 |
+
- Hard
|
118 |
+
|
119 |
+
- **Dynasty Coverage**:
|
120 |
+
- From Pre-Qin to Modern Era
|
121 |
+
- Including Tang, Song, Yuan, Ming, Qing dynasties
|
122 |
+
|
123 |
+
### Evaluation Dimensions
|
124 |
+
The framework evaluates models comprehensively across:
|
125 |
+
|
126 |
+
1. Overall accuracy
|
127 |
+
2. Performance by question type
|
128 |
+
3. Performance by difficulty level
|
129 |
+
4. Mastery of poetry from different dynasties
|
130 |
+
|
131 |
+
### Evaluation Results
|
132 |
+
|
133 |
+
| Model | blank_filling | couplet | find_poetry | first_last_words | hint_words | Total | Total Accuracy |
|
134 |
+
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|
135 |
+
| deepseek-chat | 7/15 | 9/20 | 0/15 | 7/10 | 0/10 | 23/70 | 32.86% |
|
136 |
+
| yi-lightning | 6/15 | 10/20 | 0/15 | 4/10 | 2/10 | 22/70 | 31.43% |
|
137 |
+
| qwen2.5-72b | 6/15 | 7/20 | 0/15 | 4/10 | 0/10 | 17/70 | 24.29% |
|
138 |
+
| gpt-4o-2024-08-06 | 5/15 | 6/20 | 0/15 | 4/10 | 1/10 | 16/70 | 22.86% |
|
139 |
+
| gemini-1.5-flash | 0/15 | 4/20 | 0/15 | 2/10 | 0/10 | 6/70 | 8.57% |
|
140 |
+
|
141 |
+
### Project Structure
|
142 |
+
```
|
143 |
+
.
|
144 |
+
├── poetry_benchmark.jsonl # Test dataset
|
145 |
+
├── compare_results.py # Comparison and visualization script
|
146 |
+
└── evaluation_results.<model_name>/ # Evaluation results directory
|
147 |
+
├── evaluation_report.json # Evaluation report
|
148 |
+
└── detailed_results.jsonl # Detailed results
|
149 |
+
```
|
150 |
+
|
151 |
+
### Usage
|
152 |
+
|
153 |
+
1. Run evaluation:
|
154 |
+
```bash
|
155 |
+
python evaluate_poetry.py --model <model_name> --output_dir evaluation_results.<model_name>
|
156 |
+
```
|
157 |
+
|
158 |
+
2. Compare results:
|
159 |
+
```bash
|
160 |
+
python compare_results.py
|
161 |
+
```
|
162 |
+
|
163 |
+
3. View results:
|
164 |
+
The script generates the following visualizations:
|
165 |
+
- accuracy_comparison.html: Overall accuracy comparison
|
166 |
+
- accuracy_by_type.html: Accuracy comparison by question type
|
167 |
+
- accuracy_by_difficulty.html: Accuracy comparison by difficulty
|
168 |
+
- accuracy_by_dynasty.html: Accuracy comparison by dynasty
|
169 |
+
- radar_comparison.html: Multi-dimensional capability radar chart
|
170 |
+
|
171 |
+
### Output Format
|
172 |
+
The evaluation report (evaluation_report.json) contains:
|
173 |
+
```json
|
174 |
+
{
|
175 |
+
"overall": {
|
176 |
+
"total": 70,
|
177 |
+
"correct": 45,
|
178 |
+
"accuracy": 0.643
|
179 |
+
},
|
180 |
+
"by_type": {
|
181 |
+
"couplet": {...},
|
182 |
+
"blank_filling": {...},
|
183 |
+
...
|
184 |
+
},
|
185 |
+
"by_difficulty": {...},
|
186 |
+
"by_dynasty": {...}
|
187 |
+
}
|
188 |
+
```
|
compare_results.py
ADDED
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import pandas as pd
|
4 |
+
import plotly.graph_objects as go
|
5 |
+
from typing import Dict, List
|
6 |
+
|
7 |
+
def get_model_names() -> List[str]:
|
8 |
+
"""从evaluation_results文件夹获取所有模型名称"""
|
9 |
+
model_names = []
|
10 |
+
for item in os.listdir('.'):
|
11 |
+
if item.startswith('evaluation_results.') and os.path.isdir(item):
|
12 |
+
model_name = item.replace('evaluation_results.', '')
|
13 |
+
model_names.append(model_name)
|
14 |
+
return sorted(model_names) # 排序以保持顺序一致
|
15 |
+
|
16 |
+
def load_report(model_name: str) -> Dict:
|
17 |
+
"""加载模型的评测报告"""
|
18 |
+
report_path = f"evaluation_results.{model_name}/evaluation_report.json"
|
19 |
+
with open(report_path, 'r', encoding='utf-8') as f:
|
20 |
+
return json.load(f)
|
21 |
+
|
22 |
+
def create_comparison_tables() -> Dict[str, pd.DataFrame]:
|
23 |
+
"""创建不同维度的对比表格"""
|
24 |
+
# 动态获取所有模型名称
|
25 |
+
models = get_model_names()
|
26 |
+
|
27 |
+
# 加载所有报告
|
28 |
+
reports = {model: load_report(model) for model in models}
|
29 |
+
|
30 |
+
# 1. 整体表现
|
31 |
+
overall_data = []
|
32 |
+
for model, report in reports.items():
|
33 |
+
overall = report['overall']
|
34 |
+
overall_data.append({
|
35 |
+
'模型': model,
|
36 |
+
'总题数': overall['total'],
|
37 |
+
'正确数': overall['correct'],
|
38 |
+
'准确率': f"{overall['accuracy']*100:.2f}%"
|
39 |
+
})
|
40 |
+
overall_df = pd.DataFrame(overall_data)
|
41 |
+
|
42 |
+
# 2. 按题型分类
|
43 |
+
type_data = []
|
44 |
+
for model, report in reports.items():
|
45 |
+
for q_type, metrics in report['by_type'].items():
|
46 |
+
type_data.append({
|
47 |
+
'模型': model,
|
48 |
+
'题型': q_type,
|
49 |
+
'总题数': metrics['total'],
|
50 |
+
'正确数': metrics['correct'],
|
51 |
+
'准确率': f"{metrics['accuracy']*100:.2f}%"
|
52 |
+
})
|
53 |
+
type_df = pd.DataFrame(type_data)
|
54 |
+
|
55 |
+
# 3. 按难度分类
|
56 |
+
difficulty_data = []
|
57 |
+
difficulty_order = ['easy', 'medium', 'hard'] # 预定义难度顺序
|
58 |
+
for model, report in reports.items():
|
59 |
+
for diff in difficulty_order:
|
60 |
+
if diff in report['by_difficulty']:
|
61 |
+
metrics = report['by_difficulty'][diff]
|
62 |
+
difficulty_data.append({
|
63 |
+
'模型': model,
|
64 |
+
'难度': diff,
|
65 |
+
'总题数': metrics['total'],
|
66 |
+
'正确数': metrics['correct'],
|
67 |
+
'准确率': f"{metrics['accuracy']*100:.2f}%"
|
68 |
+
})
|
69 |
+
difficulty_df = pd.DataFrame(difficulty_data)
|
70 |
+
|
71 |
+
# 4. 按朝代分类
|
72 |
+
dynasty_data = []
|
73 |
+
for model, report in reports.items():
|
74 |
+
for dynasty, metrics in report['by_dynasty'].items():
|
75 |
+
dynasty_data.append({
|
76 |
+
'模型': model,
|
77 |
+
'朝代': dynasty if dynasty else "未知",
|
78 |
+
'总题数': metrics['total'],
|
79 |
+
'正确数': metrics['correct'],
|
80 |
+
'准确率': f"{metrics['accuracy']*100:.2f}%"
|
81 |
+
})
|
82 |
+
dynasty_df = pd.DataFrame(dynasty_data)
|
83 |
+
|
84 |
+
return {
|
85 |
+
'overall': overall_df,
|
86 |
+
'by_type': type_df,
|
87 |
+
'by_difficulty': difficulty_df,
|
88 |
+
'by_dynasty': dynasty_df
|
89 |
+
}
|
90 |
+
|
91 |
+
def plot_accuracy_comparison(dfs: Dict[str, pd.DataFrame]):
|
92 |
+
"""绘制准确率对比图"""
|
93 |
+
# 1. 整体准确率对比
|
94 |
+
fig = go.Figure(data=[
|
95 |
+
go.Bar(
|
96 |
+
name='整体准确率',
|
97 |
+
x=dfs['overall']['模型'],
|
98 |
+
y=[float(x.strip('%')) for x in dfs['overall']['准确率']],
|
99 |
+
text=dfs['overall']['准确率'],
|
100 |
+
textposition='auto',
|
101 |
+
)
|
102 |
+
])
|
103 |
+
fig.update_layout(
|
104 |
+
title='各模型整体准确率对比',
|
105 |
+
yaxis_title='准确率 (%)',
|
106 |
+
yaxis_range=[0, 100],
|
107 |
+
template='plotly_white'
|
108 |
+
)
|
109 |
+
fig.write_html('accuracy_comparison.html')
|
110 |
+
|
111 |
+
# 2. 按题型的准确率对比
|
112 |
+
type_pivot = pd.pivot_table(
|
113 |
+
dfs['by_type'],
|
114 |
+
values='准确率',
|
115 |
+
index='题型',
|
116 |
+
columns='模型',
|
117 |
+
aggfunc=lambda x: x
|
118 |
+
)
|
119 |
+
fig = go.Figure(data=[
|
120 |
+
go.Bar(
|
121 |
+
name=model,
|
122 |
+
x=type_pivot.index,
|
123 |
+
y=[float(x.strip('%')) for x in type_pivot[model]],
|
124 |
+
text=type_pivot[model],
|
125 |
+
textposition='auto',
|
126 |
+
) for model in type_pivot.columns
|
127 |
+
])
|
128 |
+
fig.update_layout(
|
129 |
+
title='各模型在不同题型上的准确率对比',
|
130 |
+
yaxis_title='准确率 (%)',
|
131 |
+
yaxis_range=[0, 100],
|
132 |
+
barmode='group',
|
133 |
+
template='plotly_white',
|
134 |
+
height=600 # 增加图表高度
|
135 |
+
)
|
136 |
+
fig.write_html('accuracy_by_type.html')
|
137 |
+
|
138 |
+
# 3. 按难度的准确率对比
|
139 |
+
difficulty_pivot = pd.pivot_table(
|
140 |
+
dfs['by_difficulty'],
|
141 |
+
values='准确率',
|
142 |
+
index='难度',
|
143 |
+
columns='模型',
|
144 |
+
aggfunc=lambda x: x
|
145 |
+
)
|
146 |
+
# 确保难度顺序正确
|
147 |
+
difficulty_order = ['easy', 'medium', 'hard']
|
148 |
+
difficulty_pivot = difficulty_pivot.reindex(difficulty_order)
|
149 |
+
|
150 |
+
fig = go.Figure(data=[
|
151 |
+
go.Bar(
|
152 |
+
name=model,
|
153 |
+
x=difficulty_pivot.index,
|
154 |
+
y=[float(x.strip('%')) for x in difficulty_pivot[model]],
|
155 |
+
text=difficulty_pivot[model],
|
156 |
+
textposition='auto',
|
157 |
+
) for model in difficulty_pivot.columns
|
158 |
+
])
|
159 |
+
fig.update_layout(
|
160 |
+
title='各模型在不同难度上的准确率对比',
|
161 |
+
yaxis_title='准确率 (%)',
|
162 |
+
yaxis_range=[0, 100],
|
163 |
+
barmode='group',
|
164 |
+
template='plotly_white'
|
165 |
+
)
|
166 |
+
fig.write_html('accuracy_by_difficulty.html')
|
167 |
+
|
168 |
+
# 4. 按朝代的准确率对比
|
169 |
+
dynasty_pivot = pd.pivot_table(
|
170 |
+
dfs['by_dynasty'],
|
171 |
+
values='准确率',
|
172 |
+
index='朝代',
|
173 |
+
columns='模型',
|
174 |
+
aggfunc=lambda x: x
|
175 |
+
)
|
176 |
+
fig = go.Figure(data=[
|
177 |
+
go.Bar(
|
178 |
+
name=model,
|
179 |
+
x=dynasty_pivot.index,
|
180 |
+
y=[float(x.strip('%')) for x in dynasty_pivot[model]],
|
181 |
+
text=dynasty_pivot[model],
|
182 |
+
textposition='auto',
|
183 |
+
) for model in dynasty_pivot.columns
|
184 |
+
])
|
185 |
+
fig.update_layout(
|
186 |
+
title='各模型在不同朝代诗词上的准确率对比',
|
187 |
+
yaxis_title='准确率 (%)',
|
188 |
+
yaxis_range=[0, 100],
|
189 |
+
barmode='group',
|
190 |
+
template='plotly_white',
|
191 |
+
height=800 # 增加图表高度以适应更多朝代
|
192 |
+
)
|
193 |
+
fig.write_html('accuracy_by_dynasty.html')
|
194 |
+
|
195 |
+
# 5. 雷达图对比
|
196 |
+
categories = ['整体'] + list(type_pivot.index)
|
197 |
+
fig = go.Figure()
|
198 |
+
|
199 |
+
for model in dfs['overall']['模型']:
|
200 |
+
values = [float(dfs['overall'][dfs['overall']['模型']==model]['准确率'].iloc[0].strip('%'))]
|
201 |
+
for q_type in type_pivot.index:
|
202 |
+
values.append(float(type_pivot[model][q_type].strip('%')))
|
203 |
+
|
204 |
+
fig.add_trace(go.Scatterpolar(
|
205 |
+
r=values,
|
206 |
+
theta=categories,
|
207 |
+
name=model,
|
208 |
+
fill='toself'
|
209 |
+
))
|
210 |
+
|
211 |
+
fig.update_layout(
|
212 |
+
polar=dict(
|
213 |
+
radialaxis=dict(
|
214 |
+
visible=True,
|
215 |
+
range=[0, 100]
|
216 |
+
)),
|
217 |
+
showlegend=True,
|
218 |
+
title='各模型在不同维度的表现对比(雷达图)',
|
219 |
+
template='plotly_white'
|
220 |
+
)
|
221 |
+
fig.write_html('radar_comparison.html')
|
222 |
+
|
223 |
+
def main():
|
224 |
+
# 创建对比表格
|
225 |
+
dfs = create_comparison_tables()
|
226 |
+
|
227 |
+
# 保存为Excel文件
|
228 |
+
with pd.ExcelWriter('model_comparison.xlsx') as writer:
|
229 |
+
dfs['overall'].to_excel(writer, sheet_name='整体表现', index=False)
|
230 |
+
dfs['by_type'].to_excel(writer, sheet_name='按题型分类', index=False)
|
231 |
+
dfs['by_difficulty'].to_excel(writer, sheet_name='按难度分类', index=False)
|
232 |
+
dfs['by_dynasty'].to_excel(writer, sheet_name='按朝代分类', index=False)
|
233 |
+
|
234 |
+
# 打印表格
|
235 |
+
print("\n整体表现:")
|
236 |
+
print(dfs['overall'].to_string(index=False))
|
237 |
+
|
238 |
+
print("\n按题型分类:")
|
239 |
+
print(dfs['by_type'].to_string(index=False))
|
240 |
+
|
241 |
+
print("\n按难度分类:")
|
242 |
+
print(dfs['by_difficulty'].to_string(index=False))
|
243 |
+
|
244 |
+
print("\n按朝代分类:")
|
245 |
+
print(dfs['by_dynasty'].to_string(index=False))
|
246 |
+
|
247 |
+
# 绘制对比图
|
248 |
+
plot_accuracy_comparison(dfs)
|
249 |
+
|
250 |
+
if __name__ == '__main__':
|
251 |
+
main()
|
evaluate_poetry.py
ADDED
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import openai
|
3 |
+
import google.generativeai as genai
|
4 |
+
import time
|
5 |
+
from collections import defaultdict
|
6 |
+
from typing import Dict, List
|
7 |
+
import os
|
8 |
+
from tqdm import tqdm
|
9 |
+
import argparse
|
10 |
+
|
11 |
+
class PoetryEvaluator:
|
12 |
+
def __init__(self, api_key: str, provider: str = "openai", model: str = "gpt-3.5-turbo",
|
13 |
+
dry_run: bool = False, delay: float = 0.5, max_retries: int = 3, retry_delay: float = 1.0):
|
14 |
+
"""初始化评测器
|
15 |
+
Args:
|
16 |
+
api_key: API密钥
|
17 |
+
provider: API提供商 ("openai" 或 "google")
|
18 |
+
model: 模型名称
|
19 |
+
dry_run: 是否为演示模式
|
20 |
+
delay: API调用间隔时间(秒)
|
21 |
+
max_retries: 最大重试次数
|
22 |
+
retry_delay: 重试等待时间(秒)
|
23 |
+
"""
|
24 |
+
self.api_key = api_key
|
25 |
+
self.provider = provider
|
26 |
+
self.model = model
|
27 |
+
self.dry_run = dry_run
|
28 |
+
self.delay = delay
|
29 |
+
self.max_retries = max_retries
|
30 |
+
self.retry_delay = retry_delay
|
31 |
+
self.results = defaultdict(list)
|
32 |
+
|
33 |
+
# 根据provider初始化API
|
34 |
+
if provider == "google":
|
35 |
+
genai.configure(api_key=api_key)
|
36 |
+
self.generation_config = {
|
37 |
+
"temperature": 0,
|
38 |
+
"top_p": 0.95,
|
39 |
+
"top_k": 64,
|
40 |
+
"max_output_tokens": 8192,
|
41 |
+
}
|
42 |
+
self.google_model = genai.GenerativeModel(
|
43 |
+
model_name=model,
|
44 |
+
generation_config=self.generation_config
|
45 |
+
)
|
46 |
+
|
47 |
+
def load_benchmark(self, jsonl_path: str) -> List[Dict]:
|
48 |
+
"""加载评测数据集"""
|
49 |
+
questions = []
|
50 |
+
with open(jsonl_path, 'r', encoding='utf-8') as f:
|
51 |
+
for line in f:
|
52 |
+
if line.strip():
|
53 |
+
questions.append(json.loads(line))
|
54 |
+
return questions
|
55 |
+
|
56 |
+
def generate_prompt(self, question: Dict) -> str:
|
57 |
+
"""根据题型生成提示词"""
|
58 |
+
q_type = question['type']
|
59 |
+
author = question['metadata']['author']
|
60 |
+
content = question['content']['question']
|
61 |
+
|
62 |
+
prompts = {
|
63 |
+
'couplet': "请将下面的诗句补充完整。只需要回答括号()之内的内容,不需要进行解释。\n\n",
|
64 |
+
'hint_words': "请将以下包含星号的诗句补充完整。回答补充后的完整诗句,不需要进行解释。\n\n",
|
65 |
+
'find_poetry': "请从以下给出的多行诗句中,从每一行提取出一个字,组成一句有效的诗句。只需要回答找到的诗句,不需要进行解释。\n\n",
|
66 |
+
'blank_filling': "请将下面的诗句补充完整。只需要回答括号()之内的内容,不需要进行解释。\n\n",
|
67 |
+
'first_last_words': "请将以下包含星号的诗句补充完整。回答补充后的完整诗句,不需要进行解释。\n\n"
|
68 |
+
}
|
69 |
+
if author != None:
|
70 |
+
return prompts[q_type] + f"{author}: {content}"
|
71 |
+
else:
|
72 |
+
return prompts[q_type] + content
|
73 |
+
|
74 |
+
def normalize_answer(self, answer: str) -> str:
|
75 |
+
"""标准化答案格式"""
|
76 |
+
return answer.strip().replace('。', '').replace(',', '')
|
77 |
+
|
78 |
+
def evaluate_answer(self, prediction: str, ground_truth: str) -> bool:
|
79 |
+
"""评估答案是否正确
|
80 |
+
只要模型输出中包含正确答案就算对
|
81 |
+
"""
|
82 |
+
pred = self.normalize_answer(prediction)
|
83 |
+
truth = self.normalize_answer(ground_truth)
|
84 |
+
|
85 |
+
# 如果答案中包含多个可能的正确答案(用/分隔)
|
86 |
+
if '/' in truth:
|
87 |
+
possible_answers = [ans.strip() for ans in truth.split('/')]
|
88 |
+
return any(ans in pred for ans in possible_answers)
|
89 |
+
|
90 |
+
# 否则检查输出中是否包含正确答案
|
91 |
+
return truth in pred
|
92 |
+
|
93 |
+
def call_api_with_retry(self, prompt: str) -> str:
|
94 |
+
"""带重试机制的API调用
|
95 |
+
Args:
|
96 |
+
prompt: 提示词
|
97 |
+
Returns:
|
98 |
+
模型回复文本
|
99 |
+
"""
|
100 |
+
retries = 0
|
101 |
+
while True:
|
102 |
+
try:
|
103 |
+
if self.provider == "openai":
|
104 |
+
client = openai.OpenAI(
|
105 |
+
api_key=self.api_key,
|
106 |
+
base_url=openai.api_base
|
107 |
+
)
|
108 |
+
|
109 |
+
response = client.chat.completions.create(
|
110 |
+
model=self.model,
|
111 |
+
messages=[
|
112 |
+
{"role": "system", "content": "你是一个古诗词专家。"},
|
113 |
+
{"role": "user", "content": prompt}
|
114 |
+
],
|
115 |
+
temperature=0
|
116 |
+
)
|
117 |
+
return response.choices[0].message.content
|
118 |
+
|
119 |
+
elif self.provider == "google":
|
120 |
+
chat = self.google_model.start_chat(
|
121 |
+
history=[
|
122 |
+
{"role": "user", "parts": ["你是一个古诗词专家。"]}
|
123 |
+
]
|
124 |
+
)
|
125 |
+
response = chat.send_message(prompt)
|
126 |
+
return response.text
|
127 |
+
|
128 |
+
except Exception as e:
|
129 |
+
retries += 1
|
130 |
+
if retries > self.max_retries:
|
131 |
+
raise e
|
132 |
+
|
133 |
+
# 对于限流错误,使用指数退避策略
|
134 |
+
if "429" in str(e):
|
135 |
+
wait_time = self.retry_delay * (2 ** (retries - 1))
|
136 |
+
print(f"\n遇到限流,等待 {wait_time} 秒后重试 ({retries}/{self.max_retries})...")
|
137 |
+
time.sleep(wait_time)
|
138 |
+
else:
|
139 |
+
raise e
|
140 |
+
|
141 |
+
def evaluate_single(self, question: Dict) -> Dict:
|
142 |
+
"""评估单个问题"""
|
143 |
+
prompt = self.generate_prompt(question)
|
144 |
+
|
145 |
+
try:
|
146 |
+
if self.dry_run:
|
147 |
+
prediction = f"[DRY RUN] 这是问题 {question['id']} 的模拟答案"
|
148 |
+
else:
|
149 |
+
prediction = self.call_api_with_retry(prompt)
|
150 |
+
# 添加调用间隔
|
151 |
+
time.sleep(self.delay)
|
152 |
+
|
153 |
+
is_correct = self.evaluate_answer(prediction, question['content']['answer'])
|
154 |
+
|
155 |
+
return {
|
156 |
+
'id': question['id'],
|
157 |
+
'type': question['type'],
|
158 |
+
'difficulty': question['difficulty'],
|
159 |
+
'metadata': question['metadata'],
|
160 |
+
'prompt': prompt,
|
161 |
+
'prediction': prediction,
|
162 |
+
'ground_truth': question['content']['answer'],
|
163 |
+
'is_correct': is_correct
|
164 |
+
}
|
165 |
+
|
166 |
+
except Exception as e:
|
167 |
+
print(f"Error evaluating question {question['id']}: {str(e)}")
|
168 |
+
return None
|
169 |
+
|
170 |
+
def evaluate_all(self, questions: List[Dict]):
|
171 |
+
"""评估所有问题"""
|
172 |
+
# 初始化计数器
|
173 |
+
total = len(questions)
|
174 |
+
correct = 0
|
175 |
+
|
176 |
+
# 创建进度条
|
177 |
+
pbar = tqdm(questions, desc="Evaluating")
|
178 |
+
|
179 |
+
for question in pbar:
|
180 |
+
result = self.evaluate_single(question)
|
181 |
+
if result:
|
182 |
+
self.results['all'].append(result)
|
183 |
+
self.results[result['type']].append(result)
|
184 |
+
self.results[result['difficulty']].append(result)
|
185 |
+
if result['metadata']['dynasty']:
|
186 |
+
self.results[result['metadata']['dynasty']].append(result)
|
187 |
+
|
188 |
+
# 更新计数
|
189 |
+
if result['is_correct']:
|
190 |
+
correct += 1
|
191 |
+
|
192 |
+
# 更新进度条描述
|
193 |
+
accuracy = correct / len(self.results['all']) * 100
|
194 |
+
pbar.set_description(
|
195 |
+
f"Accuracy: {accuracy:.2f}% ({correct}/{len(self.results['all'])})"
|
196 |
+
)
|
197 |
+
|
198 |
+
# 打印详细信息
|
199 |
+
print(f"\n问题 {result['id']} ({result['type']}, {result['difficulty']}):")
|
200 |
+
print(f"提示: {result['prompt']}")
|
201 |
+
print(f"预测: {result['prediction']}")
|
202 |
+
print(f"答案: {result['ground_truth']}")
|
203 |
+
print(f"结果: {'✓' if result['is_correct'] else '✗'}\n")
|
204 |
+
|
205 |
+
# 每次评测后更新总体准确率
|
206 |
+
print(f"当前总体准确率: {accuracy:.2f}%")
|
207 |
+
print("-" * 80)
|
208 |
+
|
209 |
+
def generate_report(self) -> Dict:
|
210 |
+
"""生成评测报告"""
|
211 |
+
report = {
|
212 |
+
'overall': self._calculate_metrics(self.results['all']),
|
213 |
+
'by_type': {},
|
214 |
+
'by_difficulty': {},
|
215 |
+
'by_dynasty': {}
|
216 |
+
}
|
217 |
+
|
218 |
+
# 按题型统计
|
219 |
+
for q_type in ['couplet', 'hint_words', 'find_poetry', 'blank_filling', 'first_last_words']:
|
220 |
+
if self.results[q_type]:
|
221 |
+
report['by_type'][q_type] = self._calculate_metrics(self.results[q_type])
|
222 |
+
|
223 |
+
# 按难度统计
|
224 |
+
for difficulty in ['easy', 'medium', 'hard']:
|
225 |
+
if self.results[difficulty]:
|
226 |
+
report['by_difficulty'][difficulty] = self._calculate_metrics(self.results[difficulty])
|
227 |
+
|
228 |
+
# 按朝代统计
|
229 |
+
for dynasty in set(r['metadata']['dynasty'] for r in self.results['all'] if r['metadata']['dynasty']):
|
230 |
+
report['by_dynasty'][dynasty] = self._calculate_metrics(self.results[dynasty])
|
231 |
+
|
232 |
+
return report
|
233 |
+
|
234 |
+
def _calculate_metrics(self, results: List[Dict]) -> Dict:
|
235 |
+
"""计算评测指标"""
|
236 |
+
total = len(results)
|
237 |
+
correct = sum(1 for r in results if r['is_correct'])
|
238 |
+
return {
|
239 |
+
'total': total,
|
240 |
+
'correct': correct,
|
241 |
+
'accuracy': correct / total if total > 0 else 0
|
242 |
+
}
|
243 |
+
|
244 |
+
def save_results(self, output_dir: str):
|
245 |
+
"""保存评测结果"""
|
246 |
+
os.makedirs(output_dir, exist_ok=True)
|
247 |
+
|
248 |
+
# 保存详细结果
|
249 |
+
with open(os.path.join(output_dir, 'detailed_results.jsonl'), 'w', encoding='utf-8') as f:
|
250 |
+
for result in self.results['all']:
|
251 |
+
f.write(json.dumps(result, ensure_ascii=False) + '\n')
|
252 |
+
|
253 |
+
# 保存原始输入输出
|
254 |
+
with open(os.path.join(output_dir, 'raw_io.jsonl'), 'w', encoding='utf-8') as f:
|
255 |
+
for result in self.results['all']:
|
256 |
+
raw_io = {
|
257 |
+
'id': result['id'],
|
258 |
+
'type': result['type'],
|
259 |
+
'prompt': result['prompt'],
|
260 |
+
'completion': result['prediction'],
|
261 |
+
'ground_truth': result['ground_truth']
|
262 |
+
}
|
263 |
+
f.write(json.dumps(raw_io, ensure_ascii=False) + '\n')
|
264 |
+
|
265 |
+
# 保存评测报告
|
266 |
+
report = self.generate_report()
|
267 |
+
with open(os.path.join(output_dir, 'evaluation_report.json'), 'w', encoding='utf-8') as f:
|
268 |
+
json.dump(report, ensure_ascii=False, indent=2, fp=f)
|
269 |
+
|
270 |
+
if __name__ == '__main__':
|
271 |
+
parser = argparse.ArgumentParser(description='评测大语言模型的古诗词能力')
|
272 |
+
|
273 |
+
parser.add_argument('--api-key',
|
274 |
+
type=str,
|
275 |
+
required=True,
|
276 |
+
help='API密钥')
|
277 |
+
|
278 |
+
parser.add_argument('--provider',
|
279 |
+
type=str,
|
280 |
+
choices=['openai', 'google'],
|
281 |
+
default='openai',
|
282 |
+
help='API提供商 (openai 或 google)')
|
283 |
+
|
284 |
+
parser.add_argument('--model',
|
285 |
+
type=str,
|
286 |
+
help='要评测的模型名称')
|
287 |
+
|
288 |
+
parser.add_argument('--api-base',
|
289 |
+
type=str,
|
290 |
+
help='API基础URL (例如: https://api.openai.com/v1)')
|
291 |
+
|
292 |
+
parser.add_argument('--output-dir',
|
293 |
+
type=str,
|
294 |
+
default='evaluation_results',
|
295 |
+
help='评测结果保存目录 (默认: evaluation_results)')
|
296 |
+
|
297 |
+
parser.add_argument('--benchmark-file',
|
298 |
+
type=str,
|
299 |
+
default='poetry_benchmark.jsonl',
|
300 |
+
help='评测数据集文件路径 (默认: poetry_benchmark.jsonl)')
|
301 |
+
|
302 |
+
parser.add_argument('--dry-run',
|
303 |
+
action='store_true',
|
304 |
+
help='演示模式,不实际调用API')
|
305 |
+
|
306 |
+
parser.add_argument('--delay',
|
307 |
+
type=float,
|
308 |
+
default=0.5,
|
309 |
+
help='API调用间隔时间(秒) (默认: 0.5)')
|
310 |
+
|
311 |
+
parser.add_argument('--max-retries',
|
312 |
+
type=int,
|
313 |
+
default=5,
|
314 |
+
help='API调用最大重试次数 (默认: 5)')
|
315 |
+
|
316 |
+
parser.add_argument('--retry-delay',
|
317 |
+
type=float,
|
318 |
+
default=10,
|
319 |
+
help='重试等待时间(秒) (默认: 10)')
|
320 |
+
|
321 |
+
args = parser.parse_args()
|
322 |
+
|
323 |
+
# 设置API基础URL (仅OpenAI需要)
|
324 |
+
if not args.dry_run and args.provider == "openai":
|
325 |
+
openai.api_base = args.api_base
|
326 |
+
|
327 |
+
# 初始化评测器
|
328 |
+
evaluator = PoetryEvaluator(
|
329 |
+
api_key=args.api_key,
|
330 |
+
provider=args.provider,
|
331 |
+
model=args.model,
|
332 |
+
dry_run=args.dry_run,
|
333 |
+
delay=args.delay,
|
334 |
+
max_retries=args.max_retries,
|
335 |
+
retry_delay=args.retry_delay
|
336 |
+
)
|
337 |
+
|
338 |
+
# 加载数据
|
339 |
+
questions = evaluator.load_benchmark(args.benchmark_file)
|
340 |
+
|
341 |
+
# 运行评测
|
342 |
+
evaluator.evaluate_all(questions)
|
343 |
+
|
344 |
+
# 生成报告
|
345 |
+
report = evaluator.generate_report()
|
346 |
+
print(json.dumps(report, ensure_ascii=False, indent=2))
|
347 |
+
|
348 |
+
# 保存结果
|
349 |
+
evaluator.save_results(args.output_dir)
|
generate_report.py
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
from typing import Dict, List
|
4 |
+
from datetime import datetime
|
5 |
+
|
6 |
+
def get_model_names() -> List[str]:
|
7 |
+
"""从evaluation_results文件夹获取所有模型名称"""
|
8 |
+
model_names = []
|
9 |
+
for item in os.listdir('.'):
|
10 |
+
if item.startswith('evaluation_results.') and os.path.isdir(item):
|
11 |
+
model_name = item.replace('evaluation_results.', '')
|
12 |
+
model_names.append(model_name)
|
13 |
+
return sorted(model_names) # 排序以保持顺序一致
|
14 |
+
|
15 |
+
def load_report(model_name: str) -> Dict:
|
16 |
+
"""加载模型的评测报告"""
|
17 |
+
report_path = f"evaluation_results.{model_name}/evaluation_report.json"
|
18 |
+
with open(report_path, 'r', encoding='utf-8') as f:
|
19 |
+
return json.load(f)
|
20 |
+
|
21 |
+
def format_percentage(value: float) -> str:
|
22 |
+
"""格式化百分比显示"""
|
23 |
+
return f"{value*100:.2f}%"
|
24 |
+
|
25 |
+
def generate_markdown_report():
|
26 |
+
"""生成markdown格式的评测报告"""
|
27 |
+
# 动态获取模型列表
|
28 |
+
models = get_model_names()
|
29 |
+
|
30 |
+
# 加载所有报告
|
31 |
+
reports = {model: load_report(model) for model in models}
|
32 |
+
|
33 |
+
# 生成报告内容
|
34 |
+
report = []
|
35 |
+
|
36 |
+
# 标题和时间
|
37 |
+
report.append("# 中国古诗词大模型评测报告")
|
38 |
+
report.append(f"生成时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
|
39 |
+
|
40 |
+
# 添加模型信息
|
41 |
+
report.append(f"评测模型: {', '.join(models)}\n")
|
42 |
+
|
43 |
+
# 1. 整体表现对比
|
44 |
+
report.append("## 1. 整体表现对比")
|
45 |
+
|
46 |
+
# 获取所有题型
|
47 |
+
all_types = sorted(set(
|
48 |
+
q_type
|
49 |
+
for data in reports.values()
|
50 |
+
for q_type in data['by_type'].keys()
|
51 |
+
))
|
52 |
+
|
53 |
+
# 生成表头
|
54 |
+
headers = ["模型"] + all_types + ["总计", "总正确率"]
|
55 |
+
report.append("\n| " + " | ".join(headers) + " |")
|
56 |
+
report.append("| " + " | ".join(["----" for _ in headers]) + " |")
|
57 |
+
|
58 |
+
# 按总正确率排序
|
59 |
+
sorted_models = sorted(reports.items(),
|
60 |
+
key=lambda x: x[1]['overall']['accuracy'],
|
61 |
+
reverse=True)
|
62 |
+
|
63 |
+
# 生成每个模型的数据行
|
64 |
+
for model, data in sorted_models:
|
65 |
+
row = [model]
|
66 |
+
# 添加每个题型的数据
|
67 |
+
for q_type in all_types:
|
68 |
+
if q_type in data['by_type']:
|
69 |
+
metrics = data['by_type'][q_type]
|
70 |
+
row.append(f"{metrics['correct']}/{metrics['total']}")
|
71 |
+
else:
|
72 |
+
row.append("0/0")
|
73 |
+
|
74 |
+
# 添加总计和总正确率
|
75 |
+
overall = data['overall']
|
76 |
+
row.append(f"{overall['correct']}/{overall['total']}")
|
77 |
+
row.append(format_percentage(overall['accuracy']))
|
78 |
+
|
79 |
+
report.append("| " + " | ".join(row) + " |")
|
80 |
+
report.append("")
|
81 |
+
|
82 |
+
# 2. 按题型分类表现
|
83 |
+
report.append("## 2. 题型分类表现")
|
84 |
+
report.append("\n| 模型 | 题型 | 总题数 | 正确数 | 准确率 |")
|
85 |
+
report.append("| --- | --- | --- | --- | --- |")
|
86 |
+
|
87 |
+
# 获取所有题型
|
88 |
+
all_types = sorted(set(
|
89 |
+
q_type
|
90 |
+
for data in reports.values()
|
91 |
+
for q_type in data['by_type'].keys()
|
92 |
+
))
|
93 |
+
|
94 |
+
for q_type in all_types:
|
95 |
+
type_results = []
|
96 |
+
for model, data in reports.items():
|
97 |
+
if q_type in data['by_type']:
|
98 |
+
metrics = data['by_type'][q_type]
|
99 |
+
type_results.append((model, metrics))
|
100 |
+
|
101 |
+
# 按准确率排序
|
102 |
+
sorted_results = sorted(type_results,
|
103 |
+
key=lambda x: x[1]['accuracy'],
|
104 |
+
reverse=True)
|
105 |
+
|
106 |
+
for model, metrics in sorted_results:
|
107 |
+
report.append(f"| {model} | {q_type} | {metrics['total']} | {metrics['correct']} | {format_percentage(metrics['accuracy'])} |")
|
108 |
+
report.append("| --- | --- | --- | --- | --- |") # 添加分隔线
|
109 |
+
report.append("")
|
110 |
+
|
111 |
+
# 3. 难度分布表现
|
112 |
+
report.append("## 3. 难度分布表现")
|
113 |
+
report.append("\n| 模型 | 难度 | 总题数 | 正确数 | 准确率 |")
|
114 |
+
report.append("| --- | --- | --- | --- | --- |")
|
115 |
+
|
116 |
+
# 难度顺序
|
117 |
+
difficulty_order = ['easy', 'medium', 'hard']
|
118 |
+
|
119 |
+
for diff in difficulty_order:
|
120 |
+
diff_results = []
|
121 |
+
for model, data in reports.items():
|
122 |
+
if diff in data['by_difficulty']:
|
123 |
+
metrics = data['by_difficulty'][diff]
|
124 |
+
diff_results.append((model, metrics))
|
125 |
+
|
126 |
+
# 按准确率排序
|
127 |
+
sorted_results = sorted(diff_results,
|
128 |
+
key=lambda x: x[1]['accuracy'],
|
129 |
+
reverse=True)
|
130 |
+
|
131 |
+
for model, metrics in sorted_results:
|
132 |
+
report.append(f"| {model} | {diff} | {metrics['total']} | {metrics['correct']} | {format_percentage(metrics['accuracy'])} |")
|
133 |
+
report.append("| --- | --- | --- | --- | --- |") # 添加分隔线
|
134 |
+
report.append("")
|
135 |
+
|
136 |
+
# 4. 朝代分布表现
|
137 |
+
report.append("## 4. 朝代分布表现")
|
138 |
+
report.append("\n| 模型 | 朝代 | 总题数 | ��确数 | 准确率 |")
|
139 |
+
report.append("| --- | --- | --- | --- | --- |")
|
140 |
+
|
141 |
+
# 获取所有朝代并排序
|
142 |
+
all_dynasties = sorted(set(
|
143 |
+
dynasty if dynasty else "未知"
|
144 |
+
for data in reports.values()
|
145 |
+
for dynasty in data['by_dynasty'].keys()
|
146 |
+
))
|
147 |
+
|
148 |
+
for dynasty in all_dynasties:
|
149 |
+
dynasty_results = []
|
150 |
+
for model, data in reports.items():
|
151 |
+
if dynasty in data['by_dynasty'] or (dynasty == "未知" and None in data['by_dynasty']):
|
152 |
+
metrics = data['by_dynasty'][None if dynasty == "未知" else dynasty]
|
153 |
+
dynasty_results.append((model, metrics))
|
154 |
+
|
155 |
+
# 按准确率排序
|
156 |
+
sorted_results = sorted(dynasty_results,
|
157 |
+
key=lambda x: x[1]['accuracy'],
|
158 |
+
reverse=True)
|
159 |
+
|
160 |
+
for model, metrics in sorted_results:
|
161 |
+
report.append(f"| {model} | {dynasty} | {metrics['total']} | {metrics['correct']} | {format_percentage(metrics['accuracy'])} |")
|
162 |
+
report.append("| --- | --- | --- | --- | --- |") # 添加分隔线
|
163 |
+
report.append("")
|
164 |
+
|
165 |
+
# 5. 结论分析
|
166 |
+
report.append("## 5. 结论分析")
|
167 |
+
report.append("\n### 5.1 整体表现")
|
168 |
+
|
169 |
+
# 计算最佳表现模型
|
170 |
+
best_model = max(reports.items(), key=lambda x: x[1]['overall']['accuracy'])
|
171 |
+
report.append(f"- 最佳表现模型: {best_model[0]}, 整体准确率 {format_percentage(best_model[1]['overall']['accuracy'])}")
|
172 |
+
|
173 |
+
# 计算各个维度的最佳表现
|
174 |
+
report.append("\n### 5.2 分维度最佳表现")
|
175 |
+
|
176 |
+
# 题型维度
|
177 |
+
report.append("\n#### 题型维度:")
|
178 |
+
for q_type in all_types:
|
179 |
+
best = max(reports.items(),
|
180 |
+
key=lambda x: x[1]['by_type'][q_type]['accuracy'])
|
181 |
+
report.append(f"- {q_type}: {best[0]} ({format_percentage(best[1]['by_type'][q_type]['accuracy'])})")
|
182 |
+
|
183 |
+
# 难度维度
|
184 |
+
report.append("\n#### 难度维度:")
|
185 |
+
for diff in difficulty_order:
|
186 |
+
best = max(reports.items(),
|
187 |
+
key=lambda x: x[1]['by_difficulty'][diff]['accuracy'])
|
188 |
+
report.append(f"- {diff}: {best[0]} ({format_percentage(best[1]['by_difficulty'][diff]['accuracy'])})")
|
189 |
+
|
190 |
+
# 写入文件
|
191 |
+
with open('evaluation_report.md', 'w', encoding='utf-8') as f:
|
192 |
+
f.write('\n'.join(report))
|
193 |
+
|
194 |
+
if __name__ == '__main__':
|
195 |
+
generate_markdown_report()
|
poetry_benchmark.jsonl
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"id": "1", "type": "couplet", "difficulty": "medium", "content": {"question": "()。南雁归时更寂寥。", "answer": "只觉魂销"}, "metadata": {"author": "纳兰性德", "dynasty": "清"}}
|
2 |
+
{"id": "2", "type": "couplet", "difficulty": "medium", "content": {"question": "故山有松月,()。", "answer": "迟尔玩清晖"}, "metadata": {"author": "李白", "dynasty": "唐"}}
|
3 |
+
{"id": "3", "type": "couplet", "difficulty": "medium", "content": {"question": "(),议者死路衢。", "answer": "边人不敢议"}, "metadata": {"author": "杜甫", "dynasty": "唐"}}
|
4 |
+
{"id": "4", "type": "couplet", "difficulty": "easy", "content": {"question": "牙璋辞凤阙,()。", "answer": "铁骑绕龙城"}, "metadata": {"author": "杨炯", "dynasty": "唐"}}
|
5 |
+
{"id": "5", "type": "couplet", "difficulty": "easy", "content": {"question": "忽见陌头杨柳色,()。", "answer": "悔教夫婿觅封侯"}, "metadata": {"author": "王昌龄", "dynasty": "唐"}}
|
6 |
+
{"id": "6", "type": "couplet", "difficulty": "hard", "content": {"question": "惊世间残暴竟如斯,()。", "answer": "两洲血"}, "metadata": {"author": "陈毅", "dynasty": null}}
|
7 |
+
{"id": "7", "type": "couplet", "difficulty": "medium", "content": {"question": "坐看新落叶,()。", "answer": "行上最高楼"}, "metadata": {"author": "白居易", "dynasty": "唐"}}
|
8 |
+
{"id": "8", "type": "couplet", "difficulty": "hard", "content": {"question": "问渠何旨意,()。", "answer": "恐落凡人耳"}, "metadata": {"author": "顾况", "dynasty": "唐"}}
|
9 |
+
{"id": "9", "type": "couplet", "difficulty": "medium", "content": {"question": "(),飞鸟何时还。", "answer": "浮云几处灭"}, "metadata": {"author": "王缙", "dynasty": "唐"}}
|
10 |
+
{"id": "10", "type": "couplet", "difficulty": "medium", "content": {"question": "(),薜萝若在眼。", "answer": "想见山阿人"}, "metadata": {"author": "谢灵运", "dynasty": "南北朝"}}
|
11 |
+
{"id": "11", "type": "couplet", "difficulty": "medium", "content": {"question": "曾为大梁客,()。", "answer": "不负信陵恩"}, "metadata": {"author": "王昌龄", "dynasty": "唐"}}
|
12 |
+
{"id": "12", "type": "couplet", "difficulty": "easy", "content": {"question": "(),园柳变鸣禽。", "answer": "池塘生春草"}, "metadata": {"author": "谢灵运", "dynasty": "南北朝"}}
|
13 |
+
{"id": "13", "type": "couplet", "difficulty": "hard", "content": {"question": "冯公岂不伟,()。", "answer": "白首不见招"}, "metadata": {"author": "左思", "dynasty": "晋"}}
|
14 |
+
{"id": "14", "type": "couplet", "difficulty": "medium", "content": {"question": "(),不堪听、急管繁弦。", "answer": "憔悴江南倦客"}, "metadata": {"author": "周邦彦", "dynasty": "宋"}}
|
15 |
+
{"id": "15", "type": "couplet", "difficulty": "easy", "content": {"question": "(),万马齐喑究可哀。", "answer": "九州生气恃风雷"}, "metadata": {"author": "龚自珍", "dynasty": "清"}}
|
16 |
+
{"id": "16", "type": "couplet", "difficulty": "hard", "content": {"question": "余既滋兰之九畹兮,()。", "answer": "又树蕙之百亩"}, "metadata": {"author": "屈原", "dynasty": "战国"}}
|
17 |
+
{"id": "17", "type": "couplet", "difficulty": "medium", "content": {"question": "人生难得秋前雨,()。", "answer": "乞我虚堂自在眠"}, "metadata": {"author": "姜夔", "dynasty": "宋"}}
|
18 |
+
{"id": "18", "type": "couplet", "difficulty": "easy", "content": {"question": "(),空回首、烟霭纷纷。", "answer": "多少蓬莱旧事"}, "metadata": {"author": "秦观", "dynasty": "宋"}}
|
19 |
+
{"id": "19", "type": "couplet", "difficulty": "hard", "content": {"question": "(),花雨空坛。更无人处一凭栏。", "answer": "秋草六朝寒"}, "metadata": {"author": "朱彝尊", "dynasty": "清"}}
|
20 |
+
{"id": "20", "type": "couplet", "difficulty": "medium", "content": {"question": "少年侠气,()。", "answer": "交结五都雄"}, "metadata": {"author": "贺铸", "dynasty": "宋"}}
|
21 |
+
{"id": "21", "type": "hint_words", "difficulty": "easy", "content": {"question": "**誓**,*心***。", "answer": "波澜誓不起,妾心古井水/波澜誓不起,妾心古井水"}, "metadata": {"author": "孟郊", "dynasty": "唐"}}
|
22 |
+
{"id": "22", "type": "hint_words", "difficulty": "hard", "content": {"question": "****醉,芙****。", "answer": "美酒余杭醉,芙蓉即奉杯"}, "metadata": {"author": "庾信", "dynasty": "南北朝"}}
|
23 |
+
{"id": "23", "type": "hint_words", "difficulty": "medium", "content": {"question": "**兽**,**鸟**。", "answer": "岩悬兽无迹,林暗鸟疑飞"}, "metadata": {"author": "范云", "dynasty": "南北朝"}}
|
24 |
+
{"id": "24", "type": "hint_words", "difficulty": "medium", "content": {"question": "有****,****莲。", "answer": "有园多种橘,无水不生莲"}, "metadata": {"author": "杜荀鹤", "dynasty": "唐"}}
|
25 |
+
{"id": "25", "type": "hint_words", "difficulty": "medium", "content": {"question": "***梅***,**梅*。", "answer": "大都来梅花是我,我是梅花"}, "metadata": {"author": "景元启", "dynasty": "元"}}
|
26 |
+
{"id": "26", "type": "hint_words", "difficulty": "medium", "content": {"question": "所****,焉****。", "answer": "所遇无故物,焉得不速老"}, "metadata": {"author": "《古诗十九首》", "dynasty": "汉"}}
|
27 |
+
{"id": "27", "type": "hint_words", "difficulty": "medium", "content": {"question": "***熛***,******鸠。", "answer": "奔霆飞熛歼人子,败井颓垣剩饿鸠"}, "metadata": {"author": "鲁迅", "dynasty": "现代"}}
|
28 |
+
{"id": "28", "type": "hint_words", "difficulty": "easy", "content": {"question": "******转,***赏***。", "answer": "传语风光共流转,暂时相赏莫相违"}, "metadata": {"author": "杜甫", "dynasty": "唐"}}
|
29 |
+
{"id": "29", "type": "hint_words", "difficulty": "medium", "content": {"question": "*怜****,***绕**。", "answer": "小怜初上琵琶,晓来思绕天涯"}, "metadata": {"author": "王安国", "dynasty": "宋"}}
|
30 |
+
{"id": "30", "type": "hint_words", "difficulty": "easy", "content": {"question": "过****,险****。", "answer": "过了黄洋界,险处不须看"}, "metadata": {"author": "毛主席", "dynasty": "现代"}}
|
31 |
+
{"id": "31", "type": "find_poetry", "difficulty": "medium", "content": {"question": "请识别出一句七言唐诗(正序)\n不与世俱去\n美人在空谷\n惜哉时不遇\n我命绝今日\n上下同饮啄\n卓众来东下\n摘子防人到", "answer": "世人遇我同众人"}, "metadata": {"author": null, "dynasty": null}}
|
32 |
+
{"id": "32", "type": "find_poetry", "difficulty": "easy", "content": {"question": "请识别出一句七言唐诗(正序)\n千秋惟此心\n未去朝天子\n绝漠冲风急\n漠南胡未空\n大笑向文士\n黄昏人定后\n明月临幽黑", "answer": "秋天漠漠向昏黑"}, "metadata": {"author": null, "dynasty": null}}
|
33 |
+
{"id": "33", "type": "find_poetry", "difficulty": "hard", "content": {"question": "请识别出一句五言唐诗(乱序)\n我忆君诗最苦\n临相别也怀恨\n庭院慕寒时节\n枝头累累青梅\n堪比天真颜色", "answer": "寒梅最堪恨"}, "metadata": {"author": null, "dynasty": null}}
|
34 |
+
{"id": "34", "type": "find_poetry", "difficulty": "medium", "content": {"question": "请识别出一句五字元曲(正序)\n难怪人离心不走\n空走了千遭万遭\n苟利国家生死以\n被以不慈之伪名\n坛场宫馆尽蓬蒿", "answer": "离了利名场"}, "metadata": {"author": null, "dynasty": null}}
|
35 |
+
{"id": "35", "type": "find_poetry", "difficulty": "hard", "content": {"question": "请识别出一句五字宋词(乱序)\n早落先梧桐\n檐外三竿日\n我今对鳞羽\n吹起故乡情\n谷风转凄薄", "answer": "今日风吹落"}, "metadata": {"author": null, "dynasty": null}}
|
36 |
+
{"id": "36", "type": "find_poetry", "difficulty": "easy", "content": {"question": "请识别出一句五字宋词(正序)\n天空海阔思何穷\n须识愁多暗损心\n殷勤纳谏论兴废\n比红得句寻花笑\n那知自己归来丧", "answer": "何须论得丧"}, "metadata": {"author": null, "dynasty": null}}
|
37 |
+
{"id": "37", "type": "find_poetry", "difficulty": "medium", "content": {"question": "请识别出一句七言宋诗(正序)\n千唤不一回\n食闷飞不起\n江陵谪去时\n仙衣尽带风\n泪下如流泉\n雨洒石壁来\n飞上桃花面", "answer": "唤起谪仙泉洒面"}, "metadata": {"author": null, "dynasty": null}}
|
38 |
+
{"id": "38", "type": "find_poetry", "difficulty": "hard", "content": {"question": "请识别出一句五言唐诗(乱序)\n翠钗金作股\n三十羽林将\n还应甲桂林\n见吾满面笑\n黄鹄游四海", "answer": "三面黄金甲"}, "metadata": {"author": null, "dynasty": null}}
|
39 |
+
{"id": "39", "type": "find_poetry", "difficulty": "easy", "content": {"question": "请识别出一句六字元曲(正序)\n烟花雁行\n花是春心\n杨柳眉颦\n东园之柳\n有用真空\n不辨伪真", "answer": "花花柳柳真真"}, "metadata": {"author": null, "dynasty": null}}
|
40 |
+
{"id": "40", "type": "find_poetry", "difficulty": "hard", "content": {"question": "请识别出一句七言明诗(正序)\n凉风吹过妆楼\n当年许我忘年\n小庭闲步徘徊\n眼中前事分明\n松柏一何累累\n但见茂林芳树\n碧桃枝上莺声", "answer": "吹我庭前柏树枝"}, "metadata": {"author": null, "dynasty": null}}
|
41 |
+
{"id": "41", "type": "find_poetry", "difficulty": "easy", "content": {"question": "请从下面五句诗中找出一句五言唐诗:(正序)\n地势使之然\n天上分金镜\n有三秋桂子\n仙人垂两足\n鼎镬甘如饴", "answer": "势分三足鼎"}, "metadata": {"author": null, "dynasty": null}}
|
42 |
+
{"id": "42", "type": "find_poetry", "difficulty": "medium", "content": {"question": "请从下面七句诗中找出一句七言宋诗:(正序)\n不如随分尊前醉\n指挥楚汉如旋蓬\n人人尽说江南好\n春蚕到死丝方尽\n不炼金丹不坐禅\n肯使江山付劫灰\n要休且待青山烂", "answer": "不指南方不肯休"}, "metadata": {"author": null, "dynasty": null}}
|
43 |
+
{"id": "43", "type": "find_poetry", "difficulty": "medium", "content": {"question": "请从下面六句诗中找出一句宋词:(正序)\n除非问取黄���\n换了浅斟低唱\n醉舞狂歌欲倒\n叫秋木而长吟\n春风十里柔情\n明月前溪后溪", "answer": "除了醉吟风月"}, "metadata": {"author": null, "dynasty": null}}
|
44 |
+
{"id": "44", "type": "find_poetry", "difficulty": "hard", "content": {"question": "请从下面五句诗中找出一句南北朝诗:(乱序)\n东林怀我师\n静夜四无邻\n君行逾十年\n雨过一蝉噪\n蝉噪野风秋", "answer": "蝉噪林逾静"}, "metadata": {"author": null, "dynasty": null}}
|
45 |
+
{"id": "45", "type": "find_poetry", "difficulty": "hard", "content": {"question": "请从下面七句诗中找出一句唐诗:(乱序)\n每岁烟花一万重\n一去心知更不归\n深巷明朝卖杏花\n寒林空见日斜时\n柳外轻雷池上雨\n蒹葭杨柳似汀洲\n沾衣欲湿杏花雨", "answer": "一汀烟雨杏花寒"}, "metadata": {"author": null, "dynasty": null}}
|
46 |
+
{"id": "46", "type": "blank_filling", "difficulty": "medium", "content": {"question": "闻道()酒,无钱亦可求。", "answer": "成都"}, "metadata": {"author": "李崇嗣", "dynasty": "唐"}}
|
47 |
+
{"id": "47", "type": "blank_filling", "difficulty": "hard", "content": {"question": "()论未竟,已遭肉食骂。", "answer": "陶公"}, "metadata": {"author": "郑孝胥", "dynasty": "清"}}
|
48 |
+
{"id": "48", "type": "blank_filling", "difficulty": "medium", "content": {"question": "人去空(),花飞半掩门。", "answer": "流水"}, "metadata": {"author": "秦观", "dynasty": "宋"}}
|
49 |
+
{"id": "49", "type": "blank_filling", "difficulty": "easy", "content": {"question": "由来()地,不见有人还。", "answer": "征战"}, "metadata": {"author": "李白", "dynasty": "唐"}}
|
50 |
+
{"id": "50", "type": "blank_filling", "difficulty": "medium", "content": {"question": "我不识君曾梦见,()了然光可烛。", "answer": "瞳子"}, "metadata": {"author": "苏轼", "dynasty": "宋"}}
|
51 |
+
{"id": "51", "type": "blank_filling", "difficulty": "medium", "content": {"question": "九天阊阖开宫殿,()衣冠拜冕旒。", "answer": "万国"}, "metadata": {"author": "王维", "dynasty": "唐"}}
|
52 |
+
{"id": "52", "type": "blank_filling", "difficulty": "easy", "content": {"question": "山一程,水一程,身向()那畔行,夜深千帐灯。", "answer": "榆关"}, "metadata": {"author": "纳兰性德", "dynasty": "清"}}
|
53 |
+
{"id": "53", "type": "blank_filling", "difficulty": "hard", "content": {"question": "名都多妖女,京洛出()。", "answer": "少年"}, "metadata": {"author": "曹植", "dynasty": "三国"}}
|
54 |
+
{"id": "54", "type": "blank_filling", "difficulty": "medium", "content": {"question": "()城东谁家子,窃听琴声碧窗里。", "answer": "金陵"}, "metadata": {"author": "李白", "dynasty": "唐"}}
|
55 |
+
{"id": "55", "type": "blank_filling", "difficulty": "easy", "content": {"question": "今宵剩把银釭照,犹恐相逢是()。", "answer": "梦中"}, "metadata": {"author": "晏几道", "dynasty": "宋"}}
|
56 |
+
{"id": "56", "type": "blank_filling", "difficulty": "hard", "content": {"question": "怅望()空吊影,正人间、鼻息鸣鼍鼓。", "answer": "关河"}, "metadata": {"author": "张元干", "dynasty": "宋"}}
|
57 |
+
{"id": "57", "type": "blank_filling", "difficulty": "medium", "content": {"question": "不才明主弃,多病()疏。", "answer": "故人"}, "metadata": {"author": "孟浩然", "dynasty": "唐"}}
|
58 |
+
{"id": "58", "type": "blank_filling", "difficulty": "easy", "content": {"question": "()如不赏,归卧故山秋。", "answer": "知音"}, "metadata": {"author": "贾岛", "dynasty": "唐"}}
|
59 |
+
{"id": "59", "type": "blank_filling", "difficulty": "hard", "content": {"question": "()流日夜,客心悲未央。", "answer": "大江"}, "metadata": {"author": "谢朓", "dynasty": "南北朝"}}
|
60 |
+
{"id": "60", "type": "blank_filling", "difficulty": "medium", "content": {"question": "愁与()应有约,年年同赴清秋。", "answer": "西风"}, "metadata": {"author": "史达祖", "dynasty": "宋"}}
|
61 |
+
{"id": "61", "type": "first_last_words", "difficulty": "medium", "content": {"question": "衣******,******吼。", "answer": "衣如飞鹑马如狗,临歧击剑生铜吼。"}, "metadata": {"author": "李贺", "dynasty": "唐"}}
|
62 |
+
{"id": "62", "type": "first_last_words", "difficulty": "easy", "content": {"question": "试******,******期。", "answer": "试玉要烧三日满,辨材须待七年期。"}, "metadata": {"author": "白居易", "dynasty": "唐"}}
|
63 |
+
{"id": "63", "type": "first_last_words", "difficulty": "hard", "content": {"question": "紫******,******冰。", "answer": "紫府仙人号宝灯,云浆未饮结成冰。"}, "metadata": {"author": "李商隐", "dynasty": "唐"}}
|
64 |
+
{"id": "64", "type": "first_last_words", "difficulty": "medium", "content": {"question": "渡*****,******手。", "answer": "渡江天马南来,几人真是经纶手。"}, "metadata": {"author": "辛弃疾", "dynasty": "宋"}}
|
65 |
+
{"id": "65", "type": "first_last_words", "difficulty": "easy", "content": {"question": "烈***,***已。", "answer": "烈士暮年,壮心不已。"}, "metadata": {"author": "曹��", "dynasty": "三国"}}
|
66 |
+
{"id": "66", "type": "first_last_words", "difficulty": "hard", "content": {"question": "逆******,******声。", "answer": "逆胡未灭心未平,孤剑床头铿有声。"}, "metadata": {"author": "陆游", "dynasty": "宋"}}
|
67 |
+
{"id": "67", "type": "first_last_words", "difficulty": "medium", "content": {"question": "当***,******雄。", "answer": "当场只手,毕竟还我万夫雄。"}, "metadata": {"author": "陈亮", "dynasty": "宋"}}
|
68 |
+
{"id": "68", "type": "first_last_words", "difficulty": "easy", "content": {"question": "停******,******然。", "answer": "停杯投箸不能食,拔剑四顾心茫然。"}, "metadata": {"author": "李白", "dynasty": "唐"}}
|
69 |
+
{"id": "69", "type": "first_last_words", "difficulty": "hard", "content": {"question": "回****,****洲。", "answer": "回首叫虞舜,杜若满芳洲。"}, "metadata": {"author": "张孝祥", "dynasty": "宋"}}
|
70 |
+
{"id": "70", "type": "first_last_words", "difficulty": "medium", "content": {"question": "人******,******歇。", "answer": "人境不教车马近,醉乡莫放笙歌歇。"}, "metadata": {"author": "吴文英", "dynasty": "宋"}}
|