Alpaca-format examples carry three fields: name them
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.
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.
Detailed answer & concept explanation~8 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: three field names + which are mandatory + with-input versus no-input templates + completion-only loss masking + how the shape relates to Self-Instruct, ChatML, and modern chat formats.
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.
- Hugging Face's TRL SFTTrainer accepts Alpaca JSON natively and applies the canonical template automatically when the dataset has the three field names.
- Modern frameworks like Axolotl and LLaMA-Factory document the Alpaca format as a first-class input alongside ChatML and ShareGPT formats.
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?
QHow does the Alpaca shape convert to the ChatML messages format?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating input as a mandatory field. About 40 percent of Alpaca examples have an empty input because the instruction stands on its own.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.