Reflexion
Even the best models make mistakes. Reflexion is a technique that gives the AI a chance to evaluate its own output and then improve it based on feedback. It’s like having the model reflect on what went wrong and try again.
Reflexion = generate an answer → evaluate (self‑critique) → refine.
How Reflexion Works
1. The model produces an initial answer.
2. A separate prompt (or the same model) evaluates the answer against criteria (e.g., correctness, format).
3. The model receives the critique and a instruction to improve.
4. It produces a revised answer.
5. Repeat until satisfactory or max iterations.
Example: Code Generation with Self‑Correction
Step 1: Write a Python function to reverse a string.
AI: def reverse(s): return s[::-1]
Critic: The function works, but add a docstring.
Step 2: Revised: def reverse(s): """Returns reversed string.""" return s[::-1]Self‑Reflection Prompt
A simple way to implement reflexion manually: after getting an answer, ask "Does this answer meet all requirements? If not, what is missing?" Then feed that critique back.
When to Use Reflexion
- When you have clear evaluation criteria (e.g., code must run, answer must be in JSON).
- When one‑shot answers are often flawed.
- When you can afford multiple API calls.
Two Minute Drill
- Reflexion = generate → evaluate → refine loop.
- The model critiques its own output.
- Improves answer quality, especially for structured tasks.
- Costs more but yields higher accuracy.
Need more clarification?
Drop us an email at career@quipoinfotech.com
