Files
benchmark-chart/README.md
2026-06-02 00:44:53 +08:00

108 lines
2.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Benchmark Chart — AI 模型基准测试对比图生成器
一键生成类似 Qwen/Gemma 官方风格的 AI 模型基准测试对比图。
## 效果预览
![示例输出](output.png)
## 功能特性
- 12 个基准测试自动排列为 3×4或自定义行列网格
- **分组柱状图**MoE混合专家和 Dense稠密模型分组对比
- 虚线分隔 + 组标签,一目了然
- 最高分自动标注
- 底部统一图例,颜色可自定义
- 薄荷绿背景,现代扁平风格
## 快速开始
```bash
# 安装依赖
pip install matplotlib
# 用示例数据生成
python benchmark_chart.py -c sample_data.py -o output.png
# 自定义配置
python benchmark_chart.py -c my_data.py -o result.png --dpi 200 --width 28 --height 18
```
## 数据格式
支持 `.py` / `.json` / `.yaml` 三种配置格式。推荐 `.py`,可以用变量减少重复:
```python
# my_data.py
TITLE = "My Model Comparison"
COLORS = {
"model_a": "#5B2D8E",
"model_b": "#06B6D4",
}
BENCHMARKS = [
{
"title": "Benchmark Name",
"subtitle": "Short Description",
"models": [
{
"name": "Full Model Name", # 图例显示
"short_label": "Short", # 柱子下方标签
"group": "moe", # "moe" 或 "dense"
"score": 85.5, # 分数
"color_key": "model_a", # 对应 COLORS 中的 key
},
# ... 更多模型
],
},
# ... 更多基准测试
]
```
### 配置项说明
| 字段 | 说明 |
|------|------|
| `TITLE` | 总标题(顶部居中) |
| `COLORS` | `{color_key: hex颜色}` 映射 |
| `BG_COLOR` | 背景色(默认 `#E8F5E9` |
| `BAR_WIDTH` | 柱子宽度(默认 `0.55` |
| `NCOLS` | 每行列数(默认 `4` |
| `BENCHMARKS` | 基准测试列表 |
每个 benchmark 中每个 model 的字段:
| 字段 | 说明 |
|------|------|
| `name` | 完整名称(图例) |
| `short_label` | 短标签(柱下方,支持 `\n` 换行) |
| `group` | `"moe"``"dense"` |
| `score` | 数值 |
| `color_key` | 颜色映射 key |
## 命令行参数
```
-c, --config 数据配置文件路径(必需)
-o, --output 输出图片路径(默认 benchmark_chart.png
--dpi 分辨率(默认 200
--width 图片宽度,英寸(默认 24
--height 图片高度,英寸(默认 16
```
## 文件结构
```
benchmark-chart/
├── benchmark_chart.py # 主脚本
├── sample_data.py # 示例数据
├── output.png # 生成结果
└── README.md
```
## 依赖
- Python 3.8+
- matplotlib
- (可选) PyYAML — 如果用 `.yaml` 配置