---
title: "Chapter 13: Rejection Sampling"
description: "The simplest self-improvement method that works: sample k rollouts per task, keep the verified winners, train on them, redeploy, score."
type: lesson
order: 13
chapter: "05-the-flywheel"
---

# Chapter 13: Rejection Sampling

This is rejection sampling, sometimes called STaR (Self-Taught Reasoner) or expert iteration. It is the simplest self-improvement method that works, and coding is its best-case domain because the filter is free — your verifier from Part 4.

## The Loop

Sample **k = 4–8 rollouts per task** at temperature ~0.8. Keep every rollout that passes tests. One task can contribute several successful trajectories, each a different valid path — that diversity is a feature, not noise.

Train on the winners. Redeploy. Score.

Every piece already exists:

- Generation: the harness from [Chapter 07](/fine-tune-local-agent/03-trajectories/07-the-harness/)
- Verification: `eval.py`-style pass/fail from [Chapter 12](/fine-tune-local-agent/04-the-verifier/12-the-scoreboard/), populating `outcome`
- Filtering: a one-liner over trajectory JSONL
- Training: `make train` from [Chapter 06](/fine-tune-local-agent/02-the-pipeline/06-serve-and-automate/)
- Scoring: the held-out eval set — which the flywheel never trains on

## Watch For: The Plateau

**The loop plateaus.** After 2–3 rounds the model gets good at exactly the tasks it can already sometimes solve, and stops improving on the ones it never solves. Expected. The fix is harder tasks or a better base model, not more rounds.

## Exit Criteria for the Whole Flywheel

Round *n+1* scores higher than round *n* on held-out tasks, for at least two consecutive rounds, with no teacher in the loop.

---

[← Part 5 Index](/fine-tune-local-agent/05-the-flywheel/) · [Next: Chapter 14 →](/fine-tune-local-agent/05-the-flywheel/14-learning-from-failures/)
