StepProbe / README.md
Akiyue's picture
Add files using upload-large-folder tool
1e59964 verified
|
Raw
History Blame Contribute Delete
6.1 kB
# StepProbe 🔬
**Step-Level Diagnosis of Reasoning under Weight Quantization, with Diagnosis-Driven Interventions**
> Where exactly does reasoning break when you quantize a thinking model?
This repository hosts the code, paper, and released experiment artefacts for
the manuscript:
> *StepProbe: Step-Level Diagnosis of Reasoning under Weight Quantization,
> with Diagnosis-Driven Interventions*
> Tran Huy Hoang Son. Submitted to *Neurocomputing*, 2026.
The full PDF lives at [`paper/main.pdf`](paper/main.pdf); the LaTeX source,
the highlights file, and the two appendices (LLM-judge prompts and
qualitative error-type examples) are under [`paper/`](paper/).
## What StepProbe does
StepProbe is a diagnostic-plus-intervention framework that answers three
questions about quantized reasoning LLMs:
1. **Where** in the chain-of-thought does reasoning first fail?
2. **What type** of error dominates at each bit-width?
3. **Can we fix it** with minimal, diagnosis-driven intervention?
The framework introduces three step-level metrics:
| Metric | Meaning |
|---|---|
| **FFS** — First Failure Step | Step index where the quantized chain first diverges |
| **ECR** — Error Cascade Rate | Fraction of post-FFS steps that are also incorrect |
| **SSR** — Step Survival Rate | Probability that the chain is still correct at depth d |
…plus a 4-way error-type taxonomy (conceptual / methodological / executional /
logical), and two downstream interventions (targeted QLoRA fine-tuning;
training-free FP16 prompt-prefix injection).
## Headline findings (paper §5)
- **>85% of failed traces fail in the first three reasoning steps**
damage is concentrated at the chain's *opening*, not distributed evenly.
- **Conditional cascade rate >0.90** on the harder benchmarks (MATH-500,
GPQA-Diamond): once a quantized chain breaks, it almost never recovers.
- **Methodological errors dominate**, not conceptual: under GPT-4o-mini
re-classification, methodological accounts for 54–60% of failed steps;
conceptual is only ~9%.
- **Targeted QLoRA recovers up to +7.6 pp** on Qwen-family cells; the
diagnosed-vs-random selection gap is +1.8 pp (significant; honestly
reported as small relative to the overall recovery).
- **Training-free prompt-prefix injection adds +7.6 pp at k=4** under a
leak-controlled ablation, matching the QLoRA comparator at k=2.
## Repository layout
```
StepProbe/
├── paper/ # LaTeX manuscript + highlights + form
│ ├── main.tex # Source (elsarticle, Neurocomputing target)
│ ├── main.pdf # Compiled paper (44 pp)
│ ├── highlights.txt # Editorial-Manager highlights file (5 bullets)
│ └── references.bib # 38 references
├── stepprobe/ # Core package
│ ├── segment.py # CoT step segmentation (rule-based)
│ ├── align.py # DTW step alignment
│ ├── diagnose.py # Per-step scoring + LLM-judge prompts
│ ├── metrics.py # FFS / ECR / SSR computation
│ └── restore.py # QLoRA targeted fine-tuning
├── scripts/ # Top-level runners and figure generators
│ ├── run_inference.py
│ ├── run_eval.py
│ ├── compute_ci.py # Bootstrap CIs + paired sig tests
│ ├── eval_accuracy.py
│ ├── make_paper_figures.py # Figs 1, 2, 3, 4, 5, 11–13 + Table 4
│ ├── make_ablation_figure.py # Fig 9
│ ├── make_baselines_figure.py# Fig 10
│ ├── make_lr_sweep_figure.py # Fig 12
│ ├── make_multi_seed_figure.py# Fig 13
│ ├── make_prefix_injection_figure.py # Fig 14
│ ├── rediagnose_error_types.py
│ └── validate_classifier.py
├── run_*.sh # Experiment launchers (one per ablation)
├── configs/default.yaml
├── requirements.txt
└── figures/paper/ # Final figure PDFs referenced by main.tex
```
## Reproducing the paper
The released `results/` and `logs/` directories are *not* in this repository
(too large for git). To reproduce from scratch you need a single 24-GB GPU
and roughly 24 hours of compute.
```bash
# 0. Install dependencies
pip install -r requirements.txt
# 1. Main matrix (Table 4): 4 models × 3 benchmarks × 6 conditions
bash run_all.sh
# 2. Ablation: silver-bullet dataset size N (Table 5)
bash run_ablation.sh
# 3. Sampling-strategy baselines (Table 6)
bash run_baselines.sh
# 4. Llama LR sweep (Fig 12)
bash run_llama_lr_sweep.sh
# 5. Multi-seed robustness (Fig 13)
bash run_multi_seed.sh
# 6. Prompt-prefix injection (Fig 14, Table 7)
bash run_prompt_prefix.sh
# 7. Render all paper figures + tables from results/metrics/
python scripts/make_paper_figures.py --metrics results/metrics \
--output figures/paper --primary-model r1-qwen-7b \
--primary-benchmark math500
```
The full paper PDF rebuilds with:
```bash
cd paper && tectonic main.tex # or: latexmk -pdf main.tex
```
## Quick demo (no GPU required)
For a 20-problem dry run on a small model:
```bash
python scripts/run_eval.py \
--model deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B \
--benchmark gsm8k --quant-methods bnb_nf4 --quick
```
## Models, benchmarks, quantization
**Models tested in the paper** (24-GB-VRAM-friendly in 4-bit):
- DeepSeek-R1-Distill-Qwen-{1.5B, 7B, 14B}
- DeepSeek-R1-Distill-Llama-8B
- Qwen2.5-7B-Instruct (non-reasoning control / primary intervention cell)
**Quantization methods**: AWQ, GPTQ, BitsAndBytes NF4
(SmoothQuant supported but not part of the main matrix.)
**Benchmarks**: GSM8K, MATH-500, GPQA-Diamond.
## Hardware
All experiments ran on a single NVIDIA RTX 3090 Ti (24 GB).
## Citing
If you use StepProbe, please cite the paper:
```bibtex
@article{son2026stepprobe,
title = {StepProbe: Step-Level Diagnosis of Reasoning under Weight
Quantization, with Diagnosis-Driven Interventions},
author = {Tran Huy Hoang Son},
journal= {Neurocomputing},
year = {2026},
note = {Under review}
}
```
## License
MIT — see [`LICENSE`](LICENSE).