Key takeaways
- Instruction tuning fine-tunes a pretrained model on instruction and response pairs so it follows requests instead of just continuing text.
- It is a form of supervised fine-tuning; SFT is the broader term for training on labelled input and output examples.
- Prompt tuning learns a small soft prompt and leaves the model frozen; instruction tuning updates the model or its adapters.
- Diversity of tasks and quality of responses matter more than raw example count.
- Visual and code instruction tuning apply the same idea to images and programming tasks.
Instruction tuning is fine-tuning a pretrained language model on examples of instructions paired with good responses, so that it learns to follow requests rather than simply continue text. It is the step that turned raw base models into assistants. I built FineTune Studio around supervised fine-tuning with QLoRA, Transformers, PEFT and TRL, so this page explains what instruction tuning is and how it works, how it relates to SFT, fine-tuning and prompt tuning, how to do it at scale, and its visual and code variants.
What is instruction tuning?
Instruction tuning trains a pretrained model on a dataset of instruction and response pairs, such as "Summarise this email" with a good summary, across many kinds of tasks. The model learns the general skill of following instructions, including for tasks it never saw.
The idea was popularised by Google's FLAN work in 2021, which showed that a model tuned on many tasks phrased as instructions performed much better zero-shot on unseen tasks. Base models trained only to predict the next word often ramble or answer the wrong question; instruction tuning teaches format, helpfulness and task focus. Most chat models are instruction-tuned and then further aligned with preference methods.
What is instruction fine-tuning in LLMs?
Instruction fine-tuning in LLMs is the same thing as instruction tuning: updating a large language model's weights, or small adapters, on instruction-response examples, often formatted with a chat template that marks system, user and assistant turns.
Also asked as: what is instruction fine tuning in llm
In practice, you prepare examples in the model's chat format, train with a loss computed only on the assistant's responses, and evaluate on held-out instructions. Teams instruction-tune open models for a domain, such as legal drafting or support replies, so the model follows their formats and tone. With LoRA or QLoRA, this can run on a single GPU. Always compare the tuned model against the base model on the same prompts; FineTune Studio shows base and tuned outputs side by side for that reason.
How does instruction tuning work?
You start from a pretrained model, build a dataset of instructions with high-quality responses, format each example with a consistent template, and train with next-token prediction loss on the response tokens. The model's weights shift towards producing helpful, well-formatted answers.
Key details:
- Data: diverse tasks, clear instructions, correct responses; quality beats quantity.
- Template: use the model's chat template so training matches inference.
- Loss masking: train on responses, not on the instruction text.
- Method: full fine-tuning or LoRA and QLoRA adapters.
- Evaluation: held-out instructions, task metrics and human review.
A few thousand excellent examples can noticeably change behaviour for a narrow domain.
Is instruction tuning SFT?
Yes. Instruction tuning is a type of supervised fine-tuning (SFT): the model learns from labelled examples where the desired output is given. SFT is the broader term, covering any supervised training on input and output pairs, instruction-style or not.
In the common pipeline for chat models, the SFT stage is instruction tuning on demonstrations, followed by preference optimisation such as RLHF or DPO, which teaches the model which of several responses people prefer. In tools such as Hugging Face TRL, you run instruction tuning with the SFT trainer. When people say "SFT" in LLM work today, they nearly always mean instruction or chat fine-tuning.
What is the difference between fine-tuning and instruction tuning?
Fine-tuning is any further training of a pretrained model on new data for a goal. Instruction tuning is a specific kind of fine-tuning whose data is instructions paired with responses, aimed at general instruction following.
Also asked as: difference between fine tuning and instruction tuning
Other fine-tuning includes continued pretraining on domain text without instructions, classification fine-tuning with a label head, and preference tuning with ranked responses. Instruction tuning improves how a model responds to requests; continued pretraining adds domain knowledge and vocabulary. For knowledge that changes, such as policies or prices, retrieval with RAG is usually better than either, because you can update documents without retraining.
What is the difference between prompt tuning and instruction tuning?
Prompt tuning learns a small set of continuous "soft prompt" vectors prepended to the input while the model stays frozen. Instruction tuning trains the model, or its adapters, on instruction-response examples so its behaviour changes across many tasks.
Prompt tuning is very parameter-efficient, storing only a tiny prompt per task, and research by Lester and colleagues showed it approaches full fine-tuning quality as models get larger. But each task needs its own learned prompt, and it does not generally teach instruction following. Instruction tuning produces one model that handles many instructions. Do not confuse either with prompt engineering, which writes text prompts by hand without any training.
How do I do instruction tuning at scale?
At scale, mix many tasks and sources, balance them carefully, deduplicate and filter for quality, and train with efficient distributed methods. Google's Flan work scaled to 1,836 tasks and found that more tasks, larger models and chain-of-thought data all improved results.
Also asked as: how to do instruction tuning at scale
Practical steps:
- Collect diverse instructions: human-written, converted datasets and filtered synthetic data.
- Balance task mixtures so no single dataset dominates.
- Remove duplicates, test-set overlap and low-quality responses.
- Use multi-GPU training with sharded data parallelism or DeepSpeed.
- Track evaluation suites across reasoning, coding, safety and languages.
Version every dataset mixture so you can trace which data caused improvements or regressions.
What is visual instruction tuning?
Visual instruction tuning trains a multimodal model on instructions about images paired with responses, so it can answer questions, describe scenes and follow visual tasks. It was introduced with LLaVA in 2023, which connected a vision encoder to a language model.
LLaVA generated instruction data by prompting a text model with image captions and object boxes, then trained a projection layer and the language model on that data. The approach became the template for many open vision language models. In practice, visual instruction tuning teaches tasks such as reading charts, extracting fields from documents and explaining photos. The same quality rules apply: diverse, accurate examples and careful evaluation on real images.
How does instruction tuning for code completion work?
Code instruction tuning trains a code model on natural-language requests paired with correct code, such as "Write a function that validates email addresses" with a tested solution, so it can generate and explain code from instructions.
Datasets come from human-written problems, commits with their messages, and synthetic instructions evolved to be harder, as in WizardCoder's Evol-Instruct. Inline completion inside an editor relies more on pretraining objectives such as fill-in-the-middle, where the model learns to complete code given text before and after the cursor. Assistants combine both: completion models for typing and instruction-tuned models for chat. Evaluate with executable tests such as HumanEval, not just text similarity.
Can programming languages boost each other via instruction tuning?
Yes, according to a 2023 study by Zan and colleagues: instruction tuning a code model on one language improved its performance in other languages. Training on Python instructions, for example, improved Java results, suggesting shared programming concepts transfer.
The researchers built instruction datasets for eight languages, including Python, JavaScript, C++, Java, Go and HTML, and tuned StarCoder on each. Some transfers were surprising, with markup language data helping general-purpose languages. The practical lesson: for a low-resource language, adding high-quality instruction data in related languages can help, but measure on your target language, because transfer varies between pairs.
Sources
- Wei et al., Finetuned Language Models Are Zero-Shot Learners (FLAN, 2021)arxiv.org
- Chung et al., Scaling Instruction-Finetuned Language Models (2022)arxiv.org
- Liu et al., Visual Instruction Tuning (LLaVA, 2023)arxiv.org
- Zan et al., Can Programming Languages Boost Each Other via Instruction Tuning? (2023)arxiv.org
- Lester et al., The Power of Scale for Parameter-Efficient Prompt Tuning (2021)arxiv.org
- Hugging Face TRL, SFT Trainer documentationhuggingface.co




