System Prompts and User Prompts
A prompt template is a fixed layout that merges a system prompt and a user prompt into the single input the model reads.
Why Two Prompts Become One Input
Imagine you are building a chatbot that helps home buyers. Every time someone asks it a question, the model needs to know two different things. It needs to know how it should behave in general, and it needs to know what this particular person is asking right now. Many model APIs let you keep these two concerns in separate places instead of mixing them into one block of text. Those two places are the system prompt and the user prompt.
There is one detail that is easy to miss. Before the model does any work, the system prompt and the user prompt are combined into a single piece of text, usually by following a template. The model never reads the two prompts as separate objects. It reads one complete sequence of characters. This article traces how that merge happens, where it can go wrong, and how to decide what belongs in each slot.
Job Description and Daily Assignment
A helpful way to hold the distinction in mind is to think of the system prompt as the description of the job and the user prompt as the specific assignment handed over for today. The job description stays the same from one conversation to the next. The assignment changes every time someone types something new.
A system prompt carries standing instructions, such as a role or an overall description of the task. A user prompt carries the specific question, input, or material for the current exchange. Roleplaying instructions and task descriptions are the most common content for the system slot, because they are meant to shape many responses at once rather than just one.
In the home-buyer chatbot, the builder writes once that the assistant should act like an experienced real estate agent. That role instruction goes in the system slot. It tells the model how to read each disclosure, how to assess risks fairly, and how to keep answers brief and professional. Then, for each buyer, the document being discussed and the buyer's question go into the user slot.
How a Template Merges the Two Prompts
A prompt template is a fixed layout with empty slots. The slots are filled with the content of a particular request, and the result is one complete piece of text. In the case of a model that accepts a system prompt and a user prompt, the template decides where each piece goes, which markers separate them, and what text surrounds them. The model then receives the combined result as its single input.
The merge is easy to overlook because it happens before the model does any work. It nevertheless determines the exact sequence of characters the model actually reads. Model providers often describe system prompts as especially powerful, but the mechanism is concatenation. The system prompt and the user prompt are joined into one final prompt, and from the model's side both are processed the same way.
Merging a Short System and User Prompt
An application has the system prompt 'Answer in one short sentence' and the user prompt 'What does a template do?'. How is the final input built?
- 1Identify the layout
Use the same Llama 2 style layout described in the source: a begin marker, an instruction block, a system block that holds the system prompt, then the user message, then a closing marker.
- 2Fill the system slot
Insert 'Answer in one short sentence' inside the system block, between the system opening and closing markers.
- 3Fill the user slot
Insert 'What does a template do?' after the system block, followed by the closing marker of the instruction block.
- 4Leave the markers alone
The fixed markers are not edited. Only the empty slots change from request to request.
- 5Send one string
The result is one complete piece of text. The model reads that string as its single input.
The model receives one combined text in which the standing instruction and the specific question sit in their designated positions, surrounded by the fixed markers the model was trained to expect.
[BEGIN][SYSTEM]Answer in one short sentence[/SYSTEM]What does a template do?[END]- The bracket markers here are invented placeholders for illustration; a real model's markers come from its own chat template documentation.
- The function never edits the fixed parts, which is what makes the layout repeatable.
- The printed string is the exact text the model would read, so it is the thing to inspect.
Two Meanings of Template
The word template is used for two related but distinct things, and confusing them causes real debugging trouble. The first is the chat template that a model's developers define for their model. It describes how that model expects its input to be structured and can usually be found in the model's documentation. The second is the prompt template an application developer writes to fill in their own prompts with specific data, such as a product name or a document.
| Feature | Chat template | Prompt template |
|---|---|---|
| Who writes it | The model's developers | The application's developers |
| What it does | Describes how the model expects its input to be structured | Fills in the developer's own prompts with specific data |
| Where to find it | Usually in the model's documentation | In the application's own code |
| Can change between versions | Yes, the provider may change the layout | Under the developer's control |
The two layers that both use the word template
Chat templates are not permanent. For the Llama 3 chat model, the provider changed the layout, so the same underlying idea of a system part followed by a user part now looks quite different. The newer layout uses header markers that name each role, end-of-turn markers that close each part, and a final header that prompts the model to begin its reply. An application that hard-codes an old layout can quietly fall out of step with the model it calls.
Why Markers Must Match Exactly
The markers in a chat template are not ordinary words. Each span between the less-than-bar and bar-greater-than delimiters is treated as a single token by the model. A marker such as the start-header marker is handled as one unit, not as a sequence of letters that might be rewritten or split by accident. Changing even a small part of one of these markers produces a different input from the one the model was trained to expect.
What do you think happens?
Suppose the same two prompts are merged, but one extra new line is inserted between a marker and the user text. What changes for the model?
Reveal answer
The model reads a different character sequence, so its behavior can shift
The source reports that even a minor slip such as an extra new line can cause the model to change its behavior significantly, because the exact input the model reads has changed.
Tracing a Formatting Failure
When output seems wrong, the most likely point of failure is the merge step, not the model's reasoning. Follow the request from the moment you write the prompts to the moment the reply arrives. A formatting error can enter at the template step, and it stays invisible unless you look at the exact text that will reach the model.
Common mistake Assuming the model will sort out the message format on its own
What it looks likeTreating spacing, line breaks, and special markers as cosmetic and leaving them unchecked.
Why it failsThe template fixes the exact sequence of characters the model reads, so small differences change the input.
Do this insteadTreat the layout as part of the instructions and inspect the final string.
Common mistake Using the wrong template for the model
What it looks likeCopying a header-based layout into a model that expects bracket markers.
Why it failsThe source reports that the wrong template can produce puzzling performance problems.
Do this insteadCheck the chat template in the model's documentation for the exact version you call.
Common mistake Editing a marker by hand
What it looks likeChanging one character of a start-header marker.
Why it failsEach marker is handled as a single token, so a changed marker is a different input.
Do this insteadCopy markers from the documentation and never retype them.
Common mistake Blaming the model before checking the input
Deciding Where an Instruction Belongs
Developer-authored instructions typically go in the system prompt, and instructions supplied by the person using the application typically go in the user prompt. This is a convention, not a rule the model enforces. A designer can move instructions between the two slots, and the arrangement itself can influence how well the model performs.
| Instruction | Better slot | Reason |
|---|---|---|
| Assign a role or personality | System prompt | It should shape many responses across a conversation |
| Describe the overall task | System prompt | It is a standing description of the job |
| Explain how to assess risk fairly | System prompt | It is developer guidance reused every turn |
| The document being discussed | User prompt | It is material for the current exchange |
| The buyer's specific question | User prompt | It changes with every new message |
A starting point for splitting instructions in the home-buyer chatbot
Label the parts of the user slot clearly, such as separating background material from the actual request. Keeping these separate makes it clear to the model which text is background to read and which text is the question to answer.
A Pre-Send Checklist
Because the failure is silent, the practical defense is to inspect the exact text that will reach the model. Work through the following checks in order before the request leaves your application. The printed result is the check.
- 1Print the final string, not the two source prompts, so you see exactly what the model reads.
- 2Compare the opening and closing markers with the chat template documentation for this model version.
- 3Confirm that each marker is copied exactly, with no retyped or altered characters.
- 4Check the spacing and new lines around each marker, since a single extra new line can change behavior.
- 5Confirm the system text sits in the system position and the user text sits in the user position.
- 6Confirm the final header that prompts the reply is present when the layout requires it.
Prompt Structure as a Testable Design
Because the arrangement of prompts can affect model performance, structure should be compared experimentally rather than assumed. Keep the same inputs, change only the template or the slot assignment, and run the request again. Comparing the replies shows which arrangement works better for your application. Repeating this cycle of change, test, and compare is how prompt structure is refined.
Take the home-buyer chatbot. Write one system prompt that assigns the role of an experienced real estate agent. Then write two different user prompts that each include a document and a question. Print the final merged string for each. Which pieces of text are identical across both inputs, and which change? Finally, move one developer instruction into the user slot, rerun the same question, and note whether the reply changes.
Hints
- The fixed role text and markers should be identical in both printed strings.
- Only the user slot should differ between the two requests.
- Changing the slot assignment changes the text the model reads, even when the words stay the same.
Key Takeaways
- A prompt template is a fixed layout with empty slots that merges a system prompt and a user prompt into one text string, which is the only input the model reads.
- The word template means two things: the chat template defined by a model's developers, and the prompt template an application developer writes to insert specific data.
- Formatting errors fail silently, and the most likely point of failure is the merge step, so the defense is to print and inspect the exact final string.
- Standing role and task instructions usually belong in the system prompt, while per-turn questions and material belong in the user prompt, but this split is a convention that can be tested and refined.