A Multi-Stage Reinforcement Learning Pipeline with Targeted Failure Repair
Joseph Li · Max Rodriguez · Victor Chen — Stanford University Stanford CS224N: Natural Language Processing with Deep Learning
Paper in progress. Full manuscript available upon request.
We train a 0.5B-parameter model (Qwen2.5-0.5B-Instruct) to solve competition-level math problems using reinforcement learning from verifiable rewards alone — no teacher model, no synthetic reasoning traces. Our three-stage pipeline achieves 20.8% overall accuracy on the Hendrycks MATH algebra benchmark, surpassing a knowledge-distilled baseline (20.3%) that requires a 32B teacher model.
On Level 1 algebra problems, the final model reaches 56.3% accuracy — a +21.5 point improvement over SFT alone.
| Model | Overall | Level 1 | Level 2 | Level 3 | \boxed{} Rate |
|---|---|---|---|---|---|
| SFT (warmstart) | 14.6% | 34.8% | 21.9% | 15.3% | 83.3% |
| + GRPO | 17.5% | 45.2% | 26.4% | 16.1% | 96.9% |
| + Targeted DAPO | 20.8% | 56.3% | 32.3% | 22.2% | 95.3% |
| + ThinkPRM (N=8)* | 27.0% | — | — | — | 100.0% |
| Knowledge-distilled baseline | 20.3% | — | — | — | 70.9% |
ThinkPRM evaluated on 100 examples due to compute cost.
See RESULTS.md for full tables, per-level breakdowns, and CaSE reasoning quality scores.
Qwen2.5-0.5B-Instruct (base)
│
▼
┌─────────────────────┐
│ Stage 1: SFT │ Full-weight fine-tuning on ground-truth solutions.
└─────────┬───────────┘ Establishes math notation, formatting, \boxed{} convention.
│ 14.6% accuracy
▼
┌─────────────────────┐
│ Stage 2: GRPO │ Self-play RL with verifiable answer-correctness rewards.
└─────────┬───────────┘ Group size G=8, KL coeff 0.005, entropy bonus 0.01.
│ +2.9% from self-generated exploration
▼
┌──────────────────────────────┐
│ Failure Detection │ Sample 8 completions per problem:
└─────────┬────────────────────┘ mastered (8/8) · borderline (1–7/8) · hard fail (0/8)
▼
┌─────────────────────────────────────────────────────┐
│ Stage 3: Targeted DAPO Repair │ DAPO on failures + borderline only.
└─────────────────────────────────────────────────────┘ LoRA r=16, 30% replay buffer.
│ +3.3% by concentrating compute on frontier problems
▼
Final model: 20.8% — surpasses distillation without any teacher
At inference time, pairing the final model with a compact ThinkPRM verifier (Best-of-8 selection) further boosts accuracy to 27.0% (+6.2 points at no additional training cost).
CS224n/
├── pipeline/ # Three-stage RL training: SFT → GRPO → Targeted DAPO Repair [§4.1]
├── distillation/ # Knowledge-distillation baseline (Gemini 2.5-Flash teacher) [§4.3]
├── verification/ # ThinkPRM and RM-R1 process reward model training [§4.2]
├── evaluation/ # Best-of-N selection, CaSE reasoning quality, verifier compare [§5–6]
├── data/ # Hendrycks MATH stratified splits and dataset scripts [§5]
└── utils/ # Shared Google Cloud Storage utilities
| Directory | Paper Section | Description |
|---|---|---|
pipeline/ | §4.1 | SFT → GRPO → Targeted DAPO, the core contribution |
distillation/ | §4.3 | Knowledge-distillation baseline to compare against |
verification/ | §4.2 | ThinkPRM + RM-R1 verifier training |
evaluation/ | §5–6 | Accuracy, CaSE reasoning quality, Best-of-N |
data/ | §5 | Algebra MATH splits (1,744 train / 1,187 test) |
RESULTS.md | §5.2, §6 | All tables and figures from the paper |
# 1. Environment
conda env create -f environment.yml # macOS (development)
conda env create -f environment.linux.yml # Linux/GPU (training)
conda activate cs224n
# 2. Cloud compute
pip install modal && modal setup
# 3. Run the full RL pipeline (~4.8 hours on one A100-80GB)
modal run pipeline/trainers/modal_train_targeted.py --run-tag v1
# 4. Evaluate
modal run pipeline/eval/modal_eval_dapo_algebra.py --run-tag v1
# 5. Best-of-N with ThinkPRM verifier
conda run -n cs224n python evaluation/best_of_n/Best_of_N_selection_eval.py \
--dapo_model_path <checkpoint> \
--thinkprm_model_path <verifier_checkpoint> \
--num_candidates 8
Several choices that are routine at larger scales become critical at 0.5B parameters:
| Decision | What we found |
|---|---|
| Full-weight SFT + GRPO | LoRA further constrains already-limited capacity; full-weight is necessary for stages 1–2 |
| Group size G=8 | With G=4, ~40% of groups are degenerate (all-same reward); G=8 reduces this to <20% |
| KL coefficient 0.005 | 10× lower than typical RLHF; per-sequence KL at 512 tokens is inherently large at this scale |
| LoRA only in repair stage | Small failure dataset makes full-weight repair catastrophically forgetting |
| Replay buffer (30%) | Prevents the repair stage from erasing GRPO-learned capabilities |
This work is currently under development. If you find it useful, please check back for a citable version once the paper is finalized.
Joseph Li, Max Rodriguez, Victor Chen.
"Bootstrapping Reasoning in Compact Language Models:
A Multi-Stage Reinforcement Learning Pipeline with Targeted Failure Repair."
Stanford CS224N, 2026.
1 commits
Python
98.6%
Shell
1.0%
A Multi-Stage Reinforcement Learning Pipeline with Targeted Failure Repair
Joseph Li · Max Rodriguez · Victor Chen — Stanford University Stanford CS224N: Natural Language Processing with Deep Learning
Paper in progress. Full manuscript available upon request.
We train a 0.5B-parameter model (Qwen2.5-0.5B-Instruct) to solve competition-level math problems using reinforcement learning from verifiable rewards alone — no teacher model, no synthetic reasoning traces. Our three-stage pipeline achieves 20.8% overall accuracy on the Hendrycks MATH algebra benchmark, surpassing a knowledge-distilled baseline (20.3%) that requires a 32B teacher model.
On Level 1 algebra problems, the final model reaches 56.3% accuracy — a +21.5 point improvement over SFT alone.
| Model | Overall | Level 1 | Level 2 | Level 3 | \boxed{} Rate |
|---|---|---|---|---|---|
| SFT (warmstart) | 14.6% | 34.8% | 21.9% | 15.3% | 83.3% |
| + GRPO | 17.5% | 45.2% | 26.4% | 16.1% | 96.9% |
| + Targeted DAPO | 20.8% | 56.3% | 32.3% | 22.2% | 95.3% |
| + ThinkPRM (N=8)* | 27.0% | — | — | — | 100.0% |
| Knowledge-distilled baseline | 20.3% | — | — | — | 70.9% |
ThinkPRM evaluated on 100 examples due to compute cost.
See RESULTS.md for full tables, per-level breakdowns, and CaSE reasoning quality scores.
Qwen2.5-0.5B-Instruct (base)
│
▼
┌─────────────────────┐
│ Stage 1: SFT │ Full-weight fine-tuning on ground-truth solutions.
└─────────┬───────────┘ Establishes math notation, formatting, \boxed{} convention.
│ 14.6% accuracy
▼
┌─────────────────────┐
│ Stage 2: GRPO │ Self-play RL with verifiable answer-correctness rewards.
└─────────┬───────────┘ Group size G=8, KL coeff 0.005, entropy bonus 0.01.
│ +2.9% from self-generated exploration
▼
┌──────────────────────────────┐
│ Failure Detection │ Sample 8 completions per problem:
└─────────┬────────────────────┘ mastered (8/8) · borderline (1–7/8) · hard fail (0/8)
▼
┌─────────────────────────────────────────────────────┐
│ Stage 3: Targeted DAPO Repair │ DAPO on failures + borderline only.
└─────────────────────────────────────────────────────┘ LoRA r=16, 30% replay buffer.
│ +3.3% by concentrating compute on frontier problems
▼
Final model: 20.8% — surpasses distillation without any teacher
At inference time, pairing the final model with a compact ThinkPRM verifier (Best-of-8 selection) further boosts accuracy to 27.0% (+6.2 points at no additional training cost).
CS224n/
├── pipeline/ # Three-stage RL training: SFT → GRPO → Targeted DAPO Repair [§4.1]
├── distillation/ # Knowledge-distillation baseline (Gemini 2.5-Flash teacher) [§4.3]
├── verification/ # ThinkPRM and RM-R1 process reward model training [§4.2]
├── evaluation/ # Best-of-N selection, CaSE reasoning quality, verifier compare [§5–6]
├── data/ # Hendrycks MATH stratified splits and dataset scripts [§5]
└── utils/ # Shared Google Cloud Storage utilities
| Directory | Paper Section | Description |
|---|---|---|
pipeline/ | §4.1 | SFT → GRPO → Targeted DAPO, the core contribution |
distillation/ | §4.3 | Knowledge-distillation baseline to compare against |
verification/ | §4.2 | ThinkPRM + RM-R1 verifier training |
evaluation/ | §5–6 | Accuracy, CaSE reasoning quality, Best-of-N |
data/ | §5 | Algebra MATH splits (1,744 train / 1,187 test) |
RESULTS.md | §5.2, §6 | All tables and figures from the paper |
# 1. Environment
conda env create -f environment.yml # macOS (development)
conda env create -f environment.linux.yml # Linux/GPU (training)
conda activate cs224n
# 2. Cloud compute
pip install modal && modal setup
# 3. Run the full RL pipeline (~4.8 hours on one A100-80GB)
modal run pipeline/trainers/modal_train_targeted.py --run-tag v1
# 4. Evaluate
modal run pipeline/eval/modal_eval_dapo_algebra.py --run-tag v1
# 5. Best-of-N with ThinkPRM verifier
conda run -n cs224n python evaluation/best_of_n/Best_of_N_selection_eval.py \
--dapo_model_path <checkpoint> \
--thinkprm_model_path <verifier_checkpoint> \
--num_candidates 8
Several choices that are routine at larger scales become critical at 0.5B parameters:
| Decision | What we found |
|---|---|
| Full-weight SFT + GRPO | LoRA further constrains already-limited capacity; full-weight is necessary for stages 1–2 |
| Group size G=8 | With G=4, ~40% of groups are degenerate (all-same reward); G=8 reduces this to <20% |
| KL coefficient 0.005 | 10× lower than typical RLHF; per-sequence KL at 512 tokens is inherently large at this scale |
| LoRA only in repair stage | Small failure dataset makes full-weight repair catastrophically forgetting |
| Replay buffer (30%) | Prevents the repair stage from erasing GRPO-learned capabilities |
This work is currently under development. If you find it useful, please check back for a citable version once the paper is finalized.
Joseph Li, Max Rodriguez, Victor Chen.
"Bootstrapping Reasoning in Compact Language Models:
A Multi-Stage Reinforcement Learning Pipeline with Targeted Failure Repair."
Stanford CS224N, 2026.
1 commits
Python
98.6%
Shell
1.0%