Skip to main content
Crowdfunding
Python + AI for Geeks
Practice

Using Delimiters to Structure Prompts for Better Understanding

If you find your written prompt difficult to understand, chances are the AI will too.

To make prompts easier to understand and to ensure the AI receives clear instructions, you can use delimiters.

A delimiter refers to characters or strings (comprising multiple characters) that clearly separate or structure information within a prompt.

Below is an example of using the ### delimiter to structure the instructions, context, and input data into distinct blocks within a prompt.

Using Delimiters to Separate Instructions, Context, and Input Data
### Instructions
Please summarize the following news article in one sentence.

### Context
The summarized sentence will be used as a meta tag for search engine optimization (SEO).

### Input Data
The rapid advancement in generative artificial intelligence (AI) technology
is leading to transformative changes in the media, entertainment, and education sectors.
Notably, generative AI is making significant strides in natural language processing and image generation..
(Continued)

Just as well-structured text is easier to read, AI prefers prompts that are clearly structured over those written as a continuous block of text.


Commonly Used Delimiters

Delimiters can be used differently for each prompt and do not have predefined meanings.

However, commonly used delimiters in prompt engineering and their roles are as follows:


1. [###]

Used to denote titles within a prompt. Often used to indicate the beginning of a section or the title of a block of information within a prompt.

Example of Using the ### Delimiter
### Request
Please develop a marketing strategy to increase sales.

### Reference Materials
- Q1 2022 Sales
- Q2 2022 Sales
...

The # symbol does not need to be used strictly in a group of three; it can be used as # (main title), ## (subtitle), ### (sub-subtitle), etc., to indicate various levels of headings.

Example of Using Multiple Levels of Headings
# What is a Prompt?

## Components of a Prompt

### Instructions

### Context

2. ["""]

Used to enclose long quotations or blocks of information that require special attention and to separate contexts.

Double quotes may also be used for emphasizing specific parts like "words".

Example of Using Double Quotes for Quotations
From which philosopher is the following quotation?

"""
I think, therefore I am.
"""
Example of Using Double Quotes for Emphasis
Please recommend "3 destinations" for overseas travel this summer.
Specifying the Location for Output
Summarize the article in one sentence.

"""Place your summary here"""

3. [---]

Used to visually separate different sections of a prompt.

This helps in dividing sections and making the prompt structure clearer.

Example of Using the --- Delimiter
Please correct the following sentence:
---
I am glad to here that you are doing well.

Combining Delimiters

Delimiters can be combined in various ways, as shown below:

Example Prompt
### Paragraph 1

"""
Content of Paragraph 1 goes here.
"""

---

### Paragraph 2

"""
Here is the content for Paragraph 2. The AI perceives this as an independent unit.
"""

In the prompt above, ### is used to separate paragraph titles, """ is used to distinguish the content of each paragraph, and --- is used for visual separation between sections.


Besides the three delimiters above, various other delimiters can be used depending on the purpose of the prompt.

Example of Using Other Delimiters
Please correct the following English sentence and explain at least two corrections made.

* Sentence to be corrected: I am a student who lives in Korea. Who is you?

* Corrected result: <Corrected Sentence>

1. <Correction Detail 1>
2. <Correction Detail 2>
3. [Additional Correction Details]

In the example above, *** is used to distinguish the sentence to be corrected, and < > is used to separate the corrected sentence and correction details.


XML Delimiters

Additionally, prompts can be structured using the XML format (a language used to represent hierarchical data structures).

XML represents hierarchical data using tags enclosed in < >, making the structure of prompts clearer. Opening tags are represented as <tag>, closing tags as </tag>, and data within tags is represented as <tag>data</tag>.

Example of Using XML Delimiters
<article>
The U.S. Consumer Price Index (CPI) increased by 0.4% from the previous month, exceeding expectations slightly.
This indicates persistent inflationary pressures and may increase the likelihood of a rate hike by the Federal Reserve.
</article>

<instructions>
1. Based on the above article, write a blog post title.

2. Extract 2 keywords for search engine optimization.
</instructions>

<context>
The summarized sentence will be used as a meta tag for search engine optimization (SEO).
</context>

<output>
- Blog Post Title: [Blog Post Title]

- Keywords: [Keyword1], [Keyword2]
</output>

Practice

Compare the responses between a structured prompt using delimiters and a less structured prompt without delimiters.

Example of a Detailed Prompt Using Delimiters
### Request
I plan to visit Bangkok for one day.
Considering the limited time, please recommend 3 tourist spots to visit in a day.

---

### Response Format

[1] <Recommended Spot 1> : <Reason for Selection>

[2] <Recommended Spot 2> : <Reason for Selection>

[3] <Recommended Spot 3> : <Reason for Selection>
Example of a Vague Prompt Without Delimiters
Please recommend places to visit in Bangkok.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.