Search

Search papers and lessons

Scaling Instruction-Finetuned Language Models

Hyung Won Chung, Le Hou, Shayne Longpre et al. · 2022

Chung et al. (2022) finetune language models on 1,836 tasks written as instructions, adding chain-of-thought data, and show that the gains grow with the number of tasks and the model size.

On this page

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

TL;DR

Instruction finetuning trains a pretrained language model on many tasks, each written as a plain-language instruction with a good answer. Chung et al. (2022) scale this in three ways: more tasks (1,836 in total), bigger models, and training examples that include written-out chain-of-thought reasoning. The resulting Flan models generalise to tasks they never saw, and Flan-PaLM 540B reaches 75.2% on five-shot MMLU when it is also given chain-of-thought prompts and self-consistency.

Builds on: Instruction Tuning, Chain-of-Thought Prompting, Neural Scaling Laws · Leads to: In-Context Learning, Self-Consistency Improves Chain of Thought Reasoning in Language Models

Why it mattered

Earlier studies had shown that instruction finetuning helps on unseen tasks, but the paper notes that they mostly evaluated held-out NLP tasks, and that the models were generally too small for successful chain-of-thought reasoning. This paper tested the method across three model families (PaLM, T5 and U-PaLM), several prompting setups (zero-shot, few-shot and chain-of-thought), and several benchmark suites. The abstract reports that Flan-PaLM 540B, instruction-finetuned on 1.8K tasks, beats PaLM 540B by 9.4% on average.

The paper also gave the community usable artefacts. The authors publicly released Flan-T5 checkpoints, and they report that these achieve strong few-shot performance even compared with much larger models, such as PaLM 62B.

The problem

A pretrained Language Model predicts the next token from its training text. That is not the same as following a request. Earlier work had shown that finetuning on a collection of instruction-formatted datasets improves performance on held-out tasks, and it reduces the need for few-shot examples in the prompt. Three questions were open. Does this keep improving as the number of tasks and the model size grow? Does it help or hurt reasoning, given that chain-of-thought prompting needs the model to write out steps? And does it hold across different model architectures and training objectives?

The paper's own framing is that the answers have to be measured on tasks the model was not finetuned on. Otherwise a gain can just be memorisation. The authors therefore hold out whole benchmarks, such as MMLU, BBH, TyDiQA and MGSM, from the finetuning data.

How it works

The paper's method is a finetuning procedure, which the authors call Flan. Here is one training example traced from start to finish, with invented wording.

flowchart LR
  A[Task written as an instruction] --> B[Mix with other tasks]
  B --> C[Pack examples into sequences]
  C --> D[Finetune with Adafactor]
  D --> E[Choose checkpoint on held-out tasks]
  E --> F[Test on unseen benchmarks]
  1. Start with a task. Suppose the dataset is a translation task, and one template reads: "Translate to French: cat." The target answer is "chat."
  2. Give each task several templates. The paper writes about ten templates per chain-of-thought dataset, and it uses the templates supplied by each source mixture for the rest.
  3. Mix the tasks. The paper combines four mixtures: Muffin (80 tasks), T0-SF (193), NIV2 (1,554) and a chain-of-thought mixture of nine datasets. Together they make 1,836 tasks, and the CoT mixture is the only part with reasoning written out.
  4. Pack several examples into one training sequence, separating inputs from targets with an end-of-sequence token and masking attention across example boundaries, so that one example cannot see another.
  5. Finetune with a constant learning rate and the Adafactor optimizer. Each model gets its own learning rate, batch size, dropout and step count, and everything else is shared across model sizes.
  6. Pick one checkpoint for each model. The authors evaluate every 2,000 to 10,000 steps on the held-out tasks and keep the best step.
  7. Evaluate on benchmarks whose tasks never appeared in the mixture. The output is a score per benchmark and a normalised average over six sub-scores.

The paper stresses that the finetuning compute is small. For Flan-PaLM 540B it is 0.2% of pretraining compute, which the authors estimate at about 512 TPU v4 chips for 37 hours.

