Definition and objective
Supervised fine-tuning (SFT) is continued training of a model already fit to a broad source distribution, using labeled input–output pairs and a supervised loss. For generative language models, each pair is a prompt and a target completion, and the loss is next-token cross-entropy on that completion. Three uses of the name should be kept apart. Task fine-tuning adapts a pretrained network to one labeled problem. Instruction tuning fine-tunes on many tasks written as natural-language instructions, aiming at held-out task types. The named SFT stage in post-training imitates demonstrations of desired responses, usually before preference optimization.[5][3] Pretraining an autoregressive Transformer estimates the next token on unlabeled text and does not designate a correct answer to a request.[11] SFT keeps that factorization and changes the data: each update raises the probability of a specified output given its input. Instruction tuning builds the pairs by rewriting supervised natural language processing datasets with templates. FLAN did this for a decoder-only model. T0, an encoder–decoder, reads the prompted input in the encoder and is trained by maximum likelihood to generate the target and never the input.[3][12] Task fine-tuning need not be generative. ULMFiT ends by training a classifier with label cross-entropy.[2] In alignment recipes the named SFT stage is the supervised policy that later methods start from. InstructGPT fine-tuned pretrained GPT-3 on labeler-written demonstrations, then collected rankings, trained a reward model, and optimized that policy with reinforcement learning from human feedback and proximal policy optimization.[5] Direct preference optimization draws the same line: SFT maximizes the likelihood of high-quality responses and supplies a reference policy, while the preference stage trains on pairs in which one completion is preferred to another.[9] SFT has no rejected completion to push down, and it does not add the penalty on drift from a reference model that those preference objectives impose.[9]Likelihood objective
For a causal model, write the prompt as and the target as tokens . The SFT objective is the conditional negative log-likelihood
the token-level cross-entropy of the next-token distribution . With teacher forcing, the model is scored for matching the demonstration token by token, not for finding some other string. Recipes describe the same quantity as cross-entropy on the target tokens.[13][14] The sum is also the pretraining loss; SFT changes which sequences appear and, commonly, which positions are included.[11]
The minimum is imitation of the fine-tuning targets, not a comparison among alternatives. DPO’s loss is a binary classification loss on a difference of log-probability ratios: a preferred and a dispreferred completion are each compared with a frozen reference, usually the SFT policy, and the update raises one likelihood relative to the other.[9] Validation likelihood is an incomplete way to choose the SFT checkpoint. In the InstructGPT runs, validation loss overfit after about one epoch, yet further epochs improved reward-model scores and human preference ratings, and the SFT model was selected by the reward-model score.[5]
Prompt masking and dialogue format
Implementations often leave prompt tokens out of the sum. Llama 2-Chat packed each sample as a prompt and an answer, separated them with a special token, used an autoregressive objective, and zeroed the loss on user-prompt tokens so that backpropagation used only answer tokens.[11] The Llama 3 supervised stage is described the same way—cross-entropy on target tokens, with the prompt masked—after each example is rendered in a chat protocol whose header tokens name the source of a message and whose termination tokens mark the end of a turn.[13] FLAN separated inputs from targets with an end-of-sequence token and used input and target lengths of 1024 and 256, so the trained span was the instructed output; T0’s decoder is likewise never trained to emit the input.[3][12] Full masking is a common default, not a settled optimum. A study of prompt-loss weight, where zero is masking and one is full-sequence loss, found that on short completions performance had a statistically significant negative quadratic relationship with that weight. Small nonzero weights, about 0.01 to 0.5, beat both extremes on the authors’ multiple-choice and short-generation checks; they attribute the gain to regularization rather than to a stabilizing effect. On long completions they report that the weight can be ignored.[14] The tokens inside the likelihood have to match inference. Dialogue SFT therefore fixes a template that marks roles such as system, user, and assistant, and trains the model to continue after the assistant marker. Skipping that supervised step, in a Zephyr ablation, left a preference-only model struggling to produce the role-marked template and scoring much worse on the authors’ chat benchmarks.[15] In multi-turn transcripts the mask falls on non-assistant spans, so the loss stays on the responses the demonstration is meant to teach.[11][13]History
Fine-tuning of pretrained models
Supervised adaptation of a network already trained on a broad source task was worked out first in vision. Convolutional neural networks trained on ImageNet learned early-layer features, similar to Gabor filters and color blobs, that were not tied to one label set. In 2014 Jason Yosinski, Jeff Clune, Yoshua Bengio, and Hod Lipson found that transfer worsened in higher layers and across more distant label sets, from specialization and from co-adaptation between layers, and that fine-tuning the copied weights beat freezing them.[16]
Instruction tuning of language models
The next line fine-tuned once on many tasks written as instructions and tested zero-shot transfer to tasks held out of that run. Swaroop Mishra, Daniel Khashabi, Chitta Baral, and Hannaneh Hajishirzi built Natural Instructions from crowdsourcing guidelines for existing datasets: 61 tasks and about 193,000 instances. Models that saw the instructions generalized about 19% better to unseen tasks in their comparison, still far from an estimated ceiling.[20] Super-NaturalInstructions, with contributors including the Allen Institute for AI, expanded the collection to 1,616 tasks. Their T5-based Tk-Instruct beat much larger models, including InstructGPT, by more than 9% on the benchmark’s unseen English tasks.[21] Jason Wei and colleagues at Google called the procedure instruction tuning. FLAN, a 137-billion-parameter model fine-tuned on more than 60 templated datasets, beat its untuned base and zero-shot GPT-3 (175 billion parameters) on 20 of 25 unseen task types, and beat few-shot GPT-3 on part of that suite. Dataset count, scale, and instruction wording mattered in the ablations.[3] Victor Sanh, Albert Webson, Colin Raffel, Stephen Bach, and collaborators at BigScience and Hugging Face tested whether explicit multitask training, rather than pretraining alone, produced the effect. T0 fine-tuned an encoder–decoder on supervised sets rewritten with many PromptSource prompts and often outperformed models up to 16 times larger on held-out tasks.[12] Scaling studies then varied the size of the mixture. Hyung Won Chung and colleagues instruction-finetuned PaLM, T5, and U-PaLM on about 1,800 tasks, some with chain-of-thought answers. Flan-PaLM 540B gained 9.4 points on average over pretrained PaLM, and smaller Flan-T5 checkpoints were released.[4] Niklas Muennighoff and other BigScience authors applied the same multitask prompting to BLOOM and mT5, producing BLOOMZ and mT0. English prompts already transferred to languages seen only in pretraining, and the xP3 mixture of supervised data in 46 languages raised zero-shot scores in English and beyond.[22]Demonstration-based alignment
A demonstration of a desired answer is a different supervised target from a relabeled benchmark. Daniel Ziegler and colleagues adapted GPT-2 with a reward model of human comparisons for style and summarization.[23] Nisan Stiennon and colleagues then showed, on Reddit TL;DR, that optimizing those preferences beat both the reference summaries and much larger models trained only to imitate the references.[24] Long Ouyang and colleagues made demonstrations the first stage for GPT-3. About 40 contractors wrote answers for roughly 13,000 prompts from labeler-written instructions and the OpenAI API. Supervised fine-tuning on those answers was followed by a reward model of human rankings and by reinforcement learning, producing InstructGPT. On the authors’ prompt distribution, raters preferred the 1.3-billion-parameter InstructGPT model to 175-billion-parameter GPT-3, with reported gains in truthfulness and lower toxicity. Fine-tunes on the public FLAN and T0 mixtures trailed the demonstration-only supervised baseline there.[5] Reinforcement learning from human feedback therefore added a stage rather than replacing supervised training. Anthropic’s Constitutional AI instead fine-tuned on the model’s own revisions, prompted by a written list of principles, and then used reinforcement learning from AI preferences.[25] Open pretrained large language models then carried demonstrations outside one vendor’s contractors. Yizhong Wang and colleagues’ Self-Instruct had GPT-3 draft instructions and answers, filtered them, and fine-tuned the same model, reporting a 33-point gain on Super-NaturalInstructions, near an early private-data InstructGPT, and a 5-point gap on a separate review of expert-written tasks.[7] In March 2023 Rohan Taori and colleagues at Stanford University fine-tuned LLaMA 7B on 52,000 text-davinci-003 demonstrations in that style, at a stated cost under $600, and released the recipe for academic use only because of LLaMA’s license, OpenAI’s terms, and missing safety filters. A resemblance to text-davinci-003 was their preliminary check, not an independent test.[26] OpenAssistant released 161,443 crowdsourced messages in 35 languages, from more than 13,500 volunteers, for supervised fine-tuning and preference training.[27] The useful size of that set was also tested. Chunting Zhou and colleagues’ LIMA fine-tuned a 65-billion-parameter LLaMA on 1,000 curated demonstrations and no preference model; in their study it tied or beat GPT-4 in 43% of cases, which they read as evidence that pretraining holds most capabilities and supervised fine-tuning mainly teaches format.[8] Meta’s Llama 2-Chat models, from 7 to 70 billion parameters, set aside bulk third-party instruction data as too narrow for dialogue, trained on 27,540 vendor demonstrations with no Meta user data and with the loss masked on user tokens, and only then collected preferences for reinforcement learning, after supervised samples often rivaled the handwritten answers.[11]Training data
Supervised fine-tuning of large language models trains on paired prompts and target responses. Those pairs have been written by contractors, volunteers, or employees; made by casting public natural language processing datasets as instructions; taken from curated community answers; or sampled from an already capable model, and open recipes usually combine several of these sources.[28]Human demonstrations
For InstructGPT, OpenAI hired about 40 contractors through Upwork and Scale AI to demonstrate desired behavior on API Playground prompts and on prompts the labelers wrote. The supervised set contained about 13,000 training prompts and was more than 96 percent English; rankings for the reward model in reinforcement learning from human feedback were collected separately.[5] OpenAssistant Conversations came from more than 13,500 volunteers: 161,443 messages in 66,497 conversation trees across 35 languages, with 461,292 quality ratings and 10,968 trees counted as complete. Of the messages, 8,576 are synthetic. The authors describe the licence as fully permissive.[27] Separately, more than 5,000 Databricks employees wrote the 15,000 English pairs in databricks-dolly-15k in March–April 2023, in categories such as question answering, extraction, summarization, and brainstorming. They were told not to use generative models, though closed tasks could quote Wikipedia. The set uses Creative Commons Attribution-ShareAlike 3.0.[29] A parallel line reformats existing tasks instead of soliciting new chats. Wei and colleagues grouped 62 public datasets into twelve clusters and wrote ten natural-language templates per dataset, including some that inverted the original task.[3] Chung and colleagues expanded the pool to 473 datasets and 1,836 tasks from that collection, T0, and Natural Instructions, plus dialogue, program synthesis, and chain-of-thought data, and removed MMLU items so the benchmark stayed held out.[4] Super-NaturalInstructions is itself 1,616 tasks with expert-written instructions across 76 task types.[21] LIMA used exactly 1,000 training sequences, about 750,000 tokens, from highly rated Stack Exchange answers, wikiHow, Reddit writing prompts, a Natural Instructions slice, and author-written examples in one assistant style.[8]Synthetic data
Self-Instruct starts from 175 author-written seed tasks and prompts unmodified GPT-3 to propose instructions, inputs, and outputs, then drops invalid or near-duplicate samples. The release has about 52,000 instructions and about 82,000 instances. Fine-tuning GPT-3 on it raised Super-NaturalInstructions by 33 absolute points, matching InstructGPT-001 on that benchmark, and left a 5-point gap to InstructGPT-001 in a human evaluation on novel tasks.[7] Stanford University’s Alpaca drew about 52,000 demonstrations from text-davinci-003 and fine-tuned Meta’s LLaMA 7B. The data are CC BY-NC 4.0 and were released for academic research; the authors also cited LLaMA’s non-commercial terms and OpenAI’s limits on competing models.[26][30] Evol-Instruct, used for WizardLM, rewrites a seed such as Alpaca. In-depth edits add constraints or reasoning steps, in-breadth edits propose a new but related instruction, and a filter drops failures. Four rounds produced about 250,000 instructions. A LLaMA-13B model trained on 70,000 of them, a scale chosen to match Vicuna’s ShareGPT set, was preferred to Alpaca and Vicuna in the authors’ human evaluation, and to ChatGPT on their high-complexity slice.[31] UltraChat contains about 1.5 million multi-turn dialogues and no human queries: two ChatGPT instances play user and assistant.[32] ShareGPT is mixed in origin—people shared their prompts along with model completions. The exact Vicuna subset was not released, so later mixtures used public reproductions split into shorter blocks.[28] Imitation does not by itself transfer measured skill. Gudibande and colleagues fine-tuned 1.5 billion- to 13 billion-parameter models on ChatGPT outputs; crowd raters often judged the copies competitive with ChatGPT, but benchmarks on tasks thinly represented in the data closed little of the gap. Style transferred more readily than factual accuracy.[33]Mixture design and quality
In the Allen Institute for AI comparison behind Tülu, chain-of-thought data helped grade-school math, code data helped coding, and ShareGPT or GPT-4 Alpaca helped open-ended following, but no dataset or mixture led every evaluation. Most single sets lowered GSM and TyDiQA versus the untuned base model; the authors attribute that to scarce reasoning traces and multilingual text, and so to forgetting. Self-Instruct, from base GPT-3, was weak on most tasks. Concatenating sampled FLAN and chain-of-thought data with Dolly, OpenAssistant, GPT-4 Alpaca, Code Alpaca, and ShareGPT gave the best average. Preference ratings did not track the benchmark gaps.[28] Tülu 2 cut the supervised mix from 490,445 to 326,154 examples: 50,000 FLAN v2 examples and 50,000 chain-of-thought examples, 7,708 top-rated OpenAssistant paths, 114,046 processed ShareGPT conversations, 20,000 GPT-4 Alpaca examples, 20,022 Code Alpaca examples, 1,030 LIMA examples, 30,000 WizardLM examples, 30,000 GPT-4 OpenOrca examples, 7,544 scientific-document tasks, and 140 author-written prompts. Dolly was dropped after weak earlier ablations.[34] Longpre and colleagues found task balancing and richer templates easy to underweight, and found that mixing zero-shot, few-shot, and chain-of-thought prompts improved every setting they measured by more than two points.[35] Quality and scale do not trade off in only one direction. LIMA’s superficial alignment hypothesis says pretraining already holds most knowledge and supervised tuning mainly selects a style. In that study, LIMA was equivalent or preferred to GPT-4 in 43 percent of cases, to Bard in 58 percent, and to text-davinci-003 in 65 percent.[8] Within one noisy corpus, AlpaGasus kept about 9,000 of Alpaca’s roughly 52,000 examples after a chat model scored them, and that subset beat the full set on the authors’ GPT-4 and human evaluations.[36] A 2024 study of Llama-2, Llama-3, and Mistral instead found math, coding, instruction following, and multi-hop question answering scaling as a power law in the number of fine-tuning examples. A handful of examples mainly changed style and did not saturate those benchmarks, and post-training could add knowledge rather than only restyle pretraining. The authors call the hypothesis at best an oversimplification when evaluation stops at preference or format.[37]Optimization methods
Supervised fine-tuning minimizes next-token cross-entropy on labeled demonstrations. The choice is which parameters move: every pretrained weight, or a small module on a frozen large language model, sometimes stored at low precision. Learning rate, sequence packing, and limits on drift from the pretrained model determine what those labels change.Full-parameter fine-tuning
Full fine-tuning starts from the pretrained weights and updates all of them under the conditional language-modeling loss, the sum of log probabilities of target tokens given the prompt and earlier targets.[38] Optimizers such as Adam also store moment estimates, so memory scales with the full parameter count. Llama 2 pretraining peaked at for the 7B and 13B models and for the 34B and 70B models; supervised fine-tuning used a cosine schedule from , weight decay 0.1, batch size 64, length 4,096, and two epochs.[39] Prompts and answers were concatenated with a separator, and the loss on user-prompt tokens was zeroed.[39] The largest Llama 3 models used for about 8,500 to 9,000 steps, with loss only on target tokens.[40] InstructGPT fine-tuned GPT-3 for 16 epochs at for the 1.3B and 6B models and for 175B.[41] Validation loss overfit after about one epoch, but further epochs improved reward-model scores and human preferences, so checkpoints were chosen by reward-model score rather than validation loss.[41] A two-epoch run used to initialize later preference optimization mixed in 10% pretraining tokens.[41] Sequence packing concatenates variable-length examples instead of padding each one. On Llama 3 models from 8B to 70B and supervised sets from about 69,000 to 1.2 million examples, packing beat padding on average, with a larger gap at 70B, and greedy packing beat random packing on instruction following by keeping multi-turn conversations intact.[42] One 70B chat run took 3,749 seconds with random packing versus 9,533 with padding.[42] Batch size and learning rate were no longer proportional under packing, and packing only single-turn data can create false multi-turn context that hurts few-shot scores.[42]Parameter-efficient adaptation
Parameter-efficient methods freeze the pretrained network and store a small task-specific increment. Houlsby et al. inserted bottleneck adapters after attention and the feed-forward sublayer of BERT, training the adapters, layer-normalization parameters, and a classifier. On GLUE, BERT-Large adapters scored 80.0 against 80.4 for full fine-tuning at about 3.6% extra parameters per task.[43] Prefix-tuning learns continuous vectors inside each Transformer layer.[44] Prompt tuning learns only a short input soft prompt and, at T5 scales of billions of parameters, approached full tuning with tens of thousands of parameters per task.[45] Adapters add inference latency, and prefixes occupy context length.[38]