Part 8 of 15 in LLM fine-tuning techniques

Instruction tuning fine-tunes a pretrained language model on a large mix of tasks, each written as a natural-language instruction, so that it can follow instructions for tasks it never saw. Google Research named and tested the method in 2021 with FLAN, a 137B-parameter model that beat zero-shot GPT-3 175B on 20 of 25 datasets (Wei et al., arXiv 2109.01652).

20 of 25
datasets where zero-shot FLAN beat zero-shot GPT-3 175B
Wei et al., Sec. 3
1,836
instruction tasks used for Flan-PaLM
Chung et al. 2022, Sec. 2.1
0.2%
of pre-training compute spent on Flan-PaLM 540B's instruction tuning
Chung et al., Sec. 2.2

Instruction tuning is the first of three data-strategy pages in this series, with multi-task tuning and federated tuning. Supervised fine-tuning on human-written instruction demonstrations is also the first stage of OpenAI's InstructGPT recipe, before RLHF.

What is instruction tuning?

Instruction tuning is "finetuning language models on a collection of datasets described via instructions", in the words of the FLAN paper. Each training example pairs an instruction, such as "Translate this sentence to Spanish", with its answer. The goal is better zero-shot performance on tasks that were not in the training mix (Wei et al., Abstract and Sec. 2).

It changes the model's weights. In FLAN and Flan-PaLM all weights were fine-tuned; libraries also let you combine it with LoRA or QLoRA adapters (TRL docs).

The FLAN paper contrasts it with two older approaches (Figure 2):

ApproachHow a new task is handledExample models named in the paper
Pretrain, then fine-tuneOne specialized model per task, many task examplesBERT, T5
PromptingFew-shot examples or prompt engineering at inferenceGPT-3
Instruction tuningFine-tune once on many instruction tasks, then run unseen tasks zero-shotFLAN

How does instruction tuning work?

FLAN converted 62 public datasets into instructions using 10 hand-written templates per dataset, grouped them into 12 task clusters, and fine-tuned a 137B-parameter model on the mix. To test generalization, each evaluated cluster was held out entirely: for example, no inference datasets were seen when testing inference (Wei et al., Sec. 2.1–2.4).

Diagram of FLAN instruction tuning: task clusters are turned into instruction templates, used to fine-tune LaMDA-PT 137B, and the model is tested zero-shot on a held-out cluster

Step by step, as the FLAN paper describes it:

  1. Collect tasks. 62 text datasets from TensorFlow Datasets, covering understanding and generation, in 12 clusters such as translation, summarization and commonsense (Sec. 2.1, Figure 3).
  2. Write templates. Ten templates per dataset; up to three per dataset "turned the task around", for example asking for a movie review in a sentiment dataset (Sec. 2.1).
  3. Add options for classification. Classification prompts end with "OPTIONS" and the list of allowed answers (Sec. 2.3).
  4. Mix the data. At most 30k examples per dataset, with examples-proportional mixing capped at 3k (Sec. 2.4).
  5. Fine-tune. LaMDA-PT 137B, 30k steps, batch of 8,192 tokens, Adafactor, learning rate 3e-5, input and target lengths 1,024 and 256, with packing. This took about 60 hours on a TPUv3 with 128 cores (Sec. 2.4).
  6. Evaluate on a held-out cluster. To test c clusters, they trained c models, each with a different cluster held out (Sec. 2.2).

Worked example: how big is the instruction-tuning run?

From the numbers above, FLAN's fine-tuning processed 30,000 steps × 8,192 tokens = 245,760,000 tokens, or about 246 million (Sec. 2.4). Flan-PaLM, a year later, used 1.4 billion fine-tuning tokens against 780 billion pre-training tokens: 1.4 ÷ 780 = 0.18%, which the paper rounds to "0.2% of the pre-training tokens" (Chung et al., Sec. 3).

