System vs User vs Assistant Messages
What you'll learn: How the three-role message structure organizes conversation flow and controls LLM behavior in chat applications.
Understanding the Three-Role Architecture
Modern chat-based language models use a three-role message format to structure conversations:
- System messages set the stage and define overarching behavior
- User messages represent the human's input or query
- Assistant messages contain the model's responses
Think of it like a play: the system is the director's notes (invisible to the audience but guiding everything), the user is the audience asking questions, and the assistant is the actor performing on stage.
How Each Role Influences Behavior
System messages establish persistent context—the persona, tone, constraints, and rules that apply throughout the entire conversation. They're typically set once at the beginning and shape every subsequent response.
User messages inject new information, questions, or instructions into the conversation. Each user message is a discrete turn where the human speaks.
Assistant messages provide the model's output. In few-shot prompting scenarios, you can include example assistant responses to demonstrate the desired output format or style.
The Flow Pattern
System: "You are a helpful Python tutor. Be concise."
User: "What is a list?"
Assistant: "A list is an ordered, mutable collection in Python..."
User: "Show an example."
Assistant: [model generates response based on system rules + conversation history]
The system message persists and influences both assistant responses, while user/assistant messages build the conversation history sequentially.
Why This Structure Matters
This separation allows you to control global behavior (system) independently from turn-by-turn interaction (user/assistant). You can change system instructions without rewriting examples, or provide few-shot examples in the assistant role to guide formatting.
Key Takeaway: The three-role structure separates persistent behavioral instructions (system) from conversational turns (user/assistant), giving you fine-grained control over how the model interprets and responds to each input.