Skip to content
atlas

Instruction tuning

Also known as: supervised fine-tuning, SFT

Extra training on many written requests paired with good answers, which turns a text-continuing base model into one that follows orders.

Draft - this entry has not been reviewed yet.

Formal

A form of fine-tuning in which a language model that has finished pretraining is trained on sets of instructions and example responses, so that it answers a request instead of merely continuing the text it was given.

In plain English

Like a well-read new employee who knows a lot but must be shown, through many worked examples, how the office expects a request to be handled.

In practice

A customer-service lead at a Danish online shop tests an open model with “Write a polite reply refusing the refund”; the base version just adds more customer complaints, while the version that has had instruction tuning writes the reply.

Why it matters

It is what makes a raw model usable as an assistant, and the example answers chosen here shape its tone, its refusals and much of its safety.

Technical deep dive

Mechanically, instruction tuning is supervised fine-tuning with the same next-token cross-entropy objective as pretraining, applied to curated examples of the form instruction (plus optional input) → desired response, or to multi-turn conversations. Conversations are serialised with a chat template that marks roles with special tokens (ChatML's <|im_start|> and <|im_end|> is one widespread example), and the loss is usually computed only on the assistant's tokens; in Hugging Face code the prompt positions get the label −100 so they are ignored. Learning rates are far smaller than in pretraining and one to a few epochs are typical. A model must later be prompted with exactly the template it was tuned on, since a mismatched template measurably degrades output.

The technique took shape in 2021. FLAN (Wei et al.) took a 137-billion-parameter pretrained model, rephrased more than 60 NLP data sets into natural-language instruction templates, and showed that the tuned model beat zero-shot GPT-3 175B on 20 of 25 evaluated data sets, with gains growing with model scale and the number of task clusters. T0 (Sanh et al., 2021) reached similar conclusions, and the 2022 Flan collection scaled to 1,836 tasks. InstructGPT (Ouyang et al., 2022) used about 13,000 training prompts with human-written demonstrations as the supervised stage before RLHF. Cheaper recipes followed: Self-Instruct bootstrapped instructions from a model's own outputs, Stanford Alpaca used 52,000 examples generated by an OpenAI model, and LIMA (Zhou et al., 2023) reported strong results from only 1,000 carefully curated examples, supporting the view that tuning mostly teaches format and style while knowledge comes from pretraining.

That view has practical consequences. Instruction data teaching facts the base model does not know is learned slowly and has been linked to more hallucination (Gekhman et al., 2024), so domain knowledge is often better supplied through continued pretraining or retrieval. Heavy tuning on a narrow domain causes catastrophic forgetting of general ability, which recipes counter by mixing in general instruction data. Distilling responses from a stronger proprietary model can conflict with that provider's terms of use.

Instruction tuning is also where much safety behaviour is set, and it is fragile. Qi et al. (2023) showed that fine-tuning an aligned model on as few as ten adversarially designed examples could largely remove its refusals, and even benign fine-tuning data eroded safety somewhat. Downstream fine-tuning of an aligned model therefore needs its own safety evaluation. In the standard pipeline instruction tuning is followed by preference optimisation such as RLHF or DPO, which uses comparisons between answers rather than single reference answers.

What to learn first

Everything this builds on, foundations first.

  1. Token
  2. →Training data
  3. →Self-supervised learning
  4. →Transformer
  5. →Large language model (LLM)
  6. →Pretraining
  7. →Instruction tuning

Relationships

A kind of
Fine-tuning
Don't confuse with
Pretraining

Sources & further reading

Reference works

Where this data comes from

This entry was drafted by an AI from the sources above and has not yet been checked by a person. Treat it as a starting point, and check anything important against the sources.

See the review queueSuggest a correction on GitHubThis term as JSON

Check yourself

Loading…

Atlas is in beta.