Search

Search papers and lessons

STaR: Bootstrapping Reasoning With Reasoning

Eric Zelikman, Yuhuai Wu, Jesse Mu et al. · 2022

STaR teaches a language model to reason by sampling its own step-by-step rationales, keeping the ones that reach the right answer, and fine-tuning on them, repeating until the model improves.

On this page

  • Colour = topic mix
  • Calculus
  • Discrete math
  • Probability
  • Neural network basics
  • Linear algebra
  • Architectures
  • ReadReady to readNot yet

TL;DR

A language model answers a question better when it writes out its reasoning first, but writing good reasoning usually needs expensive human examples. STaR (Self-Taught Reasoner) removes most of that cost. The model writes a short rationale and an answer for each training question, keeps only the rationales whose answers are correct, and fine-tunes on them. For questions it failed, it is shown the correct answer as a hint and asked to write a rationale that leads to it, and those rationales are added too. Repeating this loop on GPT-J, a 6-billion-parameter model, lifted arithmetic accuracy to 89.5 percent and commonsense question answering to 72.5 percent using only a small set of hand-written examples.

Builds on: Chain-of-Thought Prompting, Fine-Tuning, Policy Gradient, Rejection Sampling · Leads to: none in the graph yet

Why it mattered

STaR showed that a model can teach itself to reason from a few examples and an answer key, with no step-by-step human solutions. That matters because the paper's previous options were both costly: hand-written rationale datasets, or few-shot prompts that did not change the model. The paper's own conclusion is that using examples without reasoning to bootstrap reasoning is a general approach. On GSM8K, direct answer training on GPT-J gave 5.8 percent accuracy, while STaR gave 10.7 percent. On CommonsenseQA, the 6-billion-parameter GPT-J model reached 72.5 percent after STaR training, close to the 73.0 percent of a fine-tuned GPT-3 that the paper describes as about 30 times larger.

The problem

Chain-of-thought prompting showed that a language model answers hard questions better when it writes intermediate steps, the "rationale", before the final answer. The catch is that the few-shot examples have to be written by people, and that Fine-Tuning on the answers alone does not teach the model to reason. A model fine-tuned to output only the answer learns to guess the answer, and its guesses on hard problems stay poor.

Two methods existed for teaching rationales. Fine-tuning on human rationales needs a large, expensive dataset. Few-shot prompting needs a handful of examples but does not change the model. STaR asks whether the model's own rationales, filtered by whether they are right, can serve as training data, so that each round of training makes the next round's rationales better.

The first version has a weakness. It only learns from questions it already answers correctly, so when it fails a question it gets no signal from that question at all. The rationalization step, described below, is the fix.

History

The paper's introduction notes that earlier work had shown rationales help language models, through scratchpads and few-shot chain-of-thought prompts, but that few-shot methods generally underperform models fine-tuned to predict answers directly on large datasets. STaR was posted to arXiv in March 2022 by Eric Zelikman, Yuhuai Wu, Jesse Mu and Noah Goodman. It took the chain-of-thought idea and asked whether the model could build its own training set from it. Its appeal is that it needs only a few examples and an answer key, and the paper argues the same sample-filter-fine-tune loop applies to any task with a checkable answer.

How it works

The method is a loop with four steps. Here is one pass on a tiny example. The question is "Ann has 3 apples and gets 2 more. How many apples does she have?", the correct answer is 5, and the prompt has a few worked examples.

  1. Sample a rationale. The base model reads the few-shot prompt, then the question, and writes a rationale and an answer. Suppose it writes "3 plus 2 is 5, so the answer is 5." The answer is correct, so this rationale is kept. Check: the answer matches the label 5.
  2. Filter by the answer. Each sampled rationale is kept only if its final answer equals the known correct answer, a rejection-sampling filter. A wrong answer, such as 6, is discarded, whatever its reasoning looked like. Check: the filter uses only the answer key, never a human-written rationale.
  3. Rationalize the failures. For each question the model got wrong, the correct answer is put into the prompt as a hint, and the model is asked to write a rationale that leads to it. This is the step that gives signal from failures. Check: the rationale is kept only if its answer is the correct one.
  4. Fine-tune from the base model and repeat. The base model is fine-tuned on the union of the kept rationales, then the loop starts again with the new model. The paper retrains from the original pretrained model each round, rather than continuing to train one model, which the paper says avoids overfitting.
