Module 4 Lesson 5: Debugging Prompt Failures
What to do when the AI gets it wrong. Advanced troubleshooting for prompt logic and output quality.
Debugging Prompt Failures
When a prompt fails, it's usually not because the AI is "stupid"—it's because the prompt is leaky, ambiguous, or over-constrained.
1. Common Failure Modes
The "Wall of Text" Failure
The AI gives a long, rambling answer when you wanted a short one.
- The Fix: Move your constraint (e.g., "Maximum 50 words") to the very end of the prompt. Models pay more attention to the end of the text.
The "Hallucination" Failure
The AI makes up facts.
- The Fix: Add a "Negative Constraint." Tell it: "If you are unsure of a fact, say 'I don't know'. Do not guess."
The "Instruction Ignored" Failure
The AI misses one of your 10 instructions.
- The Fix: Use Delimiters (###) to separate instructions. Or, break the prompt into two steps.
2. The "De-Bugging" Checklist
If a prompt is failing, ask these five questions:
- Is the Instruction at the start or the end? (Try moving it to the end).
- Are there too many OR conditions? (Be more binary).
- Have I provided an Example? (Add a few-shot example).
- Is the text Delimited? (Use ### or ---).
- Is the model's Temperature too high? (Try reducing randomness).
graph TD
Fail[Prompt Failed] --> Check1{Instruction Position?}
Check1 -->|Start| Move[Move to End]
Check1 -->|End| Check2{Ambiguity?}
Check2 -->|Yes| Clarify[Use Precise Verbs]
Check2 -->|No| Check3{Need Example?}
Check3 -->|Yes| AddFew[Add Few-Shot]
3. The "Self-Correction" Technique
If the prompt fails in the chat, ask the AI to debug itself.
"I asked you to format this as a table, but you gave me a list. Why did you ignore that instruction, and how can I rephrase my prompt to ensure you follow it next time?"
Hands-on: Fix the Leaky Prompt
The Bad Prompt: "Write a story about a cat but don't use the word 'cat' or 'kitten' and make sure it has a happy ending and is exactly 100 words."
The Problem: This is over-constrained. The AI will often fail the word count or accidentally use the forbidden words.
Your Task: Break this into two steps.
- Step 1: Write the story.
- Step 2: "Now, edit the previous story to remove the words 'cat' and 'kitten' and ensure the length is correct."
Key Takeaways
- Instructions at the end have more weight.
- Less is more: Don't over-constrain the model in one go.
- Use the Self-Correction method to improve your skills.