Alpaca Format Format Guide
Instruction-following dataset format for LLM fine-tuning
ConversationSpecification
The Alpaca format is a JSON/JSONL dataset structure designed for instruction-following fine-tuning of large language models. Introduced by Stanford's Alpaca project in March 2023, it defines a simple three-field schema: instruction (the task description or question), input (optional additional context), and output (the expected model response). This format has become one of the most widely adopted structures for supervised fine-tuning (SFT) datasets, supported by training frameworks including Axolotl, LLaMA-Factory, FastChat, and the Hugging Face TRL library.
Each example in an Alpaca-format dataset represents a single instruction-response pair. The instruction field contains the task the model should perform — this could be a question, a command, or a description of the desired output. The input field provides additional context when the instruction alone is insufficient; for example, if the instruction is "Summarize the following text," the input field would contain the text to be summarized. When no additional context is needed, the input field is left as an empty string. The output field contains the ideal response that the model should learn to generate.
The simplicity of the Alpaca format is its primary strength. Unlike multi-turn conversation formats (ShareGPT, ChatML), Alpaca focuses on single-turn instruction following, making it straightforward to create, validate, and process. During training, the instruction and input are combined into the prompt (typically with a template like "Below is an instruction..."), and the model is trained to generate the output given this prompt. The format is agnostic to the specific prompt template used — different training frameworks apply their own templates during data preprocessing.
When to Use Alpaca Format
Use the Alpaca format when creating single-turn instruction-following datasets for LLM fine-tuning. It is the ideal format for task-specific fine-tuning where each example demonstrates a complete task — answering a question, generating text, translating, classifying, extracting information, or following a specific instruction. If your training data consists of independent instruction-response pairs without conversational context, Alpaca format is the simplest and most widely supported choice.
Choose Alpaca format over ShareGPT or ChatML when your training examples are single-turn (one instruction, one response) and do not require multi-turn conversational context. The format's simplicity makes data creation faster, quality review easier, and parsing more reliable. Most major training frameworks support Alpaca format natively, and conversion to other formats (ChatML, ShareGPT) is trivial when needed.
Alpaca format is less suitable for training conversational models that need to maintain context across multiple turns — use ShareGPT or ChatML instead. It also lacks support for system prompts (instructions to set the model's persona or behavior), tool/function calling examples, or multi-modal inputs. If your training data requires any of these features, consider a more expressive format.
Schema / Structure
// Alpaca format schema
interface AlpacaExample {
instruction: string; // The task description or question
input: string; // Additional context (empty string if none)
output: string; // The expected model response
}
// Extended Alpaca format (used by some frameworks)
interface AlpacaExtended {
instruction: string;
input: string;
output: string;
system?: string; // Optional system prompt
history?: [string, string][]; // Optional conversation history
}Example Data
[
{
"instruction": "Classify the sentiment of the following product review.",
"input": "The noise cancellation on these headphones is incredible. Best purchase I've made this year.",
"output": "Positive. The review expresses strong satisfaction with the product's noise cancellation feature and overall value."
},
{
"instruction": "Write a professional email declining a meeting invitation.",
"input": "",
"output": "Subject: Re: Meeting Request\n\nHi [Name],\n\nThank you for the meeting invitation. Unfortunately, I have a scheduling conflict at that time and won't be able to attend.\n\nWould it be possible to reschedule to later in the week? I'm available Thursday or Friday afternoon.\n\nBest regards,\n[Your Name]"
},
{
"instruction": "Extract all company names mentioned in the text.",
"input": "The partnership between Microsoft and OpenAI has reshaped the industry, while Google DeepMind continues to push boundaries in AI research. Meanwhile, Anthropic has focused on AI safety.",
"output": "1. Microsoft\n2. OpenAI\n3. Google DeepMind\n4. Anthropic"
},
{
"instruction": "Convert the following temperature from Fahrenheit to Celsius. Show your work.",
"input": "98.6°F",
"output": "To convert Fahrenheit to Celsius:\nC = (F - 32) × 5/9\nC = (98.6 - 32) × 5/9\nC = 66.6 × 5/9\nC = 37°C\n\n98.6°F = 37°C (normal human body temperature)"
}
]Ertas Support
Ertas Data Suite natively supports the Alpaca format for training data preparation. You can import Alpaca-format JSON or JSONL datasets, apply PII redaction across instruction, input, and output fields, validate field completeness and quality, and export processed datasets ready for fine-tuning. The platform can also convert between Alpaca format and other instruction formats (ShareGPT, ChatML) to match your training framework's requirements.
Ertas Studio accepts Alpaca-format datasets directly for cloud-based fine-tuning, handling prompt template application and tokenization automatically based on the target model architecture.
Related Resources
Ship AI that runs on your users' devices.
Early bird pricing starts at $14.50/mo — locked in for life. Plans for builders and agencies.