Constraints and Negative Instructions
What you'll learn: How to use "don't do this" rules to keep LLM responses on track and avoid unwanted content.
The Core Idea
When prompting an LLM, you often need to tell it what not to do just as much as what to do. Constraints and negative instructions explicitly define boundaries—they prevent the model from including unwanted elements, using inappropriate formats, or drifting into irrelevant territory.
Think of it like giving directions to a friend: "Take the highway to downtown, but don't go through the tunnel—it's always jammed. And avoid stopping for food until we get there." Negative instructions create guardrails.
Why This Matters
Without constraints, models may:
- Add unnecessary explanations when you want just the answer
- Use formatting you didn't request (like bullet points when you wanted plain text)
- Include disclaimers or warnings you don't need
- Hallucinate details beyond what you asked for
Examples of Negative Instructions
- "Do not include any code examples in your explanation."
- "Avoid using technical jargon or acronyms."
- "Don't apologize or add conversational phrases like 'I hope this helps.'"
- "Never fabricate dates, numbers, or statistics—only use provided information."
- "Do not repeat the user's question in your response."
Combining With Positive Instructions
Constraints work best when paired with clear positive directions (from Explicit Output Format Instructions):
"Summarize this article in 3 sentences. Do not include your opinion or analysis. Avoid using quotes from the text."
Key Takeaway: Negative instructions and constraints act as boundaries that prevent unwanted behaviors, making outputs cleaner and more predictable by explicitly stating what the model should avoid.