Concepts / System Prompts and User Prompts

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.

  • Programming

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 real world

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.

System promptstanding role and taskTemplatefixed layout with emptyslotsFinal inputone complete piece of textModelreads the single inputUser promptthis turn's question ormaterialfills first slotfills second slotmerges with markerssingle input
Which pieces of text go into which slots, and in what order, to form the single input the model reads?

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.

Worked example

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?

  1. 1
    Identify 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.

  2. 2
    Fill the system slot

    Insert 'Answer in one short sentence' inside the system block, between the system opening and closing markers.

  3. 3
    Fill the user slot

    Insert 'What does a template do?' after the system block, followed by the closing marker of the instruction block.

  4. 4
    Leave the markers alone

    The fixed markers are not edited. Only the empty slots change from request to request.

  5. 5
    Send one string

    The result is one complete piece of text. The model reads that string as its single input.

Result

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.

python
Output (expected)
[BEGIN][SYSTEM]Answer in one short sentence[/SYSTEM]What does a template do?[END]
Notes on the code
  • 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.

Chat templatedefined by model developersRole markerswhat the model was trainedonPrompt templatewritten by applicationdevelopersDeveloper textfills slots with system anduser textdefinesfills
Which layer adds the role markers the model was trained on, and which layer supplies the developer's own text?
FeatureChat templatePrompt template
Who writes itThe model's developersThe application's developers
What it doesDescribes how the model expects its input to be structuredFills in the developer's own prompts with specific data
Where to find itUsually in the model's documentationIn the application's own code
Can change between versionsYes, the provider may change the layoutUnder 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?

  • Nothing, because new lines are ignored

  • The model reads a different character sequence, so its behavior can shift

  • The model refuses to answer

Reveal answer
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.

Write promptssystem and user textMerge into templatemarkers and spacing appliedMarkers exact?compare with chat templatedocsSend to modelsingle input is readReplyoutput to inspectFix the templatecorrect markers or spacingfills slotsinspect textyesnore-mergemodel replies
At which step between writing the prompt and receiving the reply can a formatting error corrupt the input, and how do you trace it?
  • Common mistake

    Assuming the model will sort out the message format on its own

    What it looks like

    Treating spacing, line breaks, and special markers as cosmetic and leaving them unchecked.

    Why it fails

    The template fixes the exact sequence of characters the model reads, so small differences change the input.

    Do this instead

    Treat the layout as part of the instructions and inspect the final string.

  • Common mistake

    Using the wrong template for the model

    What it looks like

    Copying a header-based layout into a model that expects bracket markers.

    Why it fails

    The source reports that the wrong template can produce puzzling performance problems.

    Do this instead

    Check the chat template in the model's documentation for the exact version you call.

  • Common mistake

    Editing a marker by hand

    What it looks like

    Changing one character of a start-header marker.

    Why it fails

    Each marker is handled as a single token, so a changed marker is a different input.

    Do this instead

    Copy 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.

InstructionBetter slotReason
Assign a role or personalitySystem promptIt should shape many responses across a conversation
Describe the overall taskSystem promptIt is a standing description of the job
Explain how to assess risk fairlySystem promptIt is developer guidance reused every turn
The document being discussedUser promptIt is material for the current exchange
The buyer's specific questionUser promptIt changes with every new message

A starting point for splitting instructions in the home-buyer chatbot

Best practice

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.

  1. 1
    Print the final string, not the two source prompts, so you see exactly what the model reads.
  2. 2
    Compare the opening and closing markers with the chat template documentation for this model version.
  3. 3
    Confirm that each marker is copied exactly, with no retyped or altered characters.
  4. 4
    Check the spacing and new lines around each marker, since a single extra new line can change behavior.
  5. 5
    Confirm the system text sits in the system position and the user text sits in the user position.
  6. 6
    Confirm 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.

MEDIUM

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.

Related concepts

More concepts starting with S