Flan-T5-XL has 3 billion parameters and scores 52.4 on MMLU with no examples. The raw T5-XXL has 11 billion and scores 33.7. A short round of instruction tuning beat a model 3.7 times larger.
Pick a model, then ask it a question. Watch the raw model keep writing the document while the tuned one answers. Then we build, piece by piece, what Hyung Won Chung, Le Hou, Shayne Longpre and colleagues (Google Research, 2022) tuned on, how much, and why each ingredient matters.
You need what a language model is, fine-tuning basics and prompting. We build the rest from zero.
Pick a model and ask. Compare what each one writes with its MMLU score.
MMLU zero-shot scores are the values in the Chapter 4 table (T5-XXL 33.7, Flan-T5-XL 52.4, Flan-T5-XXL 57.2). The replies are an illustration of the behaviour Chapter 0 describes, not recorded model output.
Chapter 0
See why a model with all the knowledge still ignores your question, and what instruction tuning adds
You have pre-trained a massive language model: 540 billion parameters, trained on trillions of tokens. It can complete any text prompt with remarkable fluency. But ask it “What is the capital of France?” and instead of answering “Paris,” it might continue: “What is the capital of Germany? What is the capital of Italy?…” It writes more questions instead of an answer.
The problem is that pre-trained language models are text completers, not instruction followers. They learned to predict what text comes next. That differs from understanding what a human wants when they write a question. The pre-training data is mostly documents, articles and books, not question and answer pairs or task instructions.
Instruction tuning (also called instruction fine-tuning) is the process of fine-tuning a pre-trained model on a diverse mixture of tasks, each written as a natural language instruction. Task-specific fine-tuning builds one model per task. Instruction tuning teaches one model to follow instructions for any task.
The same prompt goes to a base model (a text completer) and an instruction-tuned model (an instruction follower). Press the button to cycle through three prompts.
The three exchanges are illustrations of the behaviour described in the text, not recorded outputs of a specific model.
Earlier work (FLAN, 2021; T0, 2021) had shown that instruction tuning works. But critical questions remained. How does performance scale with the number of tasks? Does it help to include chain-of-thought examples? What is the effect of model size? This paper answers all three, step by step.
Why do these questions matter in practice? Because the answers tell you how to spend your training budget. If more tasks always help, you should collect and format more tasks. If chain of thought helps, you should include reasoning traces. If larger models benefit more, you should save your instruction-tuning effort for your largest model. The paper gives data-driven answers to all of these allocation decisions.
The paper also introduces Flan-T5 and Flan-PaLM, the instruction-tuned versions of Google’s T5 and PaLM models. Flan-T5 in particular became one of the most widely used open-source models. It was the default instruction-following model for the research community until LLaMA-based models took over in mid-2023.
python # The instruction tuning pipeline (simplified) from transformers import T5ForConditionalGeneration # 1. Start with pre-trained model model = T5ForConditionalGeneration.from_pretrained("t5-xxl") # 2. Prepare instruction data: (instruction + input) → output # 1,836 tasks × multiple templates = millions of examples # 3. Fine-tune with standard seq2seq loss # 30K-40K steps, batch size 128, lr=1e-3 # Result: T5-XXL → Flan-T5-XXL # Key insight: only 30K-40K steps — about 1% of pre-training compute # This tiny investment yields 20+ point improvements on benchmarks
| Previous Work | Tasks | Model | Limitation |
|---|---|---|---|
| FLAN (2021) | 62 tasks | 137B | Small task collection, no CoT |
| T0 (2021) | 35 datasets | 11B | Smaller model, no scaling analysis |
| Flan-PaLM (this paper) | 1,836 tasks | 540B | Comprehensive scaling study |
Chapter 1
Build a mix of 1,836 tasks from four sources and learn how to sample it fairly
The paper’s first contribution is a massive instruction tuning dataset: 1,836 tasks collected from four sources, each written with multiple prompt templates.
| Source | Tasks | Description |
|---|---|---|
| Flan 2021 | 62 | Original FLAN tasks: NLI, QA, sentiment, translation, etc. |
| P3 (T0) | 35 datasets (~270 prompts) | PromptSource community templates with diverse prompt formats |
| Super-Natural Instructions | 757 | Crowdsourced tasks with detailed instructions and definitions |
| Chain-of-Thought collection | 9 datasets | Tasks requiring step-by-step reasoning (math, logic, commonsense) |
Each bar is one source, and its height is the number of tasks. Choose a source to light it up and read its share.
Bar heights are the headline counts in the table above. They do not sum to the paper’s 1,836 total, so the chart shows the relative size of the sources, not the whole collection.
Each task has up to 10 different prompt templates (instructions phrased in different ways). For example, a sentiment analysis task might have:
prompt templates # Template 1: "Classify the sentiment of the following review: {review}\nSentiment:" # Template 2: "Is the following review positive or negative?\n{review}\nAnswer:" # Template 3: "Read the review and determine if the author liked the product.\nReview: {review}\nLiked:" # Template 4: "What is the sentiment (positive/negative) of this text?\n{review}"
The 1,836 tasks differ hugely in size. Some have 100 examples, others have millions. How do you mix them? The paper uses temperature-based sampling:
Worked number, with K = 3,000 and T = 3. Take a task with 100 examples and a task with 3,000 or more. Their weights are 1001/3 ≈ 4.6 and 3,0001/3 ≈ 14.4. The big task is sampled about 3.1 times as often. At T = 1 it would be 30 times as often.
Four tasks of very different size, capped at K = 3,000. The bar is each task’s share of the mix. The tick shows the share it would get from raw size with no cap. Drag T and watch the small tasks come back.
Illustrative task sizes: 100, 1,000, 20,000 and 1,000,000 examples. The formula and the cap K = 3,000 are the ones in the code below.
Each training example is an (instruction, input, output) triple, formatted as a text-to-text problem:
example # Input to model: "Classify the sentiment of the following movie review.\n" "Review: This movie was absolutely terrible. The acting was wooden,\n" "the plot made no sense, and I wanted to leave after 20 minutes.\n" "Sentiment:" # Target output: "Negative"
The model is trained with the standard language modeling loss on the target output, conditioned on the instruction and input. This is the same as supervised fine-tuning (SFT). The only difference is the diversity of tasks.
Let’s be precise about the training loss. For encoder-decoder models (T5/PaLM), the input (instruction plus input text) is encoded, and the model generates the output one token at a time. The loss is computed only on the output tokens, not the input:
The model is not penalized for generating the wrong instruction. It is only penalized for generating the wrong response. The instruction serves as conditioning context.
python # Task sampling with temperature import numpy as np def sample_tasks(task_sizes, K=3000, T=3.0): """Temperature-based task sampling to balance task sizes""" capped = np.minimum(task_sizes, K) # cap at K examples weights = capped ** (1.0 / T) # temperature smoothing probs = weights / weights.sum() # normalize to probabilities return probs # T=1: proportional to size (big tasks dominate) # T=3: smoothed (standard choice — balanced) # T=∞: uniform (all tasks equally likely)
Chapter 2
Add tasks and parameters, and see which models gain the most
The paper’s central question: does performance keep improving as you add more instruction-tuning tasks? The answer is a resounding yes, and the scaling curve has not saturated at 1,836 tasks.
The authors ran a systematic ablation: start with a subset of tasks, add more step by step, and measure performance on held-out benchmarks. The key point is that they evaluate on held-out tasks, tasks NOT in the instruction tuning mixture. This tests generalization. Does the model learn to follow novel instructions, or does it just memorize the tasks it trained on?
The results show a clear log-linear relationship:
The x-axis is log-scaled. Drag the slider to add more tasks and watch the point ride the curve.
Illustrative curve: score = 55 + 8 × log10(tasks), drawn to show the log-linear shape the paper reports. It is not the paper’s measured line.
Instruction tuning was applied to PaLM at three scales (8B, 62B, 540B) and T5 at four scales (250M, 780M, 3B, 11B). The results show an interaction between model size and instruction tuning:
| Model | Before IT | After IT | Gain |
|---|---|---|---|
| PaLM 8B | 52.1 | 59.3 | +7.2 |
| PaLM 62B | 68.4 | 73.8 | +5.4 |
| PaLM 540B | 78.3 | 81.4 | +3.1 |
| T5 11B | 33.7 | 57.2 | +23.5 |
Three patterns emerge:
1. Instruction tuning helps all sizes. Even the 540B model improves meaningfully (+3.1 on average). This was not obvious. You might expect a 540B model to be so capable that instruction tuning is redundant. That it still helps shows that even the largest models do not learn to follow instructions from pre-training alone.
2. Relative improvement is larger for smaller models. T5-11B gains 23.5 points. Instruction tuning can partly make up for limited model capacity. The smaller model has the knowledge but needs more “steering” to use it well.
3. Absolute improvement is larger for larger models on hard tasks. Relative improvement falls with size, but the absolute gap on difficult reasoning tasks is larger for bigger models. This makes sense: reasoning ability grows with model size, and instruction tuning “unlocks” whatever reasoning capability the model already has.
python # The scaling interaction: model size × instruction tuning # Think of it as: Knowledge × Interface = Performance # # PaLM 8B: Limited knowledge × Great interface → Moderate performance # 52.1 × IT → 59.3 (relative gain: +14%) # # PaLM 540B: Vast knowledge × Great interface → Excellent performance # 78.3 × IT → 81.4 (relative gain: +4%) # # The interface improvement is similar in both cases. # But the smaller model benefits more because its knowledge/interface # ratio was more imbalanced — it "knew" more than it could express.
Why does instruction tuning help smaller models more in relative terms? Smith and Ivison’s later “Camels” paper gives an answer: instruction tuning is mostly a “style transfer” step that teaches the model how to present its knowledge, not what to know. Smaller models have a larger gap between their latent knowledge and their ability to express it in instruction-following form. Tuning closes this gap more for smaller models because their “interface deficit” is larger.
The paper also runs an important ablation on the number of prompt templates per task. Using 10 templates per task (instead of 1) improves performance by 2-3 points on held-out benchmarks. Each extra template gives a slightly different phrasing of the same task. It teaches the model that one instruction can be written many ways, a crucial skill for following novel instructions that use unfamiliar phrasings.
Chapter 3
Mix in one percent of worked reasoning and watch reasoning scores jump without hurting the rest
Perhaps the most impactful finding in the paper: including chain-of-thought (CoT) examples in the instruction tuning mixture sharply improves reasoning on held-out tasks.
Chain-of-thought prompting (Wei et al. 2022) asks the model to show its work, to write intermediate reasoning steps before the final answer. For example:
without CoT "Q: Roger has 5 tennis balls. He buys 2 more cans of 3. How many does he have?" "A: 11" with CoT "Q: Roger has 5 tennis balls. He buys 2 more cans of 3. How many does he have?" "A: Roger starts with 5 balls. He buys 2 cans of 3 balls each." "That's 2 × 3 = 6 new balls. Total = 5 + 6 = 11. The answer is 11."
The paper puts 9 CoT datasets (math, commonsense, logic) in the instruction tuning mix. They are only ~1% of total examples. Despite this tiny share, the impact is dramatic:
| Config | CoT benchmarks | Non-CoT benchmarks |
|---|---|---|
| No CoT in tuning | 56.1 | 73.5 |
| CoT only in tuning | 70.2 | 66.8 |
| Mix (non-CoT + CoT) | 73.8 | 73.0 |
Pick what goes in the instruction tuning mixture. The purple bar is reasoning (CoT) benchmarks and the teal bar is standard benchmarks. The mixed approach scores best on both.
The six scores are the values in the table above.
Using CoT data alone hurts non-reasoning tasks (73.5 → 66.8). This makes sense: if you only train on step-by-step reasoning, the model may try to “reason” when a simple direct answer is needed. The mixed approach teaches the model when to reason step by step and when to answer directly.
The mechanism is subtle. With CoT-only training, the model learns a “default mode” of long step-by-step reasoning. Asked “What is the capital of France?”, it might reply: “Let me think step by step. France is a country in Western Europe. Countries have capital cities. The capital of France is Paris. The answer is Paris.” This is correct but needlessly long. The mixed approach teaches the model that simple factual questions deserve direct answers (“Paris”), while complex reasoning questions deserve step-by-step solutions.
python # CoT mixing: the key is teaching WHEN to reason # Standard task (99% of mix): # Q: "What is the capital of France?" # A: "Paris" ← direct answer # CoT task (1% of mix): # Q: "If John has 3 apples and buys 2 bags of 4, how many?" # A: "John starts with 3 apples. He buys 2 bags with 4 each. # That's 2 × 4 = 8 new apples. Total = 3 + 8 = 11." # After mixed training, the model learns: # - Simple questions → direct answer # - Multi-step reasoning → show work # This is implicit mode selection from the training distribution
Chapter 4
Compare base and tuned models on four benchmarks and find the biggest surprise
Flan-PaLM 540B (PaLM instruction-tuned with the Flan collection) reaches state-of-the-art results on a broad range of benchmarks:
| Benchmark | PaLM 540B | Flan-PaLM 540B | GPT-3.5 (text-davinci-002) |
|---|---|---|---|
| MMLU (5-shot) | 69.3 | 73.6 | 68.0 |
| BBH (CoT) | 62.0 | 66.3 | 64.3 |
| TyDiQA | 55.2 | 72.6 | — |
| MGSM (multilingual math) | 45.9 | 72.0 | — |
Flan-PaLM 540B is impressive, but it is impractical for most users. Flan-T5 is the practical variant: instruction tuning applied to Google’s T5 models. The results are remarkable:
| Model | Params | MMLU (0-shot) | BBH (CoT) |
|---|---|---|---|
| T5-XL (no IT) | 3B | 28.3 | 24.1 |
| Flan-T5-XL | 3B | 52.4 | 43.6 |
| T5-XXL (no IT) | 11B | 33.7 | 28.5 |
| Flan-T5-XXL | 11B | 57.2 | 49.0 |
Flan-T5-XL (3B) with instruction tuning beats the raw T5-XXL (11B) on both benchmarks. Instruction tuning is worth more than a 3.7 times increase in model size.
This result has large practical consequences. Running a 3B model is about 4 times cheaper than running an 11B model, in both memory and compute. If instruction tuning a 3B model beats running an 11B model without it, then instruction tuning is by far the most cost-effective step available. It costs less than buying bigger hardware, less than collecting more pre-training data, and less than any architecture change.
The paper also compares against GPT-3.5 (text-davinci-002), the strongest publicly available model at the time. Flan-PaLM 540B beats GPT-3.5 on MMLU (73.6 vs 68.0) and is competitive on BBH (66.3 vs 64.3). It was the first time an openly described instruction-tuning recipe produced a model competitive with OpenAI’s best, a significant milestone for open research.
Grey bars are the base model. Teal bars are the instruction-tuned one. Switch between the PaLM and the T5 family.
All bars are the numbers in the two tables above.
A particularly interesting finding: instruction tuning sharply improves zero-shot performance (no examples in the prompt) while keeping or slightly improving few-shot performance. This matters because zero-shot is the most user-friendly mode. You just ask a question without giving examples. Before instruction tuning, zero-shot performance was much worse than few-shot. After instruction tuning, the gap narrows or disappears.
python # Zero-shot vs few-shot improvement # PaLM 540B on MMLU: # 0-shot: 69.3 → 73.6 (Flan) = +4.3 # 5-shot: 73.5 → 74.1 (Flan) = +0.6 # Zero-shot gains >> few-shot gains # Why? Few-shot examples already provide an "interface" — # they show the model what format to use. # Instruction tuning provides this interface permanently, # making the few-shot examples redundant.
Chapter 5
Follow the five-step recipe and find the point where more training starts to hurt
The paper boils its findings down to concrete guidelines for practitioners who want to instruction-tune their own models. These guidelines have proven remarkably durable.
python # Input inversion examples # Original task: # Input: "Classify: 'This movie is great' → ?" # Output: "Positive" # Inverted task: # Input: "Generate a positive movie review." # Output: "This movie is great, with excellent acting." # Why this helps: the model learns BOTH directions of the mapping # Original: text → label (recognition) # Inverted: label → text (generation) # Together: deep understanding of what "positive" means
The advice of 30K-40K gradient steps comes from a careful look at the training curve. Performance on instruction-tuning tasks improves steadily throughout training. But performance on held-out tasks (tasks not seen during instruction tuning) peaks around 30K-40K steps and then starts to fall. This is catastrophic forgetting: the model overwrites its pre-trained knowledge with instruction-specific patterns.
The first term is pre-trained knowledge, which decays exponentially with instruction-tuning steps. The second term is growing instruction-following ability. The best number of steps balances the two. Too few steps and instruction-following is weak. Too many and the pre-trained knowledge is lost. This is a sketch of the trade-off, not a formula the paper fits.
| Mistake | Why it hurts |
|---|---|
| Too few tasks | Model overfits to seen instruction patterns, fails on novel ones |
| Only one template per task | Model learns template matching, not instruction understanding |
| Too much training | Pre-trained knowledge is overwritten (catastrophic forgetting) |
| Only CoT data | Model tries to reason on simple factual questions |
| Uniform task sampling | Tiny tasks get drowned by massive ones |
Turn each ingredient on or off and read the predicted score. Each part adds its own share.
Illustrative additive model: a base of 55, plus 12 for diverse tasks, 8 for CoT data and 3 for input inversion. These weights are a teaching toy, not measurements from the paper.
Chapter 6
Turn all three scaling axes at once and see that each adds its own share
Let’s bring the paper’s three scaling dimensions together in one instrument. You can vary the number of tasks, the model size and the presence of CoT data on their own, and see how each affects performance.
Adjust the number of tasks, the model size and CoT inclusion. Each bar is the share one axis adds. Notice that each axis contributes on its own.
Illustrative formula from the code below: score = 50 + 8 × log10(tasks) − 8 + a size bonus (0, 8, 16 or 22) + 8 for CoT, capped at 95. It shows the additive-in-log shape, not the paper’s measured scores.
| Axis | Scaling Behavior | Saturation? |
|---|---|---|
| Number of tasks | Log-linear improvement: 2x tasks ≈ +1-2% accuracy | Not observed at 1,836 |
| Model size | Power-law improvement: 10x params ≈ +5-10% accuracy | Not observed at 540B |
| CoT inclusion | Step function: including ANY CoT gives +5-15% on reasoning | Mostly saturated at ~1% mix |
The paper gives evidence for this by running a full factorial experiment: every combination of (few tasks / many tasks) × (small model / large model) × (with CoT / without CoT). The gains from each axis are roughly additive in log-space, which means they are multiplicative in raw performance. This matters because it tells practitioners to invest in all three axes. Skipping any one of them leaves significant performance on the table.
python # The three scaling dimensions — approximate formula # Performance ≈ Base + log(tasks)*8 + log(params)*3 + CoT*8 # Worst case: 20 tasks, 250M params, no CoT # ≈ 50 + 10.4 + 0 + 0 = 60.4% # Best case: 1836 tasks, 540B params, with CoT # ≈ 50 + 26.1 + 22 + 8 = 106.1% (capped at ~95%) # Marginal value of each axis at best settings: # Adding tasks (20→1836): +15.7 points # Adding scale (250M→540B): +22.0 points # Adding CoT: +8.0 points
Chapter 7
Place the paper in the field: what it built on, what came after, and what to carry away
This paper sits where two major trends meet: instruction tuning and scaling laws. It showed that both trends hold for the post-training phase, not just pre-training. More importantly, it gave the first comprehensive recipe for instruction tuning, a recipe the community followed for over a year.
The paper’s timing was critical. It came out in late 2022, just weeks before ChatGPT’s release. ChatGPT showed the public the power of instruction tuning plus RLHF. The Flan paper gave the research community the scientific base it needed to replicate and extend those results. Without this paper’s systematic analysis of what makes instruction tuning work, the open-source response to ChatGPT (Alpaca, Vicuna and others) would have been much more haphazard.
| Foundation | Contribution |
|---|---|
| FLAN (Wei 2021) | Original instruction tuning on 62 tasks, which showed the concept works |
| T0/P3 (Sanh 2021) | Community prompt templates + zero-shot generalization study |
| Super-Natural Instructions | Large crowdsourced task collection with detailed definitions |
| CoT Prompting (Wei 2022) | Chain-of-thought prompting at inference time |
| PaLM (Chowdhery 2022) | The 540B base model that Flan-PaLM is built on |
| Successor | Advance |
|---|---|
| AlpacaFarm | Simulated human feedback for faster instruction tuning research |
| Camels (Tülu) | Systematic comparison of open instruction-tuning datasets |
| Alpaca | Self-instruct: generate instruction data from GPT-3.5, tune LLaMA |
| Orca | Explanation tuning: include GPT-4’s reasoning traces in the fine-tuning data |
| Llama 3 | Scaled instruction tuning + DPO to 405B parameters |
The CoT finding deserves special emphasis. Before this paper, chain-of-thought was purely an inference-time technique: you added “Let’s think step by step” to your prompt and hoped the model would reason better. This paper showed that putting CoT in the training data is far more effective. That insight directly shaped every later instruction-tuning effort. Llama 2 Chat, Mistral Instruct and Claude all include reasoning traces in their fine-tuning data.
The Flan-T5 model family (small, base, large, xl, xxl) also deserves credit for its practical impact. For over a year (late 2022 to mid-2023), Flan-T5 was the default instruction-following model for the research community. It was used in hundreds of papers, thousands of projects and countless applications. Its encoder-decoder design made it especially good at structured tasks (classification, extraction, translation) where the output format is well defined.
| Quantity | Value |
|---|---|
| Tasks in the Flan collection | 1,836 |
| Prompt templates per task | up to 10 |
| CoT share of the mix | ~1% (9 datasets) |
| Tuning length | 30K-40K steps |
| Tuning cost | 0.2% of pre-training compute (PaLM 540B), ~0.5% (T5-11B) |
| Flan-T5-XL (3B) vs T5-XXL (11B), MMLU 0-shot | 52.4 vs 33.7 |
| Flan-PaLM 540B vs PaLM 540B, MGSM | 72.0 vs 45.9 |
The core of the paper, as code you can run:
python # Using Flan-T5 — the most practical output of this paper from transformers import T5ForConditionalGeneration, T5Tokenizer model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xl") tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xl") # Zero-shot — no examples needed! prompt = "Classify the sentiment: 'This movie was incredible'\nSentiment:" inputs = tokenizer(prompt, return_tensors="pt") output = model.generate(**inputs, max_new_tokens=10) print(tokenizer.decode(output[0], skip_special_tokens=True)) # → "positive" # CoT reasoning — also works zero-shot after Flan tuning prompt2 = "Q: If a train travels 60mph for 2.5 hours, how far does it go?" # → "The train travels 60 miles per hour for 2.5 hours. # Distance = speed × time = 60 × 2.5 = 150 miles."
“Instruction tuning is a simple method that, across many settings, substantially improves the performance of pretrained language models.”
Chung et al., 2022
Open Present to explain the recipe out loud, or Teach to draw it on the whiteboard. Then go back to the three models and ask the question again.