Lesson 9 / 29

Delimiters and Separating Data from Instructions

Use tags, quotes or fences to mark the input clearly.

Fences make boundaries obvious

Wrap variable content in clear delimiters: XML-style tags (<document>...</document>), triple quotes or Markdown code fences. Name the section in your instructions ("summarise the text inside <document> tags"). This prevents the model confusing a quoted email with your instructions, makes multi-part prompts readable, and lets you reference parts ("compare <draft> with <policy>"). It also helps with security: tell the model that the tagged content is data and any instructions inside it must be ignored (see the safety section).

Tagged sections

Instructions refer to the tags by name.

Compare the <draft> against the <policy> and list every violation.

<policy>
No promises of delivery dates. No personal data in replies.
</policy>

<draft>
Hi Asha, your order 4821 will arrive on Friday for sure.
</draft>

Pick delimiters that cannot appear in the input

If the input could contain your closing tag, strip or escape it before wrapping, as the safety section shows.

Quick check: Why wrap input in tags?

  • To change the language
  • To compress the text
  • To mark clearly what is data and what are instructions
  • To avoid tokens
Answer

To mark clearly what is data and what are instructions — Clear boundaries reduce confusion and injection risk.