When a prompt mixes instructions, documents and examples, the model needs to know which is which. Delimiters make structure explicit.
Common Delimiters
- XML-style tags:
<document>…</document>,<example>…</example>,<instructions>…</instructions>. - Markdown headings:
## Context,## Task. - Triple quotes or code fences for a block of text.
Many practitioners find XML-style tags especially clear for long, multi-part prompts.
Benefits
- The model distinguishes material to analyse from instructions to follow.
- Instructions can refer to parts by name: "Using only the text in
<contract>…". - Outputs can be requested in tags for easy parsing: "Put your final answer in
<answer>tags." - Reduces confusion when documents themselves contain instruction-like text.
Multiple Documents
Wrap each document separately with identifying attributes:
<documents>
<document id="1" title="Refund policy" date="2026-02-01">…</document>
<document id="2" title="Shipping policy" date="2025-11-10">…</document>
</documents>
Not a Security Boundary
Delimiters help the model understand structure, but they don't prevent prompt injection. Untrusted content can still influence behaviour.
Be Consistent
Use the same tag names throughout a prompt and across related prompts.