Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path →
Teach
itself.
Instruction tuning is what turns a raw language model into something that actually does what you ask — but it used to need mountains of hand-written examples, each one a person typing out a task, an input, and an ideal answer. Self-Instruct asked the cheeky question: what if the model wrote its own homework? Start with 175 human tasks, prompt the model to invent thousands more, throw away the near-duplicates, and fine-tune on what's left. The seed of Alpaca and a hundred open instruction-tuned models. Here's the bootstrapping loop, and the ROUGE-L overlap filter that keeps the data from eating its own tail.
What changes against both: the instruction data is generated
Rungs 1 and 2 both need a large set of instructions to train on, and rung 1's came from people writing them. That is the binding constraint on instruction tuning, because the quantity needed is large and the writing is skilled work. This rung's change is to bootstrap the dataset out of the model itself, starting from a seed set small enough for one person to author — on the order of a couple of hundred tasks.
The loop is simple: sample a few seed instructions as examples, ask the model to write new ones, then ask it to produce the input and output for each, add the survivors to the pool, and draw the next round's examples from the enlarged pool. Run it long enough and a couple of hundred human-written tasks become tens of thousands.
The part that makes it work is the filter, and this is the rung's real content. Generation from a pool that includes its own output collapses toward whatever the model finds easy to produce — run the loop without filtering and you get thousands of paraphrases of the same handful of tasks. So a new instruction is rejected unless its overlap with every existing instruction is below a threshold, measured by longest-common-subsequence similarity. Diversity is not hoped for; it is enforced as an admission criterion, and the criterion is the method.
Homework the model writes
A pretrained language model knows a great deal but doesn't reliably do what you ask — it completes text rather than following instructions. Instruction tuning fixes that by fine-tuning on many (instruction, input, output) examples. The catch, circa 2022, was cost: those examples were written by people, task by task, which is slow, expensive, and hard to scale to the breadth of things users actually want.
Self-Instruct (Wang et al., 2022) offered a way around the bottleneck: have the model generate its own instruction data. You seed the process with a small set of human-written tasks — the paper used 175 — and then repeatedly ask the model to invent new instructions in the same spirit, produce inputs and outputs for them, filter aggressively, and fold the survivors back into the pool. Run the loop and 175 seeds bloom into tens of thousands of diverse tasks, enough to fine-tune a base model into a capable instruction-follower for almost no annotation cost. The trick that keeps it from degenerating is a diversity filter.
Bootstrap instruction data from the model itself: sample existing tasks as examples, prompt the model to write new instructions + input/output instances, filter out near-duplicates (ROUGE-L similarity ≥ 0.7) and low-quality ones, add survivors to the pool, repeat — turning a tiny seed set into a large, diverse instruction-tuning dataset.
The bootstrapping loop
Self-Instruct is a generate → filter → add loop over a growing pool of tasks:
The loop is self-amplifying in a good way: because each round samples examples from an ever-larger, ever-more-varied pool, the model is nudged toward inventing tasks unlike the ones it's already seen, so coverage expands instead of circling the original 175. For generating the actual answers, the paper also handles classification and free-form tasks slightly differently (generating the output-first or input-first) to keep the instances well-formed. But the engine is simple: the model proposes, a filter disposes, and the survivors become the next round's teachers.
Keeping it diverse
Left unchecked, a model told to "write new instructions" will mostly produce rephrasings of what it just saw — "Write a poem about the sea," "Compose a poem about the ocean," "Create a poem regarding the sea." A dataset full of those teaches almost nothing; the fine-tuned model would be broad in wording but narrow in skill. Diversity, not raw volume, is what makes the synthetic data valuable.
Self-Instruct enforces diversity with a deduplication filter based on ROUGE-L similarity — an overlap score built from the longest common subsequence of tokens between two instructions. For each candidate instruction, it computes the maximum ROUGE-L against every instruction already in the pool, and keeps the candidate only if that maximum is below 0.7. Anything too close to an existing task is discarded before it can dilute the pool. This one threshold is what turns "generate a lot of text" into "generate a lot of genuinely different tasks," and it's the quantitative heart of the method.
ROUGE-L, precisely
ROUGE-L scores overlap by the longest common subsequence (LCS) — the longest sequence of tokens appearing in both instructions in the same order, gaps allowed. From the LCS length you form a precision, a recall, and their F1:
c is the candidate instruction's tokens, r a reference's; |·| is token count. Identical instructions score 1.0; instructions with no common subsequence score 0.0.
The keep/reject rule is then a simple max-and-threshold over the whole pool:
If the candidate is within 0.7 similarity of ANY existing instruction, it's a near-duplicate and dropped. Otherwise it's novel enough to add. The runnable version below implements LCS, ROUGE-L, and this novelty check.
How Self-Instruct builds its dataset, step by step
Self-Instruct uses one model for everything. Vanilla GPT-3, the davinci engine with no instruction tuning, writes the instructions, sorts them, writes their inputs and outputs, and is finally fine-tuned on the result. The only human input is 175 seed tasks written by the authors and their colleagues, each one instruction with one example input and output; 25 of the 175 are classification tasks.
- Prompt for new instructions. Each generation step samples 8 instructions from the pool as in-context examples: 6 from the human seeds and 2 from tasks the model generated in earlier steps. The prompt is a plain numbered list, a one-line request to come up with a series of tasks, the eight sampled instructions as Task 1 to Task 8, then an empty Task 9 line that the model completes by continuing the list.
- Identify classification tasks. A second few-shot prompt, built from 12 classification and 19 non-classification seed instructions, asks whether each new task has a small, finite set of output labels.
- Generate instances in the right order. Non-classification tasks are input-first: the model writes an input, then the output for it. Classification tasks are output-first: the model lists the possible labels, then writes an input for each label. Input-first generation on classification produced inputs skewed toward one label; for grammar-error detection, the inputs came out mostly grammatical.
- Filter. A new instruction is admitted only if its ROUGE-L similarity to every instruction already in the pool is below 0.7. Instructions that mention images, pictures or graphs are dropped, since a text model cannot act on them. Instances that exactly duplicate one another, or share an input but disagree on the output, are removed, and heuristics drop instructions that are too long or too short and outputs that merely repeat the input.
- Add and repeat. Survivors join the pool, so later steps sample from a larger, more varied set. The final dataset holds about 52,445 instructions and 82,439 instances. Generating it cost about $600 in API fees at December 2022 prices.
- Fine-tune. GPT-3 davinci was fine-tuned on the data through the OpenAI API for two epochs, with the prompt-loss weight set to zero so only outputs are learned. The layout of instruction, input and output was randomized, with or without a Task: prefix, an Input: prefix, an Output: suffix and different line breaks, so the model would not depend on one template.
What the model learns from
The tuned model, GPT3SELF-INST, takes an instruction and an optional input and returns an output, like any instruction-tuned model. Everything it learned came from text GPT-3 wrote: the seeds set the style, the classification check and generation order keep instances well formed, and the similarity filter keeps the pool from collapsing into paraphrases of a few tasks. No person labeled a generated example during the run; quality was checked afterwards, by auditing a random sample.
Self-Instruct's two generation orders, as probabilities
Write t for an instruction, x for an input (possibly empty) and y for an output or label. The two orders Self-Instruct uses factor the same joint distribution differently:
p(x | t)— the model's idea of a typical input for the task. For a classification task, typical inputs cluster on whichever label is most common in text.p(x | t, y)— an input written to fit a given label. Enumerating the labels first guarantees every label gets an example.log pθ(y | t, x)— the fine-tuning loss covers only the output, because the prompt-loss weight was set to zero.
At the extremes: a free-form task has no finite label set, so output-first is impossible and input-first is the only option. A binary classification task with one dominant label is the opposite case: input-first could yield a dataset in which the minority label barely appears, which is the failure the output-first order exists to prevent.
What Self-Instruct measured, and what it found
The tuned model was evaluated zero-shot on the Super-NaturalInstructions (SuperNI) benchmark, scored by ROUGE-L, and on 252 new instructions the authors wrote to resemble real user requests, rated by experts on a four-level scale from correct and satisfying down to irrelevant or invalid. Baselines included vanilla GPT-3, models trained on public instruction collections, and OpenAI's InstructGPT-001.
| Model | SuperNI zero-shot ROUGE-L |
|---|---|
| Vanilla GPT-3 | 6.8 |
| T0 | 33.1 |
| GPT-3 + T0 training data | 37.9 |
| GPT-3 + Self-Instruct | 39.9 |
| InstructGPT-001 | 40.8 |
| GPT-3 + SuperNI training data | 49.5 |
| GPT-3 + Self-Instruct + SuperNI | 51.6 |
The 33.1-point gain over vanilla GPT-3 used no human-written instruction data beyond the seeds, and the generated data still added 2.1 points on top of SuperNI's own training set, which matches the benchmark's format. On the 252 user-oriented instructions, counting responses rated acceptable or better, the Self-Instruct model beat GPT-3 tuned on public collections by a wide margin and finished about 5 points behind InstructGPT-001.
The audit of 200 random samples is the sobering part: 92% of instructions described a valid task, but only 79% of inputs were appropriate, 58% of outputs were correct, and just 54% of instances were right in every field. More data improved human-rated quality up to about 16K examples and then plateaued, and on SuperNI the gains flattened after a few hundred instructions. Regenerating the outputs with the stronger InstructGPT-003 improved the tuned model by about 10%, which points at output quality, not quantity, as the bottleneck.
What the authors admit, and what happened next
The paper is honest that the resulting data is noisier than human-written data — instructions that are ill-posed, outputs that are wrong — and that the mixture inherits the generating model's distribution, so it is skewed toward what that model already does and thin where it is weak. The diversity ceiling is also bounded by the seed: the overlap filter can keep the pool from collapsing, but it cannot invent a task family the seeds never gestured at.
The deeper concern was not visible yet and belongs here anyway. This rung is the origin point of the practice of training models on model output, which the field has since spent considerable effort worrying about: a generated corpus concentrates the generator's distribution, and the errors are correlated rather than random, which is a different and harder problem than noise. This rung is not a cautionary tale — the technique works and is everywhere — but it is where the question starts.
How it held up: it won so completely that it stopped being remarked on. Synthetic instruction data is the default, and the wave of small open instruction-tuned models that followed ran essentially this loop against a stronger teacher. The two lasting lessons are the filter and its reason: a generation loop needs an explicit diversity criterion or it degenerates, and the criterion is cheap to compute while the degeneration is expensive to notice.
The diversity filter, from scratch
Self-Instruct's diversity filter is a ROUGE-L overlap check, and ROUGE-L is built on the longest common subsequence of tokens. Here it is with no libraries: an LCS via dynamic programming, the ROUGE-L F1 from it, the max similarity against a pool, and the novelty test that keeps an instruction only if it's below the 0.7 threshold. A near-duplicate of a pooled task is rejected; a genuinely new one passes. Change the instructions and the threshold and watch the filter decide.
Write the body of lcs_length. Everything else in the file is
already written; this is the function the paper is about. Press ▶ Run to check it against
the 5 assertions below — they start red.
- The LCS of two identical token lists is the full length
- The LCS picks the longest common SUBSEQUENCE (order preserved, gaps allowed)
- ROUGE-L of an instruction with itself is 1.0 (perfect overlap)
- ROUGE-L of two disjoint instructions is 0.0 (no shared subsequence)
- A near-duplicate of a pooled instruction is REJECTED (not novel) at threshold 0.7
The synthetic-data era
Self-Instruct lit the fuse on open instruction tuning. Within months, Stanford's Alpaca applied the same recipe — generating ~52,000 instructions with a simplified Self-Instruct-style pipeline, this time using a stronger teacher model (text-davinci-003) to write both the instructions and the answers — and fine-tuned LLaMA into a surprisingly capable assistant for a few hundred dollars. A cascade of follow-ups (Vicuna, WizardLM's instruction-evolution, and many others) built on the pattern, and "generate instruction data with a capable model, filter for diversity and quality, fine-tune" became a standard playbook.
More broadly, it's a landmark in synthetic data and model self-improvement. The idea that a strong model can manufacture training data for another connects it directly to knowledge distillation (the teacher's outputs as a training signal) and complements the human-feedback approach of InstructGPT and the AI-feedback approach of Constitutional AI. Today, high-quality synthetic and model-generated data is a central ingredient in training frontier and small models alike — and Self-Instruct is the paper that showed a tiny seed and a filter could go a very long way.
The distinction between Self-Instruct and Alpaca is worth keeping straight. The original Self-Instruct used a model to generate data for itself (GPT-3 generating tasks to fine-tune GPT-3) — genuine self-improvement. Alpaca used a simplified version of the same pipeline but a stronger teacher (text-davinci-003, a GPT-3.5-class model) to write both the instructions and the answers for fine-tuning a weaker student (LLaMA) — which is really distillation. Both are "Self-Instruct-style," but only one is actually the model teaching itself.
Questions people ask about Self-Instruct
What does the Self-Instruct prompt template look like?
The instruction-generation prompt is a plain numbered list. It opens with a one-line request asking the model to come up with a series of tasks, then lists eight existing instructions as Task 1 through Task 8, six sampled from the 175 human-written seed tasks and two from tasks the model generated earlier, and ends with an empty Task 9 line for the model to complete. This prompt contains only instructions, no inputs or outputs. Separate few-shot prompts then decide whether each new task is a classification task and generate its instances: input-first for ordinary tasks, and output-first, labels before inputs, for classification tasks.
How is Stanford Alpaca different from Self-Instruct?
Self-Instruct used vanilla GPT-3 to generate data and then fine-tuned that same GPT-3, so the model taught itself. Alpaca, released by Stanford in March 2023, kept the idea but changed the roles: it used OpenAI's text-davinci-003, a stronger instruction-tuned model, to generate 52K instructions and answers, then fine-tuned Meta's LLaMA 7B on them, which makes it closer to distillation from a teacher than to self-improvement. Alpaca also simplified the pipeline, generating 20 instructions per call, dropping the separate classification branch and producing one instance per instruction instead of several. It reused Self-Instruct's 175 human-written seed tasks.
Why does Self-Instruct generate the output first for classification tasks?
Because asking for the input first produced skewed classification data. Told to write an example input for a task such as detecting grammatical errors, the model tends to write the most typical kind of input, which for that task means mostly grammatical sentences, so one label dominates. Self-Instruct therefore detects classification tasks with a separate few-shot prompt and, for those, has the model list the possible class labels first and then write an input that fits each label, so every label gets at least one example. Free-form tasks keep the input-first order, because they have no finite label set to enumerate.
How noisy is the data Self-Instruct generates?
Noticeably. The authors audited 200 randomly sampled instructions with one instance each. 92% of the instructions described a valid task, 79% of the inputs were appropriate for their instruction, 58% of the outputs were correct, and only 54% of instances had every field valid, so almost half the training examples contained at least one error, mostly in the outputs. The data still helped a great deal, because most flawed examples are in the right format and partly right, and the model learns the shape of instruction following from them. Regenerating the outputs with a stronger model, InstructGPT-003, improved results by about 10%.
How did Self-Instruct compare with InstructGPT?
Closely, for a model trained on data it wrote itself. On the Super-NaturalInstructions benchmark, GPT-3 fine-tuned on Self-Instruct data scored 39.9 ROUGE-L zero-shot, against 40.8 for InstructGPT-001 and 6.8 for vanilla GPT-3. On 252 user-oriented instructions rated by human experts, it trailed InstructGPT-001 by about 5 percentage points in the share of acceptable responses, while clearly beating GPT-3 tuned on public instruction datasets. The comparison is with InstructGPT-001, an early OpenAI instruction-following model built from human-labeled data; Self-Instruct needed only 175 seed tasks and about $600 of generation.
4 questions to test what you just read
Work each one out before you open it — a number, a prediction or a reason, not a definition. Producing the answer is what makes it stick. Your progress is kept on this device.
Self-Instruct data raised GPT-3's SuperNI score from 6.8 to 39.9, and InstructGPT-001 scored 40.8. What fraction of the gap between vanilla GPT-3 and InstructGPT-001 did self-generated data close?
Show answer
The gap is 40.8 − 6.8 = 34.0 points. Self-Instruct closed 39.9 − 6.8 = 33.1 of them, about 97%, with no human-written instruction data beyond the 175 seeds and nothing but GPT-3's own generations.
Predict the label balance if Self-Instruct had used input-first generation for a task that asks whether a sentence contains a grammatical error. Why does output-first fix it?
Show answer
Skewed toward no error: asked for a typical input, the model mostly writes grammatical sentences, which is what the paper observed. Output-first writes the label set first and then an input for each label, so the model must produce an ungrammatical sentence for the error label and every class gets at least one example.
Each generation prompt holds 8 examples, 6 human seeds and 2 generated. What job does each part of that mix do?
Show answer
The 2 generated examples were added to promote diversity: they show the model tasks unlike the original 175, so new instructions spread out. Keeping 75% human-written anchors style and quality, which matters because generated tasks are noisy (only 54% of audited instances were fully valid) and drift toward what the model finds easy.
Only 54% of audited instances were fully correct, yet the data lifted SuperNI ROUGE-L by 33 points. Why does such noisy data still help this much?
Show answer
Most of what a base model lacks is the habit of treating text as an instruction to carry out rather than a document to continue. Even a flawed example demonstrates that format: instruction, optional input, then a direct response. That survives wrong outputs. Output quality matters for the next increment, which is why regenerating outputs with InstructGPT-003 added about 10%.
Teaching a base model to follow
A pre-trained model completes text; it does not take instructions. Nine papers on getting from one to the other, from RLHF to a loss with no reward model in it.
Explore the topic
See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.
More Paper Breakdowns
- Attention Is All You NeedThe paper that introduced the Transformer — the architecture underneath GPT, BERT, Claude, and Gemini. Self-attention, Query/Key/Value, multi-head attention, positional encoding, and the real BLEU results, explained in depth with analogies and animated visuals, not just equations.Read →
- Word2VecHow words became math. Dense word vectors learned from the company a word keeps, so king − man + woman lands near queen. Skip-gram, CBOW, the distributional hypothesis, and the origin of every embedding model powering search and RAG.Read →
- ResNetThe skip connection that made deep learning deep. Why stacking layers made networks worse, and how residual learning let them reach 150+ layers and win ImageNet — the identity shortcut every Transformer still uses inside every block.Read →
- Vision Transformer (ViT)When an image became 16×16 words. Cut a picture into patches, treat each patch as a token, and feed them to a plain Transformer — no convolutions. Patch embeddings, the class token, and why data scale lets attention beat the CNNs that ruled computer vision for a decade.Read →
- Latent DiffusionThe paper behind Stable Diffusion. Compress an image into a small latent space with a VAE, run the diffusion denoising there instead of on pixels for a tens-of-times efficiency win, and steer it with text via cross-attention. The architecture that put text-to-image generation on consumer GPUs.Read →
- DDPMThe original denoising diffusion math — the paper that made diffusion work. A fixed forward process adds Gaussian noise over many steps; a U-Net learns the reverse. The masterstroke: train the network to simply predict the added noise with a plain MSE loss. The foundation under every modern image generator.Read →