Cheat sheets

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

Source

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_n proposes the edit that makes S_{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#

samplescorekeep bestselectnext roundmodelGeneratorLLM, policy or agentCandidatesG samples or variantsprocessEvaluatorrule, test or benchmarkstoreArchiveMAP-elites, score keyedgpuRetrain or parentSFT, GRPO or mutateclientHuman datasmall fractionsamplescorekeep bestselectnext roundmodelGeneratorLLM, policy oragentCandidatesG samples orvariantsprocessEvaluatorrule, test orbenchmarkstoreArchiveMAP-elites, scorekeyedgpuRetrain or parentSFT, GRPO or mutateclientHuman datasmall fraction

From Lesson 15.03, Lesson 15.04, Lesson 10.09

STaR loop#

1Modelsamples a reasoning trace plus answer for eachproblem.2Filterkeeps the trace only if the final answer iscorrect.3Rationalizeon failed problems, hints the correct answer andsamples again.4Fine-tunetrains on the kept and rationalized traces.5Repeatthe next round uses the new model.6V-STaRtrains a DPO verifier on correct and incorrecttraces. Picks best-of-N.

From Lesson 15.02, 15.02 code/main.py

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 group
ratios = np.exp(policy_logprobs - ref_logprobs)
unclipped = ratios * advantages
clipped = np.clip(ratios, 1 - clip_eps, 1 + clip_eps) * advantages
policy_loss = -np.minimum(unclipped, clipped).mean()PPO clipped surrogate
kl = (ref_logprobs - policy_logprobs).mean()
total_loss = policy_loss + beta * klKL to the reference stays

From 10.09 code/main.py

STaR family side by side#

FactorSTaRSTaR + rationalizationV-STaRQuiet-STaR
Training signalkeep (rationale, answer) if correctabove + correct-answer hinted retriesSTaR + DPO verifier from both classesper-token rationale + mixing weight
Inference cost1x1xNx (best-of-N)1.5-3x
Data wastediscards all incorrect rationaleslessminimalminimal
Failure modeshortcut rationalesrationalized rationales may be implausibleverifier can reinforce confident wrongnessstill answer-conditioned gradient

From Lesson 15.02

Code search and self-edit loops#

FactorAlphaEvolveDarwin Godel MachineGodel Machine (2003)
Edit targetA program in a databaseThe agent scaffoldingAny self-modification
Evaluatorcorrectness + benchmarkSWE-bench / PolyglotFormal proof
Acceptance ruleScore beats the cell incumbentempirical score delta + archiveformal proof of net benefit
Example win48-mul 4x4 matmul20% → 50% SWE-benchno known non-trivial instance
Failure modeReward hacking on a weak evaluatoraccepts reward-hacked variantsnever triggers

From Lesson 15.03, 15.03 code/main.py, Lesson 15.04

Run the simulators#

TaskCode
One GRPO round with rule rewardsself_improvement_round(prompts, sampler, group_size=group_size)
Combined rule rewardreward_math(prompt, response) + 0.1 * reward_format(response)
Bootstrap STaR roundsrun_star(rounds, initial)
AlphaEvolve with held-out testrun_loop(generations=1500, pop=20, use_holdout=True, seed=DEFAULT_SEED)
AlphaEvolve train-only demopython code/main.py --no-holdout
DGM with the scorer openpython code/main.py --reward-hack-allowed
RSI race, gap threshold 2.0python code/main.py --threshold 2.0
RSI scenario AConfig(r_c=1.15, r_a=1.08, noise_c=0.02, noise_a=0.03, threshold=th)

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#

SettingDefaultNote
grpo_step(beta)0.01KL weight
grpo_step(clip_eps)0.2Ratio clip
self_improvement_round(group_size)8Samples per prompt
star_round(n_samples)1000Traces per round
--threshold1.5Pause gap C - A
--seedDEFAULT_SEED11 in the RSI sim
star_round alpha0.6Weight 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#

SymptomCauseFix
Reward std falls to zeroMode collapseStop the run
Lost diversity after 3-5 roundsSelf-generated data is narrowerMix in fresh human data
Advantage zero for a promptSame reward in the whole groupSkip the prompt
Good in distribution, OOD breaksShortcut rationales keptProcess rewards and held-out OOD eval
Low train MSE, loose test MSETrain-only evaluatorHeld-out inputs made at eval time
Reported score above true scoreAgent edits its scorerEvaluator firewall
Gap C - A crosses the thresholdCapability rate above alignment ratePause 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.

From Lesson 15.02, Lesson 15.04, Lesson 15.07, Lesson 10.09

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