ChartBench-E / docs /chartbench_e_rebuilt_README.md
xiaoluo11's picture
Add files using upload-large-folder tool
90d6c2f verified
# ChartBench-E (Rebuilt, Insight-Oriented)
This implementation rebuilds ChartBench-E and extends it into a more diagnostic benchmark for VLM chart reading.
## What it provides
- 20 data patterns grouped into 6 behavior families.
- Multiple chart morphologies: `line`, `bar_v`, `bar_h`, `stacked`.
- Annotation modes: `labeled`, `partial`, `unlabeled`.
- Multi-factor difficulty beyond point count:
- visual perturbations (noise, blur, JPEG artifacts, partial occlusion)
- semantic traps (truncated axis, log-scale reading, legend confusion)
- event-level stressors (outlier spikes, near-tie values, regime shifts)
- Diagnostic metadata tags for capability slicing:
- `event_tags`
- `perceptual_tags`
- `semantic_risk_tags`
- Reproducible generation with random seed.
- Evaluation metrics:
- SPR (Success Parsing Rate)
- OA (Overall Accuracy)
- NRA (Numerical Reading Accuracy)
- ARE (Average Relative Error)
## Install
```bash
cd chartbench_e
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```
## Build benchmark-focused dataset
```bash
PYTHONPATH=. python scripts/build_chartbench_e.py \
--out output/chartbench_e_benchmark_plus \
--total-samples 20000 \
--seed 42 \
--task-mode benchmark \
--challenge-level standard
```
Challenge levels:
- `standard`: light perturbation, mostly clean charts.
- `advanced`: balanced stress setting.
- `extreme`: heavy perturbation and denser hard cases.
## Make fixed evaluation subset
```bash
PYTHONPATH=. python scripts/make_eval_subset.py \
--index output/chartbench_e_benchmark_plus/metadata/index.jsonl \
--out output/chartbench_e_benchmark_plus/metadata/eval_subset.jsonl \
--per-task 400
```
Risk-focused subset example:
```bash
PYTHONPATH=. python scripts/make_eval_subset.py \
--index output/chartbench_e_benchmark_plus/metadata/index.jsonl \
--out output/chartbench_e_benchmark_plus/metadata/eval_compositional.jsonl \
--per-task 200 \
--require-risk-tag compositional_reasoning
```
## Evaluate predictions
Prediction format (`jsonl`):
```json
{"sample_id": "cb_0000001", "values": [[...], [...]]}
```
Run:
```bash
PYTHONPATH=. python scripts/evaluate_predictions.py \
--truth output/chartbench_e_benchmark_plus/metadata/eval_subset.jsonl \
--pred your_predictions.jsonl \
--out output/report.json \
--tolerance 0.05
```
## Multi-model benchmark (new)
### Supported model registry
See `scripts/model_registry.json`.
Default enabled models:
- `gpt-5.2`
- `gpt-5.2-high`
- `gpt-5`
- `gpt-5-mini-high`
- `qwen3-vl-30b-a3b-thinking`
- `qwen2.5-vl-72b`
- `glm-4.6v`
Explicitly excluded in this round:
- `deepseek-vl2`
- `paddleocr-vl-1.5`
### Required env vars
OpenAI provider:
- `OPENAI_API_KEY`
- `OPENAI_BASE_URL` (optional)
SiliconFlow provider:
- `SILICONFLOW_API_KEY`
- `SILICONFLOW_BASE_URL` (optional, default `https://api.siliconflow.cn/v1`)
Fallback rule for SiliconFlow models:
- if `SILICONFLOW_*` is missing, script falls back to `OPENAI_*`
### Prompt behavior
- The benchmark runner defaults to `--prompt-mode type_specific`.
- In `type_specific` mode, prompts are loaded from `prompts/chart_types/<chart_type>.txt`.
- Each prompt instantiation now includes a shape-aware JSON example through `{json_example}`, in addition to the strict JSON output contract.
- `prompts/chart_reading_prompt.txt` remains available for `--prompt-mode unified`.
### Run benchmark
Single model + 3 repeats + evaluation:
```bash
PYTHONPATH=. python scripts/run_vlm_benchmark.py \
--truth-index output/chartbench_e_benchmark_plus/metadata/eval_subset.jsonl \
--dataset-root output/chartbench_e_benchmark_plus \
--models gpt-5.2 \
--repeats 3 \
--max-workers 2 \
--max-retries 2 \
--timeout-seconds 120 \
--run-eval \
--tolerance 0.05
```
All enabled models:
```bash
PYTHONPATH=. python scripts/run_vlm_benchmark.py \
--truth-index output/chartbench_e_benchmark_plus/metadata/eval_subset.jsonl \
--dataset-root output/chartbench_e_benchmark_plus \
--models all \
--repeats 3 \
--max-workers 4 \
--max-retries 2 \
--timeout-seconds 120 \
--run-eval
```
Offline smoke test (no API call, sanity-only):
```bash
PYTHONPATH=. python scripts/run_vlm_benchmark.py \
--truth-index output/chartbench_e_benchmark_plus/metadata/eval_subset.jsonl \
--dataset-root output/chartbench_e_benchmark_plus \
--models gpt-5.2 \
--repeats 3 \
--max-samples 20 \
--run-eval \
--mock-from-truth
```
### Prompt A/B pilot
This pilot samples a 54-chart subset (18 chart types x 3 difficulty tiers x 1 sample), runs baseline vs. updated chart-type prompts, and writes a comparison report:
```bash
PYTHONPATH=. python scripts/run_prompt_ab_pilot.py \
--mock-from-truth
```
For real model runs, set provider credentials first and rerun without `--mock-from-truth`.
### Output structure
`output/bench_runs/{run_id}/`
- `run_config.json`
- `truth_subset.jsonl`
- `run_summary.json`
- `leaderboard.csv`
- `models/{model_key}/repeat_0x/pred.jsonl`
- `models/{model_key}/repeat_0x/report.json`
- `models/{model_key}/repeat_0x/failures.jsonl`
- `models/{model_key}/repeat_0x/raw_responses.jsonl`
- `models/{model_key}/repeat_0x/slice_report.json`
- `models/{model_key}/model_stability.json`
- `models/{model_key}/sample_stability.jsonl`
- `models/{model_key}/slice_summary.json`
Slicing coverage:
- `difficulty_tier` (L1-L4)
- `theme_domain`
- `axis_scale`
- `y_axis_truncated`
## Output structure (dataset)
- `images/*.png`: generated chart images.
- `metadata/index.jsonl`: full metadata with ground truth and challenge tags.
- `metadata/summary.json`: split and distribution summary.
- `metadata/eval_subset.jsonl`: fixed benchmark subset.