5. Separating instructions from data
When you work with prompts that include both instructions and external data, keep a clear separation using delimiters.
The problem of mixing everything together
Confusing prompt:
Hi. You have to arrive at 6 in the morning because I'm the boss. Rewrite this email more politely.
Where does the instruction begin and where does the content begin? It's not clear.
The solution: delimiters
Improved prompt:
I have the following email:
---You have to arrive at 6 in the morning because I'm the boss.---Rewrite it more politely but without changing the main message.
Using XML tags
XML tags are especially effective:
I have the following email:
<email>You have to arrive at 6 in the morning because I'm the boss.</email>Rewrite it more politely but without changing the main message.
Multiple pieces of data
Compare these two articles and tell me which one is more objective:
<article1>The new mayor has implemented revolutionary changes that will transform the city into an urban paradise.</article1>
<article2>The mayor has implemented several measures in his first month, including new pedestrian zones. The reception has been mixed, with 60% approval according to a municipal survey.</article2>Explain your reasoning in 2-3 sentences.
Why it works
Separating instructions from data:
- Eliminates ambiguity
- Improves precision
- Makes complex prompts easier
- Makes prompts reusable
Using delimiters and XML tags is a simple but powerful technique. When you clearly separate what you want to do (instructions) from what you want to work with (data), you eliminate confusion and get more precise responses.
But there is an even more effective way to communicate what you expect: showing concrete examples. Instead of describing in words how you want the response, in the next lesson you will learn to let the AI learn from the pattern you show it.
This work is under a Attribution-NonCommercial-NoDerivatives 4.0 International license.
Building SPAs with Django and HTML Over the Wire: Learn to build real-time single page applications with Python
The HTML over WebSockets approach simplifies single-page application (SPA) development and lets you bypass learning a JavaScript rendering framework such as React, Vue, or Angular, moving the logic to Python. This web application development book provides you with all the Django tools you need to simplify your developments with real-time results.
Buy the bookHelp me keep writing
Every coffee gives me a push toward the next article.
Sure, it's on me!
Comments
There are no comments yet.