# How do you write a prompt template you can reuse?

Date: 2022-08-05 · Author: Robert Scales · https://guidetoartificialintelligence.com/en/learn/write-prompt-template-reuse/

**Answer:** A reusable prompt template is a prompt with fixed wording and labeled blanks, such as role, audience, task, format and input, that you fill in fresh for each job. Because the structure never changes, the model gets the same clear signals every time, and you only have to think about the parts that are new.

Most people who work with GPT-3 for a while notice they keep typing the same kind of prompt. They describe who the model should act as, who the text is for, what to do and how the answer should look, then paste in some material. A template turns that habit into a tool: you write the frame once, test it, and from then on you only fill the blanks.

The idea has a research history. In their 2021 survey of prompting methods, Pengfei Liu, Graham Neubig and colleagues at Carnegie Mellon describe a prompt as a template with slots: one slot for the input and one for the answer the model should produce. Sentiment analysis, translation and question answering all become the same move, filling a frame that a pre-trained model already knows how to continue. A template for everyday work applies the same logic, with plainer labels.

## The five blanks

A good general-purpose template has five parts. Each one answers a question the model would otherwise have to guess.

| Blank | The question it answers | Example value |
|---|---|---|
| Role | Whose voice and expertise? | an experienced copywriter for small shops |
| Audience | Who will read the result? | gift buyers browsing on a phone |
| Task | What exactly should happen? | write a product description |
| Format | What shape should the answer take? | 3 sentences, under 60 words, no exclamation marks |
| Input | What material should it work from? | the product notes |

Here is the template with the blanks in curly brackets. The triple quotes mark where the pasted material starts and ends, so the model does not mistake your notes for more instructions.

```prompt
You are {role}.
Audience: {audience}.
Task: {task}.
Format: {format}.

Material:
"""
{input}
"""

Answer:
```

The labels matter as much as the blanks. Laria Reynolds and Kyle McDonell, in a 2021 paper on prompt programming for GPT-3, point out that a model continues text in whatever direction the prompt allows. A vague prompt leaves room for many continuations you did not want. Their advice is to write prompts that fit the result you want and rule out the results you don't. Clear labels, a quoted block for the material and an open "Answer:" line at the end do exactly that.

## One template, two jobs

**Job 1: a product description.**

```prompt
You are an experienced copywriter for small craft shops.
Audience: gift buyers browsing on a phone.
Task: write a product description.
Format: 3 sentences, under 60 words, no exclamation marks.

Material:
"""
Hand-thrown mug, stoneware, 350 ml, speckled blue glaze, dishwasher safe, made in Quebec.
"""

Answer:
```

**Job 2: a summary of meeting notes.**

```prompt
You are a careful project coordinator.
Audience: team members who missed the meeting.
Task: summarize the decisions and list who does what next.
Format: a heading "Decisions" with up to 4 bullets, then a heading "Next steps" with one bullet per person.

Material:
"""
(paste the raw notes here)
"""

Answer:
```

The frame is identical. Only the five values changed, and each change was a small, deliberate choice rather than a fresh prompt written from memory. With `text-davinci-002` in the Playground, a low temperature such as 0 to 0.3 suits jobs like these, where you want steady, predictable wording.

> **Try it:** Copy the template into a text file. Pick a writing job you do every week, fill the five blanks, and run it on three different inputs. Wherever the output drifts, tighten the matching blank (usually Format) and run all three again.

## Keeping a template useful over time

A template is worth keeping only if it works on the inputs you really have. Three habits help:

- **Test on several inputs at once.** One good result proves little. Keep four or five real examples, including a messy one, and rerun them all after every change.
- **Change one blank at a time.** If you rewrite the role and the format together and the output improves, you won't know which change helped.
- **Write down the version.** A line at the top such as "v3, shorter format line" lets you go back when an edit makes things worse.

Some jobs also need a worked example inside the template, especially when the format is unusual. Reynolds and McDonell found that examples often help the model recognize a task it already knows, rather than teaching it something new, and that they matter most when the output needs a custom structure. If you add one, keep it in the fixed part of the template so every run sees the same example.

## Which parts stay fixed and which change?

Think of the template in two layers. The fixed layer is everything that describes how the work is done: the labels, their order, the quote marks around the material, the closing "Answer:" line, any standing rules such as "no exclamation marks" and any worked example. These pieces give the model the same signals every time, which is where consistency comes from.

The changing layer is the content of the blanks. The input changes on every run. Task and audience change from one job to the next. Role and format sit in between: they often stay the same within one kind of job, such as all your product descriptions, and change when you move to a different kind. A practical test is to ask, "Would I write this line the same way for the next ten uses?" If yes, it belongs in the fixed layer.

The Liu survey notes that finding the best prompt by hand takes time and experience, and that even skilled writers can miss better wordings. That is the strongest argument for templates: the effort you spend improving the fixed layer is not lost after one use. It carries over to every job you run through it.

## Sources

- Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processing: https://arxiv.org/abs/2107.13586
- Prompt Programming for Large Language Models: Beyond the Few-Shot Paradigm: https://arxiv.org/abs/2102.07350
