How to Use Delimiters in Prompts for Clear AI Instructions
Use
delimiters like triple backticks ``` or special characters to clearly separate instructions from data in prompts. This helps AI models understand where the input ends and the task begins, improving response accuracy.Syntax
Delimiters are special markers used in prompts to separate different parts, such as instructions and input data. Common delimiters include triple backticks ```, triple quotes """, or custom symbols like ###.
Basic syntax pattern:
Instruction or question
Data or context
Additional instructions or end This structure tells the AI where each section starts and ends.
plaintext
Instruction: Summarize the text below. ``` This is the text to summarize. ``` End of prompt.
Example
This example shows how to use triple backticks as delimiters to separate instructions from the text to analyze. It helps the AI clearly identify the text to work on.
python
prompt = '''Summarize the following text: ``` Artificial intelligence helps automate tasks and improve efficiency. ``` Please provide a short summary.''' print(prompt)
Output
Summarize the following text:
```
Artificial intelligence helps automate tasks and improve efficiency.
```
Please provide a short summary.
Common Pitfalls
Common mistakes when using delimiters include:
- Not closing delimiters properly, causing the AI to misinterpret where the input ends.
- Using inconsistent delimiters within the same prompt.
- Choosing delimiters that appear in the input data, confusing the AI.
Always pick unique delimiters and close them correctly.
python
wrong_prompt = '''Extract keywords: ``` Data with ``` inside ''' correct_prompt = '''Extract keywords: ``` Data without delimiter inside ``` '''
Quick Reference
| Delimiter Type | Usage | Example |
|---|---|---|
| Triple backticks ``` | Separate code or text blocks | ```Your text here``` |
| Triple quotes """ | Separate multi-line text | """Your text here""" |
| Custom symbols ### | Separate sections clearly | ### Section 1 ### Section 2 |
| Brackets <> or [] | Mark specific data parts | or [data] |
Key Takeaways
Use clear and unique delimiters to separate instructions and data in prompts.
Always close delimiters properly to avoid confusing the AI model.
Avoid using delimiters that appear inside your input data.
Common delimiters include triple backticks, triple quotes, and custom symbols.
Delimiters improve AI understanding and response accuracy by marking boundaries.