The math

The paper's math is a normalisation rule and a scaling observation, not a model. Accuracy on a multiple-choice task is not comparable across tasks with different chance levels, so the paper rescales each score against a random-guessing baseline. The paper gives the rule through an example: if random guessing gets 50% and the maximum is 100%, then a raw accuracy of 55% becomes 10%, and a raw accuracy of 45% becomes minus 10%, because it is worse than random.

The normalised score (step 7 in symbols)

Write aa for the raw accuracy, aranda_{\text{rand}} for the random-guessing accuracy, and take the maximum to be 100%. The rule that reproduces the paper's example is

s=100⋅a−arand100−arand.s = 100 \cdot \frac{a - a_{\text{rand}}}{100 - a_{\text{rand}}}.

Check it on the example: a=55a = 55 and arand=50a_{\text{rand}} = 50 give s=100⋅5/50=10s = 100 \cdot 5 / 50 = 10, and a=45a = 45 gives s=−10s = -10. The paper's normalised average is the macro-average of six such scores: MMLU-direct, MMLU-CoT, BBH-direct, BBH-CoT, TyDiQA-direct and MGSM-CoT.

Scaling gains

Let NN be the number of finetuning tasks and PP the number of model parameters. The paper's main observation is that the gain Δ(N,P)\Delta(N, P) from instruction finetuning is positive and grows with both, but that most of the growth in NN comes early. The paper reports that most of the improvement comes from using up to 282 tasks, and that scaling model size by an order of magnitude improves both finetuned and non-finetuned models substantially.

Worked examples

Example
Tiny: a hypothetical normalised score
  1. A task has four answer choices, so random guessing is 25%.
  2. A model scores 40% raw accuracy.
  3. Apply the rule with a=40a = 40 and arand=25a_{\text{rand}} = 25.
  4. The numerator is 40−25=1540 - 25 = 15.
  5. The denominator is 100−25=75100 - 25 = 75.
  6. The normalised score is 100⋅15/75=20100 \cdot 15 / 75 = 20.
Example
Standard: the 540B row of Table 3
  1. Table 3 reports the normalised average for PaLM 540B with no finetuning as 49.1.
  2. With all four mixtures, 1,836 tasks in total, the same model reaches 58.5.
  3. The gain is 58.5−49.1=9.458.5 - 49.1 = 9.4 points, which matches the table's "(+9.4)" entry and the abstract's figure.
  4. The same table shows a larger absolute gain for the 8B model. Its normalised average goes from 6.4 to 21.9, a gain of 15.5.
  5. So finetuning helps both sizes. In absolute points it helps the smaller model more.
Example
Realistic: reasoning with and without the CoT mixture
  1. Table 4 reports MMLU for PaLM 540B and Flan-PaLM 540B under chain-of-thought prompting.
  2. PaLM 540B with CoT prompting scores 64.5, and Flan-PaLM 540B with CoT prompting scores 70.2.
  3. Compute the gain in points for chain-of-thought prompting on MMLU.

Try it: what is the gain? Answer: 70.2−64.5=5.770.2 - 64.5 = 5.7 points. The same 5.7-point gap appears with self-consistency added, from 69.5 for PaLM to 75.2 for Flan-PaLM.

Results

Scale. Table 3 shows that more finetuning tasks help on most held-out benchmarks. Section 3 adds that the relative error reduction is larger for the 540B model (18.4%) than for the 8B model (16.6%), even though the absolute gain is larger for 8B. For PaLM 540B the normalised average rises from 49.1 with no finetuning to 58.5 with 1,836 tasks. The paper explains the flattening after 282 tasks in two ways. The added tasks may not be diverse enough to teach new knowledge, or most of the gain may come from the model expressing knowledge it already has from pretraining.

