PaPoo
cover

What is a prompt template?

A prompt template is a reusable prompt with placeholders for variable details, so you can generate consistent LLM inputs without rewriting the whole prompt each time.

Why it matters

Prompt templates solve a simple but common problem: most prompts are partly fixed and partly changing.

In practice, they help you:

If you are building with LLMs, you usually reach for a prompt template when the same instruction pattern repeats with different inputs.

How it works

A prompt template usually has two parts:

  1. Static instructions — the stable text that tells the model what to do.
  2. Variables or placeholders — slots you fill in at runtime, such as {{user_name}}, {question}, or <context>.

When your application runs, it substitutes the real values into the template and sends the resulting prompt to the model. The template itself is not the model; it is just the structured text you feed into it.

In many frameworks and APIs, templates can be very simple string formats. In more structured systems, they may also define roles, message blocks, or typed inputs. The core idea is the same: separate the repeated instruction from the changing content.

Tiny concrete example

Template:

You are a helpful support assistant.
Answer the user's question using only the product docs below.

Docs:
{docs}

Question:
{question}

Filled prompt:

You are a helpful support assistant.
Answer the user's question using only the product docs below.

Docs:
Our refund policy allows returns within 30 days.

Question:
Can I get a refund after 20 days?

The app reuses the same template, but swaps in different docs and questions each time.

Common pitfalls / when NOT to use it

Use a prompt template when you need repeatable structure. Do not use one just to make a prompt look “engineered” if a plain prompt would be clearer.

Related terms

Related terms

同じ著者の記事