Delimiters' Proven Impact on Prompt Injection Defense
Delimiters significantly enhance prompt injection defense, with some LLMs showing a notable increase in defense rates, for example, from 36.6% to 100% for Gemini 2.5 Flash when untrusted content is properly delimited. While not a complete solution, they markedly improve the model's ability to differentiate instructions from data, leading to more predictable and secure outputs.
The top 3
- Delimiters Boost Prompt Defense by 29%: Implementing delimiters significantly improves LLM defense against prompt injection, increasing success rates by an average of 29 percentage points; some models, like Gemini 2.5 Flash, saw defense rates jump from 36.6% to 100% when using boundary markers.
- Most Robust Delimiter Formats for LLM Safety: Top delimiter formats for LLM security include triple backticks (```), triple quotes ("""), pipes (|||), dashes (---), and XML tags (<tag></tag>), with XML and JSON providing marginally more robust boundaries for security-sensitive systems.
- Three Key Principles for Delimiter Implementation: Effective delimiter use hinges on three principles: choosing clear, unambiguous markers that avoid content interference; maintaining consistency across prompts; and explicitly instructing the AI on their purpose to ensure precise interpretation of instructions and context.
Sources
Open the full topic