Self-Taught Reasoning and Self-Improvement
Generate, grade, keep, retrain. STaR, GRPO, AlphaEvolve and DGM loops, their numbers, and the evaluator traps.
- Concepts and terms
- Tasks and commands
- Annotated code
- Diagrams
- Comparisons
- Defaults and numbers
- Troubleshooting
- Questions and tips
Core ideas#
- STaR
- fine-tune on own rationales that reach correct answers. Repeat.
- Rationalization
- give the correct answer as a hint on failed problems.
- Constitutional AI
- the model critiques and revises against written principles.
- GRPO
- PPO with no value function. The group is the baseline.
- AlphaEvolve
- LLM edits programs. A machine-checkable evaluator scores them.
- DGM
- the agent edits its own scaffolding. A benchmark scores it.
- RSI
- system
S_nproposes the edit that makesS_{n+1}. - Answer-conditioned gradient
- the loop rewards final answers, not steps.
From Lesson 15.02, Lesson 10.09, Lesson 15.03, Lesson 15.04, Lesson 15.07
One recipe: generator plus evaluator#
From Lesson 15.03, Lesson 15.04, Lesson 10.09
STaR loop#
GRPO in the code#
def group_relative_advantage(rewards: list[float]) -> np.ndarray: r = np.array(rewards, dtype=float) if r.std() < 1e-8:same reward for all: no signal return np.zeros_like(r) return (r - r.mean()) / (r.std() + 1e-8)z-score in the groupratios = np.exp(policy_logprobs - ref_logprobs)unclipped = ratios * advantagesclipped = np.clip(ratios, 1 - clip_eps, 1 + clip_eps) * advantagespolicy_loss = -np.minimum(unclipped, clipped).mean()PPO clipped surrogatekl = (ref_logprobs - policy_logprobs).mean()total_loss = policy_loss + beta * klKL to the reference staysFrom 10.09 code/main.py
STaR family side by side#
| Factor | STaR | STaR + rationalization | V-STaR | Quiet-STaR |
|---|---|---|---|---|
| Training signal | keep (rationale, answer) if correct | above + correct-answer hinted retries | STaR + DPO verifier from both classes | per-token rationale + mixing weight |
| Inference cost | 1x | 1x | Nx (best-of-N) | 1.5-3x |
| Data waste | discards all incorrect rationales | less | minimal | minimal |
| Failure mode | shortcut rationales | rationalized rationales may be implausible | verifier can reinforce confident wrongness | still answer-conditioned gradient |
From Lesson 15.02
Code search and self-edit loops#
| Factor | AlphaEvolve | Darwin Godel Machine | Godel Machine (2003) |
|---|---|---|---|
| Edit target | A program in a database | The agent scaffolding | Any self-modification |
| Evaluator | correctness + benchmark | SWE-bench / Polyglot | Formal proof |
| Acceptance rule | Score beats the cell incumbent | empirical score delta + archive | formal proof of net benefit |
| Example win | 48-mul 4x4 matmul | 20% → 50% SWE-bench | no known non-trivial instance |
| Failure mode | Reward hacking on a weak evaluator | accepts reward-hacked variants | never triggers |
Run the simulators#
| Task | Code |
|---|---|
| One GRPO round with rule rewards | self_improvement_round(prompts, |
| Combined rule reward | reward_math(prompt, |
| Bootstrap STaR rounds | run_star(rounds, |
| AlphaEvolve with held-out test | run_loop(generations= |
| AlphaEvolve train-only demo | python code/ |
| DGM with the scorer open | python code/ |
| RSI race, gap threshold 2.0 | python code/ |
| RSI scenario A | Config(r_c= |
From 10.09 code/main.py, 15.02 code/main.py, 15.03 code/main.py, 15.04 code/main.py, 15.07 code/main.py
Defaults in the code#
| Setting | Default | Note |
|---|---|---|
grpo_step(beta) | 0.01 | KL weight |
grpo_step(clip_eps) | 0.2 | Ratio clip |
self_improvement_round(group_size) | 8 | Samples per prompt |
star_round(n_samples) | 1000 | Traces per round |
--threshold | 1.5 | Pause gap C - A |
--seed | DEFAULT_SEED | 11 in the RSI sim |
star_round alpha | 0.6 | Weight of kept traces |
From 10.09 code/main.py, 15.02 code/main.py, 15.07 code/main.py, 15.04 code/main.py
Troubleshooting#
| Symptom | Cause | Fix |
|---|---|---|
| Reward std falls to zero | Mode collapse | Stop the run |
| Lost diversity after 3-5 rounds | Self-generated data is narrower | Mix in fresh human data |
| Advantage zero for a prompt | Same reward in the whole group | Skip the prompt |
| Good in distribution, OOD breaks | Shortcut rationales kept | Process rewards and held-out OOD eval |
| Low train MSE, loose test MSE | Train-only evaluator | Held-out inputs made at eval time |
| Reported score above true score | Agent edits its scorer | Evaluator firewall |
| Gap C - A crosses the threshold | Capability rate above alignment rate | Pause for human review |
From Lesson 10.09, Lesson 15.02, Lesson 15.03, Lesson 15.04, Lesson 15.07
Use X when#
- Pure CAI: subjective behavior such as tone, safety and refusal style.
- GRPO + ORM: verifiable tasks with sparse and binary reward.
- DPO on self-generated pairs: constitution makes pairs, DPO trains.
- Full RLHF: multi-objective tradeoffs a rule cannot express.
- AlphaEvolve: only where the evaluator is fast, deterministic and hard to game.
From Lesson 10.09, Lesson 15.03
Q&A#
- STaR gain on GSM8K?
- GPT-J went from 5.8% to 10.7%.
- DGM gains?
- SWE-bench 20.0% → 50.0%, Polyglot 14.2% → 30.7%.
- Alignment faking rate?
- 12% of basic tests, up to 78% after training it away.
- Can self-improvement add a capability?
- No. It amplifies signal already in the model.
- Healthy run curves?
- Mean reward up, std stable, KL bounded.
Glossary#
- ORM
- Outcome Reward Model. One reward on the final answer.
- PRM
- Process Reward Model. One reward for each step.
- RLAIF
- RL from AI Feedback. PPO or DPO on model preferences.
- SL-CAI
- stage 1 of CAI. SFT on (prompt, revised) pairs.
- MAP-elites
- grid keyed by feature vectors. Best variant per cell.
From Lesson 10.09, Lesson 15.03