FLAN (Wei et al., 2021)Flan-PaLM 540B (Chung et al., 2022)
Base modelLaMDA-PT 137BPaLM 540B
Tasks62 datasets, 12 clusters1,836 tasks, 473 datasets, 146 categories
Fine-tuning tokens30k steps × 8,192 ≈ 246M (our arithmetic)1.4B (0.2% of 780B pre-training)
Hardware and timeTPUv3, 128 cores, ~60 hours~512 TPU v4 chips, 37 hours
Chain-of-thought dataNoYes, nine CoT datasets

What does the training data look like?

The current Hugging Face TRL docs accept instruction data in a conversational format, a list of messages with roles, or as prompt-completion pairs (TRL SFT docs):

# Conversational language modeling
{"messages": [{"role": "user", "content": "What color is the sky?"},
              {"role": "assistant", "content": "It is blue."}]}

# Standard prompt-completion
{"prompt": "The sky is", "completion": " blue."}

The loss is token-level cross-entropy on the target text; with prompt-completion data TRL computes it on the completion only by default (same page).

When was instruction tuning introduced, and by whom?

The term and the method were introduced in "Finetuned Language Models Are Zero-Shot Learners" by Jason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai and Quoc V. Le of Google Research. It was posted to arXiv on Sept. 3, 2021, and published at ICLR 2022 (arXiv 2109.01652).

Two follow-ups this page also draws on:

  • Flan-PaLM and Flan-T5. "Scaling Instruction-Finetuned Language Models" by Hyung Won Chung, Le Hou, Shayne Longpre and 32 co-authors at Google, posted Oct. 20, 2022. It scaled tasks, model size and chain-of-thought data, and released Flan-T5 checkpoints from 80M to 11B parameters (arXiv 2210.11416).
  • InstructGPT. "Training language models to follow instructions with human feedback" by Long Ouyang and colleagues at OpenAI, posted March 4, 2022. Its first stage is supervised fine-tuning on about 13k prompts with human-written demonstrations, followed by RLHF (arXiv 2203.02155, Sec. 3.2).

The FLAN instruction-tuning data code is at google-research/FLAN.

What results did the instruction-tuning papers report?

Zero-shot FLAN 137B beat zero-shot GPT-3 175B on 20 of 25 datasets and beat few-shot GPT-3 on 10. Flan-PaLM 540B gained 9.4% on average over PaLM 540B and reached 75.2% on five-shot MMLU. InstructGPT's 175B outputs were preferred over a FLAN-tuned GPT-3 78% of the time on OpenAI's API prompts (Wei et al., Sec. 3; Chung et al.; Ouyang et al., Sec. 4.1).

FLAN (Wei et al., 2021):

  • Beat zero-shot GPT-3 on 20 of 25 datasets and few-shot GPT-3 on 10, using the best template on the dev set; beat zero-shot GLaM on 13 of 19 and one-shot GLaM on 11 of 19 (Sec. 3).
  • Beat few-shot GPT-3 "by a large margin" on ANLI, RTE, BoolQ, AI2-ARC, OpenbookQA and StoryCloze (Abstract).
  • Helped most where tasks read naturally as instructions (inference, QA, translation, struct-to-text). On seven commonsense and coreference tasks written as sentence completions, it beat the untuned model on only three (Sec. 3).

Ablations (Wei et al., Sec. 4):

  • More clusters helped. Average held-out performance rose as clusters were added, without saturating at seven (Sec. 4.1, Figure 6).
  • Scale mattered. For the two models around 100B parameters, instruction tuning helped a lot; for models of 8B and smaller, "instruction tuning actually hurts performance on held-out tasks" (Sec. 4.2, Figure 7).
  • Instructions mattered. Averaged over four held-out clusters, FLAN scored 55.2, against 37.3 when fine-tuned with no instructions and 46.6 to 47.0 when fine-tuned with only the dataset name (Sec. 4.3, Figure 8).

