Advanced Reasoning Strategies / Self-Improvement

Self-Refine

Advanced [4/5]
Iterative self-improvement Self-refinement Feedback-driven revision

Definition

Self-Refine is a technique where the model iteratively improves its output through a generate-critique-refine loop. After initial generation, the model critiques its own response, then produces an improved version based on that feedback.

This process can repeat multiple times until the output meets quality criteria or shows no further improvement.

Key Concepts

  • Generate: Produce initial output for the task
  • Critique: Identify weaknesses and areas for improvement
  • Refine: Create improved version addressing the critique
  • Iterate: Repeat until quality threshold met

Examples

Complete Loop
Self-Refine in Action
Task: "Write a professional email declining a meeting" ITERATION 1: Generate: "I can't come to the meeting. Too busy." Critique: "Too abrupt and unprofessional. Missing: - Polite greeting, reason for declining, alternative suggestions, professional closing." Refine: "Hi, Thanks for the invite. Unfortunately I have a conflict. Could we reschedule? Best, [Name]" ITERATION 2: Critique: "Better but still brief. Could be warmer, specify willingness to find alternative time." Refine: "Hi [Name], Thank you for thinking of me for this meeting. Unfortunately, I have a prior commitment at that time. I'd value the opportunity to connect—would any time later this week work for you? Please let me know your availability and I'll do my best to accommodate. Best regards, [Your name]" ITERATION 3: Critique: "Professional, warm, and actionable. No major improvements needed." Final Output: [Iteration 2 response]
Implementation
Self-Refine Algorithm
def self_refine(task, model, max_iterations=3): # Initial generation output = model.generate(task) for i in range(max_iterations): # Critique current output critique = model.generate(f""" Critique this response for the task "{task}": Response: {output} List specific weaknesses and improvements needed. """) # Check if refinement needed if "no major improvements" in critique.lower(): break # Refine based on critique output = model.generate(f""" Task: {task} Previous response: {output} Critique: {critique} Write an improved response addressing the critique. """) return output

Interactive Exercise

Practice Self-Refine

Given this initial output and critique, write a refined version:

Task: "Explain APIs to a beginner"
Initial: "An API is an Application Programming Interface."
Critique: "Just states the acronym. Missing: analogy, practical example, why it matters."

Pro Tips
  • Set clear stopping criteria to avoid infinite loops
  • Include the original task in each iteration for context
  • Track improvements to detect when refinement plateaus
  • 3-5 iterations usually sufficient for most tasks

Related Terms