Self-Refine and CRITIC: Iterative Output Improvement
Self-Refine (Madaan et al., 2023) uses one LLM in three roles — generate, feedback, refine — in a loop. Average gain: +20 absolute on 7 tasks. CRITIC (Gou et al., 2023) hardens the feedback step by routing verification through external tools. In 2026 this pattern ships in every framework as "evaluator-optimizer" (Anthropic) or a guardrail loop (OpenAI Agents SDK). State Self-Refine's three prompts (generate, feedback, refine) and explain why history matters for the refine prompt. Explain CRITIC's critical insight: LLMs are unreliable at self-verification without external grounding. Implement a stdlib Self-Refine loop with history and an optional external verifier. Map this pattern to Anthropic's "evaluator-optimizer" workflow and OpenAI Agents SDK's output guardrails. An agent produces an answer that is almost right. Maybe a line of code has a syntax error. Maybe a summary is too long. Maybe a plan misses an edge case. What you want is: the agent critiques its own output, then fixes it. Self-Refine shows this works with a single model, no training data, no RL. But there is a catch: LLMs are bad at self-verification on hard facts. CRITIC names the fix — route the verify step through external tools (search, code interpreter, calculator, test runner). Together these two papers define the 2026 default for iterative improvement: generate, verify (externally when possible), refine, stop when the…
Self-Refine and CRITIC: Iterative Output Improvement: Self-Refine (Madaan et al., 2023) uses one LLM in three roles — generate, feedback, refine — in a loop.…
This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.
Browse the complete course catalog or open this lesson on GitHub.