Principle:LLMBook zh LLMBook zh github io Instruction Data Formatting
| Knowledge Sources | |
|---|---|
| Domains | NLP, Data_Engineering |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
A data formatting technique that wraps instruction-response pairs into structured prompt templates for supervised fine-tuning.
Description
Instruction Data Formatting transforms raw instruction-response datasets into formatted strings using predefined templates. The Alpaca-style template wraps each example with markers like "### Instruction:" and "### Output:" to clearly delineate the instruction from the expected response. This formatting ensures the model learns to follow instructions by associating the template structure with the task of generating responses.
Two template variants exist: one for instructions with additional input context, and one for standalone instructions.
Usage
Use this principle when preparing data for supervised fine-tuning (SFT) of a language model. Apply it before tokenization to ensure consistent formatting across all training examples.
Theoretical Basis
The template structure follows the Alpaca format:
With input:
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{instruction}{input}
### Output:
{response}
Without input:
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{instruction}
### Output:
{response}