flowchart TD
  A["Questions with answer labels"] --> B["Sample rationale and answer per question"]
  B --> C{"Answer correct?"}
  C -- yes --> D["Keep rationale"]
  C -- no --> E["Rerun with the correct answer as a hint"]
  E --> F{"Hinted answer correct?"}
  F -- yes --> D
  F -- no --> G["Discard"]
  D --> H["Fine-tune base model on kept rationales"]
  H --> B

The method has one job per step, and the expensive part is only the sampling. The model is never shown a correct rationale directly, except through the hint, which gives the answer but not the reasoning.

Example
Tiny: one question, one kept rationale

Question: "A box holds 4 pens. You add 1 pen. How many pens are in the box?" The label is 5.

  1. The model samples a rationale: "4 plus 1 is 5."
  2. Its answer is 5, which equals the label, so the rationale is kept.
  3. A second sample says "4 plus 1 is 6." Its answer is 6, which does not equal 5, so it is discarded.
  4. The round's training set now contains one correct rationale for this question.

Interpretation: the filter keeps a rationale because its final answer is right, not because the reasoning is elegant. A correct answer with a sloppy argument also passes, which is one of the limits discussed below.

Example
Standard: arithmetic with rationalization

The paper uses arithmetic problems that add two numbers of up to five digits. The paper's text reports that few-shot accuracy on 2-digit addition is under 1 percent. After one fine-tuning round on the model's rationalized scratchpads, it rose to 32 percent.

  1. Start: the few-shot model gets under 1 percent of 2-digit sums right, so there are almost no correct rationales to learn from. The plain loop has almost nothing to filter.
  2. Rationalization: the model is given the correct sum as a hint and writes a scratchpad, the step-by-step arithmetic, that ends at that sum. These scratchpads are kept, so the training set now has many more examples of the steps.
  3. Fine-tune from the base model on the union of the kept scratchpads.
  4. Result: 2-digit addition accuracy goes from under 1 percent to 32 percent after one round.
  5. Over 16 rounds, the overall accuracy on the arithmetic test set reaches 89.5 percent. A baseline trained on 10,000 examples without rationales for 5,000 steps reaches 76.3 percent.

Interpretation: rationalization turns failures into training data. The gain is largest where the model starts with almost no correct answers, which is where the plain loop has nothing to work with.

Example
Realistic: commonsense question answering, with the chance floor

CommonsenseQA has 5 answer choices, so a model that guesses at random is right about 20 percent of the time. The paper reports dev-set accuracy for GPT-J, a 6-billion-parameter model, in Table 1.

  1. GPT-J fine-tuned to output only the answer reaches 60.0 percent.
  2. STaR without rationalization reaches 68.8 percent, using 69.7 percent of the training questions.
  3. STaR with rationalization reaches 72.5 percent, using 86.7 percent of the training questions, counting the rationalized ones.
  4. The paper's GPT-3 fine-tuned baseline is 73.0 percent. A 137-billion-parameter LaMDA model prompted with chain-of-thought examples reaches 55.6 percent.
  5. The gap from the 60.0 baseline to 72.5 is 12.5 percentage points. Subtracting the 20 percent chance floor from each score shows the same ranking more clearly: 40.0 for the direct baseline, 52.5 for STaR with rationalization.

Try it: STaR without rationalization gets 68.8 percent and the direct GPT-J baseline gets 60.0 percent. How many percentage points does STaR gain over the direct baseline, and what is that as a fraction of the 40 points the direct baseline gains above chance? Answer: the gain is 8.8 points. The direct baseline is 40 points above the 20 percent chance floor, so 8.8 is 8.8 divided by 40, which is 0.22, or 22 percent of the headroom above chance.

The math

Definition (the model as a latent-variable model). Let MM be the language model and xx a question with answer yy. The model's probability of the answer can be written as a sum over rationales rr:

pM(y∣x)=∑rp(r∣x) p(y∣x,r)p_M(y \mid x) = \sum_{r} p(r \mid x) \, p(y \mid x, r)

