Zenaique

Alpaca format examples carry three fields: name them

Flashcard·Easy·4.0 · 0·~30s·Asked atAutodeskCloudflareIBM·Relevant atCoreweaveDatabricksFireworks AiLambda Labs
Attempt it
TL;DR

instruction, input, output. Instruction states the task, input supplies optional context, output is the gold response. Instruction plus input become the prompt; only output enters the loss.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a homework worksheet with three boxes for each question. Box one says what you have to do, like 'translate this sentence into French'. Box two holds the thing you are working on, like the English sentence itself, or it stays blank if the task is self-contained like 'write a poem about clouds'. Box three is the model answer the teacher will grade against. When the student trains, the teacher hands over box one and box two as the assignment and grades only box three. The Alpaca dataset shape works exactly like that, with the same three boxes per row. The middle box is the one that is sometimes empty.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

The Alpaca format is the canonical reference for single-turn instruction-tuning data. It has three fields, an extremely simple JSON shape, and a specific training-time template that turns each example into a prompt plus output pair suitable for completion-only SFT. Knowing the shape cold is useful both because it appears in many derived datasets and because most modern training frameworks accept it natively.

The three fields are instruction, input, and output. The instruction field is mandatory and states the task. The input field is conditionally present and supplies any context the task operates on. The output field is mandatory and carries the gold response. About 40 percent of original Alpaca examples have an empty input because the instruction is self-contained, which is one of the most commonly missed details about the format.

The shape was introduced by Stanford's Alpaca project in March 2023 as the storage format for 52,000 Self-Instruct-generated examples used to fine-tune LLaMA 7B into a chat-style model. The format itself was inherited from the Self-Instruct pipeline. It was copied so widely in the months that followed that 'Alpaca format' became the de facto name for any dataset with this shape, regardless of whether it had any connection to the original Stanford release. This deep dive walks through the fields in detail, the canonical training-time templates, the loss-masking conventions, and the practical limitations that have driven the move toward multi-turn chat formats.

The three fields in detail

Each Alpaca example is a JSON object with exactly three string-valued keys: instruction, input, output.

The instruction field carries the natural-language task description. It is always present and is the part of the example that tells the model what to do. Examples span the full range of common LLM tasks: summarisation, classification, generation, translation, question answering, code completion, format conversion. The instruction is the only field that is mandatory and never empty in well-formed Alpaca data.

The input field carries the context the task operates on. For a summarisation task this is the document to summarise. For a translation task it is the source sentence. For a sentiment classification task it is the review. The input field is conditionally present: roughly 40 percent of original Alpaca examples have an empty string here because the instruction is self-contained. 'Write a haiku about autumn' needs no input. 'Translate this English sentence to French: [sentence]' could be written either with the sentence in the instruction or with the instruction calling for translation and the sentence in input. The original Alpaca corpus mixes both styles for the same task, which is itself a design point worth being aware of.

The output field is the gold response the model should produce. It is always present. Its content is whatever the instruction asks for: the summary, the translation, the answer, the generated text. At training time the output tokens are the only tokens that enter the cross-entropy loss. The instruction and input tokens are masked out under completion-only loss masking.

The combined shape is dead simple. Three JSON keys, all string-valued, two mandatory and one conditional. This simplicity is one of the reasons the shape spread so widely so quickly: it is trivial to inspect, trivial to convert, and trivial to generate with a Self-Instruct-style pipeline.

The two prompt templates
Loss masking and the completion-only convention
Why the shape has been displaced for new datasets
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Stanford's original Alpaca corpus of 52K Self-Instruct-generated examples ships in this exact JSON shape and remains a standard reference dataset for instruction tuning.
  • Databricks Dolly 15K uses the same instruction, input, output shape with human-authored rows rather than Self-Instruct generation.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhy are there two prompt templates rather than one with a placeholder for missing input?
A

A blank Input section in the template leaves a visible 'Input:' header followed by nothing, which the model can learn to mimic as a stylistic pattern. Using two distinct templates avoids that leakage. The model only ever sees 'Input:' when there is real input, so it does not generate empty headers at inference.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating input as a mandatory field. About 40 percent of Alpaca examples have an empty input because the instruction stands on its own.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • The three field names: instruction, input, output

  • Which fields are mandatory and which is conditionally empty

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is RLHF, and why is it used after pretraining?
MCQ·Easy