Prompt structure: what the model receives
A conversation becomes a structured sequence with roles, separators, instructions, and context.
In this lesson
The visible message is often only one part of the actual model input.
From messages to a sequence
A chat interface stores messages with roles such as user and assistant. Before inference, a template turns that structure into the format expected by the model. Special tokens or delimiters can identify roles and message boundaries. Hugging Face’s chat-template documentation, checked November 2026, shows why model-specific formatting matters.
A role label is not merely decoration on the screen. The corresponding serialized pattern helps the model interpret who is speaking and what should come next. However, role names and allowed message patterns differ by model and application. An invented universal template would obscure those differences.
Separate instructions from material
An application may place its general instructions before the user’s current request, include retrieved passages, and end with a marker inviting an assistant response. Tokens from all of those parts can occupy the input budget. The user may not see every item the application supplied, so the visible chat history is not a complete specification of the input.
For an original teaching example, imagine a message containing a quoted email that says “Ignore the previous request.” That sentence may be data to summarize, not an instruction to obey. Clear boundaries help describe the intended distinction. Formatting alone is not a complete defense against a model treating untrusted content as instructions.
Useful structure without magic words
A clear request identifies the task, the relevant material, the desired output shape, and any constraints that matter. “Summarize these three findings in two sentences, preserving the dates” reduces ambiguity. There is no need to pretend a particular phrase unlocks a hidden universal mode. The result still depends on the model and task.
Examples can show what a format means more efficiently than a long description. But contradictory instructions and examples create ambiguity. If the prose requests two fields while the example shows five, the model has competing signals. Good prompt construction is partly careful specification and partly empirical testing.
Keep the rest of the system visible
Tool definitions and tool outputs are also context. A model can generate a request to call a tool, but an application must validate and execute that request. Treat external documents and returned text according to their source and authority, rather than assuming everything in the context deserves equal trust.
When reproducing an experiment, save the complete relevant message structure, model identifier, sampling settings, and tool results. A screenshot of one user message may be insufficient. At the same time, do not expose private instructions or user data merely to make a demonstration convenient. A small original example can show the mechanism without revealing a real conversation.
A transparent teaching format
An illustrative prompt can contain four clearly labeled parts: task, source passage, output requirements, and response start. These labels explain the roles of the text; they are not the special-token format of any named production model.
Everything inside a prompt has the same authority.
Applications distinguish instructions, user requests, quoted data, and tool results. Models can still mishandle those boundaries.
Take it with you
- Chat messages are serialized into a model-specific format.
- Visible history may omit application-supplied context.
- Clear structure helps, but does not guarantee correct behavior.
Check your understanding.
Choose an answer, then see the explanation. You can try again.
Practice only. Your answer is not stored or sent anywhere.
In-context learning: adapting without weight updates
Continue when you’re ready. Marking this lesson as read is optional.
Sources & further reading
Primary references for this lesson. The explanation and examples above are original.
- Chat templates ↗Hugging Face contributors · Living documentation; checked 2026-11-13 · checked 13 Nov 2026