Chain-of-thought data. Table 4 gives Flan-PaLM 540B 75.2% on MMLU with CoT and self-consistency, 78.4 on BBH-NLP, and 72.0 on MGSM. The ablation in Section 4.2 shows that finetuning on instruction data without CoT examples lowers CoT performance on held-out benchmarks, and that including the nine CoT datasets keeps it. The paper's reading is that instruction tuning helps unseen tasks only in the same prompting paradigm as the training tasks.

Smaller models. The Flan-T5 family, from 80M to 11B parameters, improves a lot on the same benchmarks. The paper reports that Flan-T5-XL, with 3B parameters, reaches an MMLU score of 52.4% with direct prompting. The paper's Table 1 lists 43.9% as the 5-shot MMLU score of GPT-3, so the small model is ahead of it on that benchmark.

Open-ended use. In a human evaluation on 190 open-ended evaluation examples, raters preferred Flan-PaLM responses over PaLM 79% of the time, and the preference was largest in the zero-shot settings.

Limits. The authors are candid that Flan-PaLM does not beat specialised systems everywhere. On the symbolic BBH-algo tasks it does not outperform code-davinci-002 even with CoT and self-consistency. On TyDiQA it is still below ByT5 finetuned on the TyDiQA training set. The GSM8K result of 83.9% is for a model whose instruction mixture includes GSM8K training data, so it is not a clean held-out number.

Common mistakes

It is tempting to think that instruction tuning always helps reasoning. In fact the paper shows that finetuning on instruction data without any chain-of-thought examples degrades chain-of-thought performance, so the reasoning data is needed to keep it.

It is tempting to think that Flan is a new model architecture. In fact Flan is a finetuning procedure applied to existing models such as PaLM, T5 and U-PaLM, and the paper's Table 5 shows it applied to all of them.

It is tempting to think that more tasks always means more gain. In fact the paper's own explanation of the flattening after 282 tasks suggests that the extra tasks may add little new knowledge.

When to use it: when a pretrained model needs to follow instructions across many tasks and its reasoning must survive finetuning. When not to use it: when the target is a single narrow task that a dedicated finetune already solves, or when the instruction data cannot be reliably kept separate from the evaluation benchmarks. Alternatives: Fine-Tuning on one task, In-Context Learning with examples in the prompt, and Training Language Models to Follow Instructions with Human Feedback, which uses human demonstrations and preference data.

Reading guide

Check yourself

QuestionName the three things the paper scales when it instruction-finetunes a model.Show answer

The number of finetuning tasks, the model size, and the inclusion of chain-of-thought data in the finetuning mixture. The paper's abstract lists them as scaling the number of tasks, scaling the model size, and finetuning on chain-of-thought data.

QuestionUsing the paper's rule, a model with 50% random-guess accuracy and a raw accuracy of 60% gets what normalised score?Show answer

Apply s=100⋅(a−arand)/(100−arand)s = 100 \cdot (a - a_{\text{rand}}) / (100 - a_{\text{rand}}) with a=60a = 60 and arand=50a_{\text{rand}} = 50. The numerator is 10 and the denominator is 50, so s=100⋅10/50=20s = 100 \cdot 10 / 50 = 20.

QuestionWhy does the paper argue that finetuning without any chain-of-thought examples can hurt a model's reasoning, even though instruction tuning usually helps on unseen tasks?Show answer

The paper argues that instruction tuning improves unseen tasks when they are in the same prompting paradigm as the training tasks. Finetuning on non-CoT data alone teaches the model to answer directly, so chain-of-thought performance on held-out reasoning benchmarks falls. Including just nine CoT datasets keeps the reasoning ability and improves it.

QuestionA team wants to instruction-finetune a 540B model for a fraction of its pretraining budget. Using the paper's numbers, what share of pretraining compute does the paper report for Flan-PaLM 540B, and what does that suggest?Show answer

The paper reports 0.2% of the pretraining compute, about 512 TPU v4 chips for 37 hours. The suggestion is that instruction finetuning is cheap relative to pretraining, so the gains come from using compute that is small compared with the original training run.

Sources

Read the full paper

Hyung Won Chung, Le Hou, Shayne Longpre et al., 2022. arXiv:2210.11416