P

Self Refine: Definition and Examples

Self Refine is a technique where a language model generates an initial response, then evaluates and improves it iteratively without human intervention, resulting in a higher quality output.

Full definition

Self Refine is an iterative improvement approach in which a large language model (LLM) simultaneously plays the roles of generator, critic, and reviser. Instead of producing a single response, the model first produces an initial draft, then analyzes it to identify weaknesses, and finally rewrites it incorporating its own feedback. This cycle can be repeated several times until a satisfactory quality level is reached.

This technique is directly inspired by the human writing process: one rarely writes a perfect text in a first draft. We reread, identify weak passages, rephrase, restructure. Self Refine replicates this cognitive mechanism by formalizing it in a structured prompt. The key lies in the model's ability to step back from its own output and apply explicit evaluation criteria.

Concretely, a Self Refine prompt decomposes into three distinct phases: initial generation, feedback (where the model critiques its own output according to defined criteria), and revision (where it produces an improved version integrating that feedback). Each phase can be handled in a separate prompt or chained within the same exchange. The major advantage is that no additional model or training data is needed.

Self Refine was formalized in a 2023 research paper by Madaan et al. and demonstrated significant improvements on diverse tasks such as code generation, mathematical reasoning, writing, and dialogue. This technique has become a pillar of advanced prompt engineering and naturally combines with other approaches like Chain of Thought or multi-agent systems.

Etymology

The term 'Self Refine' comes from English and literally means 'self-refine' or 'refine oneself'. It was popularized by the academic paper 'Self-Refine: Iterative Refinement with Self-Feedback' published in 2023 by Aman Madaan and collaborators at Carnegie Mellon University. The choice of term emphasizes the autonomy of the process: the model itself corrects itself without external supervision.

Concrete examples

Improving the quality of a professional email

Step 1: Write a professional email requesting a deadline extension from a client.

Step 2: Now, critique this email according to these criteria: tone (professional but empathetic), clarity of the request, proposal of alternative solution, appropriate length. List each weakness.

Step 3: Rewrite the email by correcting each identified weakness.

Optimizing Python code

Generate a Python function that sorts a list of dictionaries by multiple keys.

Now, evaluate this code against: readability, performance, edge case handling, and PEP 8 compliance. Identify each issue.

Produce an improved version that corrects all identified issues, explaining each modification.

Refining an argument in an essay

Write an argumentative paragraph on the impact of generative AI in education.

Evaluate this paragraph: is the thesis clear? Are the arguments supported by concrete examples? Are there biases or overgeneralizations? Does the paragraph anticipate counterarguments?

Rewrite the paragraph incorporating all suggested improvements.

Practical usage

To apply Self Refine, structure your prompt into three explicit steps: generation, critique with precise criteria, then revision. Always define the evaluation criteria in advance (clarity, relevance, tone, completeness) to guide the feedback phase effectively. You can repeat the critique-revision cycle two to three times for complex tasks, but beyond that, marginal gains typically diminish.

Related concepts

Chain of ThoughtReflexionConstitutional AICritique prompting

FAQ

What is the difference between Self Refine and simply asking 'improve your response'?
Self Refine structures the improvement process with explicit evaluation criteria and a formal critique phase before revision. Vaguely asking to improve a response does not give the model clear direction, often resulting in superficial changes. With Self Refine, the model knows exactly what to evaluate and what to correct, leading to targeted and measurable improvements.
How many iterations of Self Refine are needed to get a good result?
In practice, one to two iterations are sufficient for most tasks. The first iteration captures the most significant improvements, the second refines details. Beyond three iterations, the model tends to make minor changes or even degrade certain aspects of the response. For critical tasks like code generation, two iterations with different criteria each time generally yield the best results.
Does Self Refine work with all language models?
Self Refine requires a model capable enough to critically evaluate its own output. The most capable models (Claude, GPT-4, Gemini) excel at this because they can identify subtle nuances in their responses. Smaller models can benefit from the technique, but the quality of internal feedback will be limited by their abilities. In such cases, it is sometimes more effective to use a more powerful model solely for the critique phase.

See also

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. Replace the bracketed variables with your details, then refine the result.

About Prompt Guide

Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.

More definitions

Get new prompts every week

Join our newsletter.