Loading

Quipoin Menu

Learn • Practice • Grow

/
interview

Q1. What is Reflexion prompting?
Reflexion is a technique that allows an LLM to reflect on its own previous attempts and learn from mistakes.
It combines reinforcement learning concepts with prompting: the model generates an initial answer, evaluates it (or receives external feedback), then produces a reflection on what went wrong and how to improve.
The reflection is stored in a memory buffer and used to guide the next attempt. This creates a self-improvement loop.
Reflexion is particularly effective for multi‑turn tasks like programming, math problem solving, and strategy games, where the model can iteratively refine its output based on error messages or test results.

Q2. How does Reflexion differ from standard self-correction?
Standard self-correction asks the model to critique its own answer in the same turn or in a separate call but without persistent memory.
Reflexion maintains a long-term memory of reflections across attempts.
For example, after a failed code execution, the model writes a reflection like: "I used the wrong variable name. I should check variable definitions."
This reflection is stored and fed back into the prompt for the next attempt, preventing the same mistake.
Reflexion also uses a heuristic to decide when to stop (e.g., maximum attempts or success). This makes learning cumulative and more effective for complex tasks.

Q3. What are the core components of a Reflexion system?
A Reflexion system typically includes:
• An actor (the LLM) that generates attempts.
• An evaluator that assesses the attempt (could be a function, test suite, or another LLM).
• A reflection generator that produces textual feedback on the error.
• A memory module that stores past reflections.
• A termination condition (e.g., success or max attempts).
The process: actor generates output → evaluator gives score/error → reflection generator creates insight → memory updated → next attempt prompt includes the memory.
This loop continues until success or max tries.
Reflexion has been shown to improve performance on coding tasks (HumanEval) and decision-making tasks.

Q4. Give an example of Reflexion for a coding problem.
Problem: Write a function that returns the sum of squares of even numbers in a list.
Attempt 1: The model writes code that sums all squares without checking evenness. The evaluator (running the code) returns an error: incorrect output.
Reflection: "I forgot to filter only even numbers. I need to add a condition `if n % 2 == 0`." The reflection is stored.
Attempt 2: The model, now prompted with the reflection, writes corrected code. The evaluator passes.
This mirrors how a human programmer debugs.
Reflexion can also be used without code execution, using an LLM as the evaluator for tasks like reasoning puzzles.

Q5. What are the limitations of Reflexion?
Limitations include:
• Increased token cost and latency due to multiple attempts.
• The reflection generator must itself be competent; poor reflections may lead to no improvement.
• Memory may become very long, leading to context window issues.
• Reflexion may cause the model to overcorrect or fixate on minor issues.
• Requires a reliable evaluator (e.g., test cases or gold answers).
• Not suitable for real-time applications.
Despite these, Reflexion is a powerful technique for tasks where iterative improvement is acceptable, such as code generation, mathematical reasoning, and game playing.