Self-Refine
A technique that asks the same model for feedback and iteratively improves the answer with it
Contents
A technique that takes feedback from the same model and improves the answer through repetition.
Concept
Self-Refine asks the same model for feedback and improves the answer with it over several rounds. With no separate verifier model and no external tools, the model that produced the answer points out the weaknesses in its own output and fixes them.
How it works
- Generation: produce the initial answer.
- Feedback request: ask the same model what could be improved.
- Refinement: apply the feedback to the answer.
- Evaluation: judge whether it got better. If it is still lacking, return to step 2 and repeat; if it is good enough, emit it as the final answer.
Example
First generation "AI possesses high intelligence."
Feedback request "Point out what could be improved in the sentence above."
Feedback "The scope of 'high intelligence' is vague. It needs to specify what kind of intelligence."
Second version "Artificial intelligence has reached human-level performance in natural language processing and image recognition."
Final evaluation "Much more specific and clear."
Code refactoring example
First generation
def calc(a, b, c): return a + b * cFeedback request "Point out what could be improved in the code above."
Feedback
- The function name is vague (calc → ?)
- The parameter names are unclear
- The operator precedence is not explicit
Second version
def calculate_total_with_multiplier(base, quantity, multiplier):Computes the total of the base plus (quantity * multiplier).return base + (quantity * multiplier)Feedback "Much clearer."
How it differs from Reflexion
| Reflexion | Self-Refine | |
|---|---|---|
| Trigger | Reflection after failure | Continuous improvement |
| Failure signal | Requires an explicit failure | Improves without any failure |
| Memory | Stored in long-term memory | Applied immediately |
| Where it fits | Coding, QA | Writing, summarization |
The core difference
- Reflexion: after an attempt fails, it analyzes "why did this fail?" and improves.
- Self-Refine: after an attempt, regardless of whether it failed, it asks "can this be better?" and improves.
Where it applies
Self-Refine is particularly useful on tasks with no single correct answer:
| Area | Examples |
|---|---|
| Writing | Essays, emails, reports |
| Code quality | Refactoring, readability |
| Summarization | Document summaries, key point extraction |
| Translation | Natural phrasing |
The algorithm
max_iterations caps the number of rounds, and the loop breaks early when the feedback comes back containing "no changes needed" or "good enough".
def self_refine(task, max_iterations=3):
# first generation
output = llm.generate(task)
for i in range(max_iterations):
# request feedback
feedback = llm.generate(
f"Point out what could be improved in the following output:\n{output}"
)
# decide whether more refinement is needed
if "no changes needed" in feedback or "good enough" in feedback:
break
# refine based on the feedback
output = llm.generate(
f"Feedback: {feedback}\n"
f"Previous output: {output}\n"
f"Revise the output according to the feedback."
)
return outputImproving feedback quality
Ask for specific feedback
Bad "Tell me what to improve."
Good "Point out improvements from the following angles:
- Clarity: can a reader follow this easily?
- Specificity: are there abstract phrases?
- Grammar: are there grammatical errors?
- Structure: does the logic flow naturally?"
Assign a role
"You are a technical documentation editor with ten years of experience. Point out what could be improved in the following document from an expert's perspective."
Stopping conditions
Ways to set the stopping condition for Self-Refine:
| Method | Description |
|---|---|
| Fixed iterations | Stop after three rounds |
| Feedback-based | Stop when the response says it is good enough |
| Change magnitude | Stop when the improvement gets small |
| Score-based | Stop when the quality score passes a threshold |
Limits
- Subjective judgment: it rests on the model's own bias
- Over-editing: unnecessary changes are possible
- Infinite loops: a stopping condition is required
- No fact checking: CRITIC is needed for that
Combining with CRITIC
When fact checking is required:
- Self-Refine: improve quality iteratively.
- CRITIC: verify the facts with external tools.
- Final result: emit output that has both quality and accuracy.
Summary
Self-Refine takes feedback from the same model and improves the answer repeatedly, even with no explicit failure signal. It earns its keep on tasks with no single correct answer, such as writing, summarization and code readability. Asking for feedback along specific, named angles and setting an explicit stopping condition reduces both over-editing and infinite loops. Its limits, dependence on the model's own bias and the inability to check facts, are covered by combining it with CRITIC, which verifies facts using external tools.
Related concepts
- Reflexion: failure-driven learning
- CRITIC: verification with external tools
- Multi-Agent Debate: feedback from other agents