LLMLOOP: Improving LLM-Generated Code and Tests through Automated Iterative Feedback Loops
Organizations: University of Auckland, Auckland, New Zealand · JRC European Commission, Ispra, Italy · King’s College London, London, United Kingdom
Abstract
Large Language Models (LLMs) are showing remarkable performance in generating source code, yet the generated code often has issues like compilation errors or incorrect code. Researchers and developers often face wasted effort in implementing checks and refining LLM-generated code, frequently duplicating their efforts. This paper presents LLMLOOP, a framework that automates the refinement of both source code and test cases produced by LLMs. LLMLOOP employs five iterative loops: resolving compilation errors, addressing static analysis issues, fixing test case failures, and improving test quality through mutation analysis. These loops ensure the generation of high-quality test cases that serve as both a validation mechanism and a regression test suite for the generated code. We evaluated LLMLOOP on HUMANEVAL-X, a recent benchmark of programming tasks. Results demonstrate the tool's effectiveness in refining LLM-generated outputs.
Figures & tables
| Flag | Additional Argument | Description |
| -e | - | Enable EvoSuite |
| -p | Path to Java project (String) | Path to an existing Java project |
| -d | - | Enable debug logging |
| -t | - | Enable test generation using LLMs |
| -r | - | Enable code coverage report |
| -n | Number of retries (Int) | Set the number of attempts in the feedback loop |
| LLMloop stage | pass@1 | pass@1 | |
| (mean std) | (mean %) | ||
| #1 | Baseline (no feedback loop) | 117.50 1.20 | 71.65% |
| #2 | Compilation (Loop 1) | 125.30 1.55 | 76.40% |
| #3 | HumanEval-X Given Tests (Loop 2) | 130.40 2.91 | 79.51% |
| #4 | Static Analysis (Loop 3) | 130.50 3.11 | 79.57% |
| Loops 4 and 5 repeated for LLM and EvoSuite -generated test cases | |||
LLM Code Generation
Large language model code generation studies how models translate instructions and context into executable programs and how to make them reliable.
See all 309 papers