Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:LLMBook zh LLMBook zh github io Instruction Data Formatting

From Leeroopedia
Revision as of 18:11, 16 February 2026 by Admin (talk | contribs) (Auto-imported from principles/LLMBook_zh_LLMBook_zh_github_io_Instruction_Data_Formatting.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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}

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment