Instruction Following › Instruction Format Design
Language AI HandbookAll chapters Instruction Following › Instruction Format DesignOne section · Sections in this chapter4 / 12 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Creating effective instruction-tuning data requires careful attention to format. The structure of training examples teaches models what inputs to expect and what outputs to produce. A well-designed format makes the distinction between instruction, input, and response crystal clear, helping the model learn the appropriate boundaries and behaviors. Several components define an instruction format, and each plays a useful role in the training signal.
The format affects model behavior. Because language models learn by pattern-matching, the consistent structural markers in your instruction format become reliable behavioral cues. When a model is trained on thousands of examples that always place the task description after "### Instruction:" and the expected response after "### Response:", these tokens activate instruction-following behavior. The specific delimiter tokens matter: a model tuned on one format may perform poorly with a different format because the activating cues are absent. This is why production systems preserve their instruction format at inference time and why deviating from the training format often degrades performance.
Instruction Component
The instruction component tells the model what to do. This is the core directive that specifies the task the model should perform. Effective instructions are clear and specific enough to act on:
- Clear: "Translate the following English sentence to Spanish" leaves no ambiguity about the task. The model knows exactly what language pair to work with and what direction the translation should go.
- Specific: "Summarize in exactly three sentences" provides concrete constraints that guide the model's output. Without such specificity, the model must guess at the appropriate length and format.
- Actionable: The instruction describes something the model can generate as text output. Instructions like "feel happy about this text" aren't actionable because they don't translate into specific textual output.
Instructions can range from single-word commands ("Translate:") to detailed multi-sentence specifications explaining exactly what output is expected. The level of detail often depends on the task complexity and the desired output format. Simple tasks may need only brief instructions, while complex tasks benefit from more elaborate specifications that reduce ambiguity and set clear expectations.
The quality of the instruction component has an asymmetric effect on what models learn. A vague instruction paired with a high-quality response still teaches the model to produce good responses, but it doesn't teach the model to consistently recognize what type of response is being requested. Conversely, a precise, clear instruction paired with a mediocre response teaches the model a pattern for recognizing requests but produces suboptimal output quality. This asymmetry suggests that both instruction quality and response quality matter, but they matter for different aspects of the model's behavior.
Input Component
Many instructions operate on provided content. The input component contains the material the model should process, serving as the raw data that the instruction acts upon:
Instruction: Summarize the following article.
Input: [article text here]Some instructions don't require separate input (e.g., "Write a haiku about spring") while others are meaningless without it (e.g., "Translate the following sentence"). The format must clearly distinguish the instruction from the input to prevent confusion. Without clear separation, the model might incorporate parts of the instruction into its understanding of the input, or vice versa, leading to incorrect responses.
The presence or absence of an explicit input field also carries meaning. When your training data uses a consistent format where the input field is present for some task types and absent for others, the model learns that "tasks with input fields require processing external content" versus "tasks without input fields require generation from scratch." This distinction helps the model correctly interpret instruction-only prompts at inference time without getting confused about where to find content to process.
Output Component
The output (or response) component contains the desired model behavior. During training, this is the target text the model learns to generate. The output should directly address the instruction and, where applicable, properly process the input. This component is the ground truth that the model optimizes toward during training.
Quality outputs exhibit several properties:
- Responsiveness: The output addresses exactly what the instruction asks. A summarization instruction should produce a summary, not additional commentary or tangential information.
- Completeness: All parts of the instruction are fulfilled. If the instruction asks for three points, the output should contain three points, not two or four.
- Conciseness: No unnecessary elaboration beyond what's requested. Verbose responses that pad the output with irrelevant information teach the model to be similarly unfocused.
- Correctness: Factually accurate and logically sound. Training on incorrect outputs teaches the model to produce errors confidently.
The output component is where training data quality has the most direct impact on deployed model behavior. If you train on incorrect outputs, the model learns to be confidently wrong. If you train on verbose, padded outputs, the model learns to pad. If you train on outputs that technically address the instruction but miss the spirit of what was asked, the model learns similarly evasive responses. The model is, in a very literal sense, learning to imitate the outputs in your training set. This makes output quality the most consequential investment in instruction data creation.
Format Templates
Instruction-tuning datasets typically use consistent templates to structure examples. A common template might look like:
### Instruction:
{instruction_text}
### Input:
{input_text}
### Response:
{output_text}The specific delimiters and formatting vary across datasets, but consistency within a dataset helps models learn the pattern reliably. When the model sees consistent markers like "### Instruction:" and "### Response:", it learns to associate these patterns with the instruction-following behavior. This consistency reduces ambiguity and accelerates learning. We'll explore format templates in depth in the upcoming chapter on instruction format.
Different template designs carry different tradeoffs. The minimal template above (used in Alpaca and many derivative datasets) is compact and easy to parse, but provides no system-level context about the model's role. Templates that include a preamble like "Below is an instruction that describes a task. Write a response that appropriately completes the request" add context that may help the model maintain its role as an assistant, at the cost of extra tokens in every training example. Chat-oriented templates that distinguish between user and assistant turns (as in OpenAI's ChatML format) are better suited for multi-turn conversations but require the training data to include appropriate turn boundaries. The choice of template should match how you intend to use the model in deployment.