Read it as: the model first picks a rationale rr for the question, then gives the answer given that rationale. The sum adds up all rationales that could be written.

Step 1 in symbols (sampling and the reward). The reward for a sampled pair (r^,y^)(\hat{r}, \hat{y}) is the indicator 1(y^=y)\mathbb{1}(\hat{y} = y), which is 1 when the answer is right and 0 otherwise. The expected total reward over a dataset of questions xix_i with answers yiy_i is

J(M)=∑iEr^i,y^i∼pM(⋅∣xi) 1(y^i=yi)J(M) = \sum_{i} \mathbb{E}_{\hat{r}_i, \hat{y}_i \sim p_M(\cdot \mid x_i)} \, \mathbb{1}(\hat{y}_i = y_i)

Here E\mathbb{E} is the average over the rationales and answers the model samples. The reward ignores the quality of the rationale and counts only the answer, which is why the filter in step 2 uses only the answer key.

Step 2 in symbols (the gradient). The standard log-derivative trick, the basis of Policy Gradient methods, gives the gradient of JJ:

∇J(M)=∑iEr^i,y^i∼pM(⋅∣xi)[1(y^i=yi) ∇log⁡pM(y^i,r^i∣xi)]\nabla J(M) = \sum_{i} \mathbb{E}_{\hat{r}_i, \hat{y}_i \sim p_M(\cdot \mid x_i)} \left[ \mathbb{1}(\hat{y}_i = y_i) \, \nabla \log p_M(\hat{y}_i, \hat{r}_i \mid x_i) \right]

The indicator multiplies each term, so every sampled rationale that gives a wrong answer contributes zero gradient. That is exactly the filter in step 2 of the walkthrough. The paper calls STaR an approximation to this objective, because it replaces the expectation with a greedy sample per question and takes several gradient steps on the same batch. The authors say that the link to the reinforcement-learning objective deserves further study.

Step 3 in symbols (rationalization). Let hint(xi,yi)\mathrm{hint}(x_i, y_i) be the prompt with the correct answer added. The rationalized sample is (r^irat,y^irat)∼M(hint(xi,yi))(\hat{r}^{\mathrm{rat}}_i, \hat{y}^{\mathrm{rat}}_i) \sim M(\mathrm{hint}(x_i, y_i)), and it is kept when y^irat=yi\hat{y}^{\mathrm{rat}}_i = y_i. The training set for round nn is then the union of the correctly answered rationales and these rationalized ones:

Dn={(xi,r^i,yi):y^i=yi}∪{(xi,r^irat,yi):y^i≠yi and y^irat=yi}\mathcal{D}_n = \{(x_i, \hat{r}_i, y_i) : \hat{y}_i = y_i\} \cup \{(x_i, \hat{r}^{\mathrm{rat}}_i, y_i) : \hat{y}_i \neq y_i \text{ and } \hat{y}^{\mathrm{rat}}_i = y_i\}

The first set is the filter of step 2. The second is the rationalization of step 3, restricted to the questions the model failed.

Step 4 in symbols (the outer loop). Let M0M_0 be the base model. For round n=1,…,Nn = 1, \ldots, N, the next model is Mn=train(M0,Dn)M_n = \mathrm{train}(M_0, \mathcal{D}_n), fine-tuned from the base model on the round's data. The paper's default starts with 40 fine-tuning steps and increases the number of steps by 20 percent each round; the arithmetic runs instead start at 300 steps and add 20 per iteration. After 16 iterations of the arithmetic runs, overall accuracy is 89.5 percent.

Results

Main findings, using the paper's numbers:

  • Arithmetic. After 16 rounds, overall accuracy on the arithmetic test set is 89.5 percent, against 76.3 percent for a baseline trained on 10,000 examples without rationales for 5,000 steps.
  • CommonsenseQA. Dev-set accuracy is 72.5 percent with rationalization and 68.8 percent without, against 60.0 percent for GPT-J fine-tuned to output only the answer. GPT-3 fine-tuned directly reaches 73.0 percent, and a 137-billion-parameter LaMDA prompted with chain-of-thought reaches 55.6 percent.
  • GSM8K. Test accuracy is 10.7 percent with rationalization and 10.1 percent without, against 5.8 percent for direct fine-tuning and 3.1 percent for few-shot chain-of-thought with GPT-J.
  • Rationale quality. In a crowdworker study on 10 questions, participants preferred STaR rationales over human-written ones 74 percent more often. The paper says this reflects how hard good human rationales are to elicit, not human-level generation.