Flan-PaLM and Flan-T5 (Chung et al., 2022):

  • Instruction tuning on 1,836 tasks raised normalized held-out performance by 9.4% (540B) to 15.5% (8B) over the untuned PaLM models; most of the gain came by 282 tasks (Sec. 3).
  • Flan-PaLM 540B reached 75.2% on five-shot MMLU, against 69.3% for PaLM, 68.3% for code-davinci-002 and 67.6% for Chinchilla (Sec. 4.1).
  • Flan-T5 11B beat PaLM 62B on BBH-direct, 43.7% vs 37.5% (Sec. 7).

InstructGPT (Ouyang et al., 2022): GPT-3 175B fine-tuned on the FLAN and T0 datasets did better than plain GPT-3 but worse than OpenAI's own supervised baseline on API prompts. The authors note that classification and QA make up about 18% of API use, while open-ended generation and brainstorming are about 57% (Sec. 4.1).

How is instruction tuning different from multi-task tuning and RLHF?

Instruction tuning is multi-task fine-tuning where every task is phrased as a natural-language instruction and success is measured on unseen tasks. The FLAN paper tested the difference directly: the same multi-task mix without instructions scored 37.3 against 55.2 with them. RLHF is a separate stage that trains on human preference rankings after supervised tuning (Wei et al., Sec. 4.3; Ouyang et al., Sec. 3).

Instruction tuningMulti-task tuningRLHFPrompt tuning
Training signalInstruction → target textTask input → target; FLAN's no-instruction ablation scored 37.3 vs 55.2 (Sec. 4.3)Human rankings via a reward model (Ouyang et al., Sec. 3)Task input → target (Lester et al., Sec. 2)
Weights changedYes (or adapters)YesYesNo, only a soft prompt
Stated goal in the papersZero-shot on unseen tasks (Wei et al.)See Part 9Align models with user intent (Ouyang et al., Abstract)One frozen model reused across tasks (Lester et al.)

Alignment methods that usually follow it, such as DPO and GRPO, are covered later in the series; for how distillation, LoRA and GRPO fit together, see our explainer.

Which libraries support instruction tuning?

Hugging Face TRL supports instruction tuning through SFTTrainer and SFTConfig. Its docs (v1.19.0, read Dec. 4, 2026) include an instruction-tuning example that turns Qwen3-0.6B-Base into a chat model with a chat template, and support standard, conversational and prompt-completion datasets plus PEFT adapters via peft_config (TRL SFT docs).

The released Flan-T5 checkpoints are on Hugging Face, for example google/flan-t5-xxl, and the FLAN data code is at google-research/FLAN.

How do you use instruction tuning in code?

This is the TRL docs' own instruction-tuning example: a base model, a chat template and a conversational dataset. Class and argument names are from the TRL v1.19.0 reference (SFTTrainer and SFTConfig).

from trl import SFTConfig, SFTTrainer
from datasets import load_dataset

trainer = SFTTrainer(
    model="Qwen/Qwen3-0.6B-Base",
    args=SFTConfig(
        output_dir="Qwen3-0.6B-Instruct",
        chat_template_path="HuggingFaceTB/SmolLM3-3B",
    ),
    train_dataset=load_dataset("trl-lib/Capybara", split="train"),
)
trainer.train()

To train adapters instead of all weights, pass peft_config=LoraConfig() to SFTTrainer; the docs suggest a learning rate around 1e-4 for adapters. To compute the loss only on assistant replies, set assistant_only_loss=True in SFTConfig (same page).

