Remember playing the game "Simon Says" as a kid? The magic happened when you knew exactly when Simon was giving a command versus just making a statement. That simple difference between "Simon says touch your nose" and just "touch your nose" determined whether you should act or not. In the world of AI, we use something similar called "delimiters" - they're like the "Simon says" of artificial intelligence, helping AI understand exactly what we want it to do.
The Magic of Clear Instructions
Think about how you organise your kitchen. You probably have different sections - a drawer for utensils, a cabinet for plates, another for cooking pots. Each space has a clear purpose, and everything works better because of this organisation. When we talk to AI, we need similar organisation, and that's where delimiters come in.
Delimiters are like invisible fences we put around different parts of our instructions to AI. Just like you might tell a story by saying "Once upon a time..." and ending with "The End," these special markers help AI understand where one part of your instruction ends and another begins.
How It Works in Real Life
Let's say you're asking an AI to help you write a birthday card. Without delimiters, it might look like this:
Write a birthday message for my best friend Sarah who loves gardening and just turned 30 make it funny but not too silly and include something about plants.
Kind of messy, right? Now look at how delimiters make it clearer:
<instructions> Write a birthday message with these requirements: - Should be funny but not silly - Include plant references </instructions> <recipient> Name: Sarah Age: 30 Interests: Gardening </recipient>
See how much clearer that is? The AI now knows exactly what parts are instructions and what parts are information about Sarah. It's like giving someone cooking ingredients in separate bowls instead of throwing everything into one big pile.
Why This Matters for Everyone
Even if you're not planning to become an AI expert, understanding delimiters helps you:
Get better results when using AI tools like chatbots
Organise your thoughts more clearly when asking questions
Understand why some AI responses work better than others
For those wanting to dig deeper, delimiters are part of a fascinating field called prompt engineering. They can be simple (like using ### or ---) or more complex (like XML tags). The key is consistency and clarity, just like how traffic signs use consistent colors and shapes to convey meaning.
Try It Yourself
Next time you're using an AI tool, try organising your request with simple delimiters. For example:
BACKGROUND: I'm writing a blog about gardening TASK: Generate 3 catchy titles STYLE: Professional but friendly MUST INCLUDE: The word "sustainable"
You might be surprised at how much more precise and helpful the AI's response becomes.
What are Delimiters?
In prompt engineering, delimiters are specific characters or sequences used to separate different parts of a prompt. These can be simple like triple quotes ("""), XML tags (<tag> </tag>), or unique symbol combinations (###, ===, >>>). Delimiters act as markers, enabling the LLM to identify and interpret distinct sections within the prompt, such as instructions, context, input data, or desired output format.
Why Use Delimiters?
Delimiters offer several benefits in prompt engineering:
Clarity: They enhance the clarity and organization of prompts, making it easier for both the LLM and the human user to understand the structure and intent5.
Control: By clearly separating different sections, delimiters provide greater control over how the LLM processes the input and generates the output6. For instance, when asking an LLM to write code, delimiters help in segregating the task's description, any constraints or special requirements, and additional notes or context. This approach ensures that all aspects of the request are addressed in the response, leading to more accurate and tailored code output5.
Error Reduction: Well-defined sections reduce ambiguity and the likelihood of the LLM misinterpreting the prompt, leading to more accurate and relevant responses6.
Flexibility: Delimiters allow for flexibility in structuring prompts, accommodating various levels of complexity and different types of tasks6.
Structured Outputs: Delimiters enable LLMs to generate structured outputs like lists, tables, and code blocks. By clearly defining the desired output format within the prompt, delimiters guide the LLM to produce responses that adhere to specific structures, improving the organization and usability of the generated content6.
Complementary Role with CO-STAR Framework: The CO-STAR framework, a valuable technique for organizing prompt content, often used in conjunction with delimiters, helps structure the content within the prompt. It stands for Context, Constraint, Output, Style, Actor, and Reward. By providing clear context, constraints, desired output format, style, actor, and reward, the CO-STAR framework enhances the LLM's understanding of the task and guides it towards generating more relevant and accurate responses4.
Impact of Delimiters on LLM Performance
Delimiters can significantly improve the performance of LLMs in various tasks6. For example, a study found that using specialized delimiters to mark the beginning and end of input documents reduced the attack success rate in adversarial attacks by half9. In another study, researchers assessed the impact of different delimiters (",", "|", or no delimiter) on LLM performance when processing images. A delimiter delineates between adjacent pixels, and "newline" characters were used to separate the rows in an image. The study found that the choice of delimiter can affect the accuracy of image processing tasks10. Additionally, delimiters play a crucial role in long-context Retrieval-Augmented Generation (RAG) applications. In RAG, LLMs retrieve relevant information from a knowledge base to answer questions or generate text. Delimiters are used to concatenate the retrieved chunks of information, ensuring that the LLM can effectively process and utilize the combined knowledge11. These findings highlight the importance of delimiters in optimizing LLM performance and ensuring reliable outputs.
Examples of Delimiters in Prompts
Here are some examples illustrating the use of delimiters in prompts:
Create fun team names like "The Habitat Heroes" or "Ecosystem Explorers"
3-4 students per team
Each team gets their own terrarium to design and care for </team_setup>
<materials> - Clear containers (our mini-worlds!) - Soil and pebbles - Small plants - Friendly bugs like roly-polies - Magnifying glasses - Colorful observation journals - Decorative items (optional) </materials>
Draw your dream mini-world
Pick team roles (Plant Expert, Bug Whisperer, Weather Watcher)
Create team flag/banner
Building Day
Layer your world (like making a sandwich!)
Plant your tiny garden
Add your creature friends
Daily Adventures
Morning check-ins with your mini-world
Draw what you see
Make up stories about your creatures
Show and Tell Day
Present your mini-world
Share your favorite observations
Tell the story of your ecosystem </fun_activities>
<creative_elements>
Name your creatures
Write "A Day in the Life" stories
Draw comic strips about your ecosystem
Make "Wanted" posters for your bugs </creative_elements>
See how the delimited version helps organise the project and creates clear focus points.
Conclusion
Delimiters are essential tools in prompt engineering for LLMs. They enhance the clarity, control, and flexibility of prompts, leading to more accurate, relevant, and structured outputs.
By clearly separating different sections within a prompt, delimiters help LLMs understand the task, reduce ambiguity, and generate responses that meet specific requirements. Various types of delimiters, such as special characters, XML tags, and custom keywords, cater to different needs and prompt structures. Prompt engineers should carefully select and utilise delimiters to optimise LLM performance and ensure the effective communication of instructions and information. As the field of prompt engineering continues to evolve, mastering the use of delimiters will remain a crucial skill for effectively interacting with and harnessing the power of LLMs.
Works cited
1. www.promptingguide.ai, accessed on December 31, 2024,
https://www.promptingguide.ai/#:~:text=Prompt%20engineering%20skills%20help%20to,question%20answering%20and%20arithmetic%20reasoning
2. Prompt Engineering Guide, accessed on December 31, 2024,
https://www.promptingguide.ai/
3. www.analyticsvidhya.com, accessed on December 31, 2024, https://www.analyticsvidhya.com/blog/2024/07/delimiters-in-prompt-engineering/#:~:text=In%20the%20context%20of%20prompt,without%20problems%20parse%20and%20understand.
4. CO-STAR and Delimiters: Elevate Your Prompt Engineering Skills | Streamline, accessed on December 31, 2024, https://www.streamline.us/blog/co-star-and-delimiters-elevate-your-prompt-engineering-skills/
5. Alternative Prompt Engineering Approach: Sectioning with Delimeters | by Thomas Czerny, accessed on December 31, 2024, https://medium.com/@thomasczerny/alternative-prompt-engineering-approach-sectioning-with-delimeters-112ff9d7953f
6. Delimiters in Prompt Engineering - Analytics Vidhya, accessed on December 31, 2024, https://www.analyticsvidhya.com/blog/2024/07/delimiters-in-prompt-engineering/
7. Crafting Precision: A Deep Dive into Prompt Engineering Delimiters ..., accessed on December 31, 2024, https://ai.plainenglish.io/crafting-precision-a-deep-dive-into-prompt-engineering-delimiters-6fdc63b9a32d
8. A Prompting Technique: Using Delimiters | by Sarin Suriyakoon | Medium, accessed on December 31, 2024, https://sarinsuriyakoon.medium.com/effective-prompting-a-guide-to-using-delimiters-747a45dc0e46
9. arXiv:2403.14720v1 [cs.CR] 20 Mar 2024, accessed on December 31, 2024, https://arxiv.org/pdf/2403.14720
10. LLMs and the Abstraction and Reasoning Corpus: Successes, Failures, and the Importance of Object-based Representations - arXiv, accessed on December 31, 2024, https://arxiv.org/html/2305.18354v2
11. Long Context RAG Performance of LLMs | Databricks Blog, accessed on December 31, 2024, https://www.databricks.com/blog/long-context-rag-performance-llms
Thanks for this! It is helpful. Great breakdown of both why and how. 🙌🏼