Iterative Refinement Loop: A Design Pattern for Code Generation with LLMs
摘要
Large Language Models (LLMs) have revolutionized software development and promised great efficiency gains, but their probabilistic nature still makes them unpredictable and unreliable: They frequently generate code that contains errors, defects, or fails to meet project standards. This paper introduces the Iterative Refinement Loop, a design pattern that addresses this reliability gap. The pattern establishes a feedback loop where validation tools–such as compilers, linters, and test suites–provide corrective feedback to the LLM. This guides the model through successive iterations to produce a correct, high-quality artifact, offering a robust, automatable mechanism that transforms an unreliable generator into a dependable partner for co-creating software.