Limits and tradeoffs

It is tempting to think that STaR teaches correct reasoning because it only keeps correct answers. In fact the filter checks the answer, not the reasoning. On multiple-choice questions with 5 options, a lucky guess with a wrong argument passes too. The paper observes this for CommonsenseQA, and its human preference study in Section 4.4 is a partial check, not proof of reasoning quality. Correct answers and good reasoning are correlated, but they are not the same thing.

It is tempting to think that more sampling at higher temperature will fix the lack of failure data. In practice the paper found it counterproductive. Higher-temperature samples are more often right for the wrong reasons, and training on them hurts generalisation, especially on structured tasks like arithmetic. Rationalization gives a cleaner route to hard examples, because the hint keeps the reasoning anchored to the answer.

It is tempting to think that few-shot examples are only needed at the start. The paper's Discussion says that including few-shot prompts during later sampling reduces "drift", where rationales slowly stop resembling the original style. Dropping them makes the loop faster but the style less consistent, so the choice depends on whether the goal is a fixed prompt style or training speed.

When to use STaR: when you have a verifiable answer for each training question, a base model that is good enough to produce some correct rationales, and no budget for human-written rationales. When not to use it: when the answer cannot be checked automatically, when the base model is so weak that almost nothing is kept, or when the output must follow a strict reasoning format that the sampling does not produce. Alternatives include training on human rationales directly, self-consistency (sampling many rationales and voting, with no training), and reward-model methods, which replace the answer check with a learned score.

Reading guide

Read the paper in this order, with the lessons each section needs:

Recap

  • Chain-of-thought prompting shows that writing a rationale before the answer helps, but the examples are expensive to write.
  • STaR samples rationales from the model, keeps those whose answer is correct, and fine-tunes from the base model on them.
  • Rationalization gives the correct answer as a hint for failed questions, so the loop gets training signal from failures too.
  • The method is an approximation to a policy-gradient objective whose reward is the correct answer, with the indicator acting as the filter.

Read next: Instruction Tuning and Reinforcement Learning from Human Feedback (RLHF) cover later ways to shape a model's outputs with preference signals.

Check yourself

QuestionIn STaR, why does the filter keep a rationale only when its final answer is correct, and what is the main risk of that choice?Show answer

The reward in the paper is the indicator that the answer is correct, so the filter uses only the answer key. The main risk is that a rationale with flawed reasoning can reach the right answer by chance, especially on multiple-choice tasks, and it is kept as if it were good reasoning.

QuestionA model answers 2 of 10 arithmetic questions correctly before rationalization. A hint-based pass rescues 3 of the 8 failures. How many questions have a kept rationale, and what fraction of the 10 is that?Show answer

The plain pass keeps 2. Rationalization keeps 3 more from the 8 failures, so 2 plus 3 equals 5 questions have a kept rationale. As a fraction of 10 that is 5 out of 10, or one half.

QuestionA 5-way multiple-choice model scores 60 percent. What is its accuracy above the chance floor, and how many points above chance is a model that scores 72.5 percent?Show answer

Chance is 1 in 5, which is 20 percent. The 60 percent model is 40 points above chance. The 72.5 percent model is 52.5 points above chance.

QuestionWhy does the paper retrain from the base model in each round instead of continuing to fine-tune the latest model?Show answer

The paper states that it retrains from the initial pretrained model every time it runs a fine-tuning iteration. Training from the base model on each round's filtered data keeps every round starting from the same point. The paper notes this also makes some effects, such as how much rationalized examples contribute, hard to measure directly. It is a design choice the paper made, not a result it proved is best.

Sources

Read the full paper

Eric Zelikman, Yuhuai Wu, Jesse Mu et al., 2022. arXiv:2203.14465