Introduction

The template pattern aims to use the LLM to implement a formatted output starting from a precise request and an associated template with placeholder. The LLM will then iterate the template fulfilling the answer. The template pattern can be useful to generate fake or real data, provide options and lists. A key for executing the prompt is clarifying where the patterns are. So the two main statement that the LLM has to understand are:

  • The LLM is receving a template
  • The LLM has to fill the placeholders
  • What is the format of the placeholders

The Prompt

To use the pattern a contextual statemen should be made before any instruction. In literature this contextual statement is defined in the following way

I am going to provide a template for your output
[PLACEHOLDERS] is my placeholder for content
Try to fit the output into one or more of the placeholders that I list
Please preserve the formatting and overall template that I provide.
This is the template [Format of the template]
(OPTIONAL)

According to each request there should be one or many placeholders.

How to use the prompt

The prompt requires some preparation, mostly in the definition of the template with the placeholder.

Example

A possible example can be the following

Create a list of 5 objects that I need to use to deep cleaning my apartment. I'm going to provide a template for your
output. [PLACEHOLDER] are my placeholders for each element. Try to fit the output into one or more of the placeholders that I list. Please preserve the formatting and overall template that I provide. 
This is the template:   Room [ROOM THAT I NEED TO LIST], Item [ITEM THAT I NEED],quantity [QUANTITY THAT I NEED]
Please format in a table mode.

Some Tests

Let’s run some tests across all the LLM and see if the template is maintained.

ChatGPT 5.2

ChatGPT with the prompt above:

Room [ROOM THAT I NEED TO LIST]	Item [ITEM THAT I NEED]	quantity [QUANTITY THAT I NEED]
Kitchen	Degreaser Spray	        2
Bathroom	Limescale Remover	1
Living Room	Microfiber Cloths	6
Bedroom	Vacuum Cleaner Bags	    3
All Rooms	Disinfectant Wipes	4

The pattern is applied and, interesting point of view, ChatGPT is reporting back the placeholders.

Claude - Haiku 4.5

Claude Haiku 4.5 - Same input prompt

| Room | Item | Quantity |
|------|------|----------|
| Kitchen | Degreaser spray.          | 1 bottle |
| Bathroom | Toilet brush and plunger | 1 each |
| Living Room | Microfiber cloths     | 10-15 pieces |
| Bedrooms | Vacuum bags or filters   |  2-3 sets |
| All Rooms | All-purpose cleaner     | 2 bottles |

Also here the pattern is fulfilled.

Mistral

Mistral AI, same prompt

Deep Cleaning Essentials

| Room         | Item                          | Quantity |
|--------------|-------------------------------|----------|
| Whole House  | Microfiber cloths             | 5-10     |
| Kitchen      | Degreaser cleaner             | 1 bottle |
| Bathroom     | Disinfectant spray/wipes      | 1 bottle |
| Floors       | Vacuum cleaner (with HEPA)    | 1        |
| Whole House  | All-purpose cleaner           | 1 bottle |

Conclusions

The Template Pattern is probably one of the simplest and most effective pattern. Spending a bit of time preparing the prompt with template, placeholders and format can then easily generate structured and usable output.