Course contentsShow
← Machine Learning and Deep Learning
Lesson 1752 of 3,53838. Instruction Tuning and AlignmentFree lesson

Instruction Format and Templates

Understanding standard instruction formats including system, user, and assistant roles in conversational templates.

Instruction Format and Templates

What you'll learn: How to structure conversations with language models using standardized roles and formatting conventions.

The Anatomy of an Instruction

When you fine-tune a model to follow instructions, you're essentially teaching it to play specific roles in a conversation. Just like a screenplay defines who says what, instruction formats define structured templates that organize interactions between the system, the user, and the AI assistant.

The Three Core Roles

Think of instruction formatting like a theatrical script with three characters:

System: Sets the stage and defines the assistant's behavior (e.g., "You are a helpful coding assistant"). This is optional but powerful for controlling tone and expertise level.

User: Represents the person asking questions or giving commands. This is where your actual instruction or query goes.

Assistant: The model's response, which demonstrates the desired output format and behavior.

Why Templates Matter

Without consistent formatting, your model might confuse who's speaking or what's context versus instruction. Templates create clear boundaries:

<|system|>You are a helpful assistant.<|end|>
<|user|>Explain photosynthesis.<|end|>
<|assistant|>Photosynthesis is the process...<|end|>

Different model families use different delimiters (<|...|>, [INST], special tokens), but the principle remains: clearly separate roles to help the model understand conversational structure.

Training with Templates

During instruction tuning, you format every example in your dataset consistently. The model learns to associate the user role with questions, the assistant role with answers, and the system role with behavioral constraints. This structured approach dramatically improves how models follow complex, multi-turn instructions.

Key Takeaway: Instruction templates standardize the format of system prompts, user queries, and assistant responses using role markers and delimiters, enabling models to reliably distinguish context from instructions during both training and inference.