Common pitfalls

  • Small models in the original FLAN setup. At 8B parameters and below, instruction tuning hurt held-out performance in FLAN's experiments (Wei et al., Sec. 4.2). The later Flan-PaLM study reported gains at 8B (15.5%) and released Flan-T5 down to 80M (Chung et al., Sec. 3); the two studies used different models, task mixes and evaluations.
  • Tasks that are already language modeling. Where the task is a sentence completion, "instructions are largely redundant" and instruction tuning "is not useful" (Wei et al., Sec. 3).
  • Dropping reasoning data. Flan-PaLM's held-out chain-of-thought scores were stronger with CoT and non-CoT data combined than with CoT alone, and the paper's section heading is "Some chain-of-thought data is needed to maintain reasoning ability" (Chung et al., Sec. 4.2).
  • Training on public NLP tasks only. InstructGPT found FLAN and T0 data "not sufficiently diverse" for its API prompt distribution (Ouyang et al., Sec. 4.1).
  • Assistant-only loss without template support. In TRL, assistant_only_loss=True requires {% generation %} and {% endgeneration %} in the chat template; TRL patches known families such as Qwen3 automatically (TRL docs).
  • Model dtype. When SFTTrainer loads a model from a string and no dtype is set in model_init_kwargs, it loads in float32 (same page).

FAQ

What is the difference between instruction tuning and fine-tuning?

Instruction tuning is a kind of fine-tuning. Standard fine-tuning trains one model for one task; instruction tuning trains on many tasks phrased as instructions so the model can handle unseen tasks zero-shot (Wei et al., Figure 2).

Is instruction tuning the same as supervised fine-tuning (SFT)?

Instruction tuning is done with supervised fine-tuning: the model learns to produce target text for instruction inputs with a cross-entropy loss. TRL's SFTTrainer documents an instruction-tuning example (TRL docs). InstructGPT calls its supervised stage on human demonstrations "SFT" (Ouyang et al., Sec. 3).

What does FLAN stand for?

Finetuned Language Net. It is the name the paper gives to its instruction-tuned LaMDA-PT 137B model (Sec. 1).

How much data does instruction tuning need?

FLAN used 62 datasets capped at 30k examples each (Sec. 2.4). Flan-PaLM used 1,836 tasks but found most of the gain came by 282 tasks (Chung et al., Sec. 3). InstructGPT's supervised set had about 13k training prompts (Sec. 3.2).

Does instruction tuning work on small models?

The papers differ. FLAN found it hurt held-out tasks at 8B and below (Sec. 4.2). Chung et al. reported gains for PaLM 8B and Flan-T5 models from 80M to 11B, with Flan-T5 11B beating PaLM 62B on BBH-direct (Sec. 3 and 7).

Is instruction tuning the same as RLHF?

No. In InstructGPT, supervised fine-tuning on demonstrations comes first, then a reward model trained on human rankings and reinforcement learning (Ouyang et al., Sec. 3). See RLHF.

Can I instruction-tune with LoRA?

Yes. TRL's SFTTrainer accepts a peft_config such as LoraConfig() to train adapters instead of all weights (TRL docs). See LoRA.

Sources

  • Jason Wei, Maarten Bosma, Vincent Y. Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M. Dai, Quoc V. Le. "Finetuned Language Models Are Zero-Shot Learners." arXiv:2109.01652, Sept. 3, 2021 (v5 Feb. 8, 2022); ICLR 2022. arXiv. Read Dec. 4, 2026.
  • Hugging Face TRL v1.19.0, SFT Trainer documentation. Read Dec. 4, 2026.
  • Hyung Won Chung, Le Hou, Shayne Longpre, et al. "Scaling Instruction-Finetuned Language Models." arXiv:2210.11416, Oct. 20, 2022 (v5 Dec. 6, 2022). arXiv. Read Dec. 4, 2026.
  • Long Ouyang, Jeff Wu, Xu Jiang, et al. "Training language models to follow instructions with human feedback." arXiv:2203.02155, Mar. 4, 2022. arXiv. Read Dec. 4, 2026.
  • FLAN code: google-research/FLAN; Flan-T5 checkpoint: google/flan-t5-xxl. Opened Dec. 4, 2026.

Series: ← Prev: Prompt Tuning · All 15 techniques · Next: Multi-Task Tuning →

  • #llm-fine-tuning
  • #instruction-tuning
  • #flan
  • #sft
  • #trl