Code Repair with LLMs gives an Exploration-Exploitation Tradeoff
Hao Tang, Keya Hu, Jin Peng Zhou, Sicheng Zhong, Wei-Long Zheng, Xujie, Si, Kevin Ellis

TL;DR
This paper explores the tradeoff between exploration and exploitation in iterative code repair using large language models, proposing a bandit-based approach that improves problem-solving efficiency across diverse tasks.
Contribution
It introduces a novel exploration-exploitation framework for code refinement with LLMs, framing it as a bandit problem and demonstrating its effectiveness across multiple domains.
Findings
Outperforms greedy strategies in code repair tasks
Solves more problems with fewer LLM calls
Applicable across diverse problem types
Abstract
Iteratively improving and repairing source code with large language models (LLMs), known as refinement, has emerged as a popular way of generating programs that would be too complex to construct in one shot. Given a bank of test cases, together with a candidate program, an LLM can improve that program by being prompted with failed test cases. But it remains an open question how to best iteratively refine code, with prior work employing simple greedy or breadth-first strategies. We show here that refinement exposes an explore-exploit tradeoff: exploit by refining the program that passes the most test cases, or explore by refining a lesser considered program. We frame this as an arm-acquiring bandit problem, which we solve with Thompson Sampling. The resulting LLM-based program synthesis algorithm is broadly applicable: Across loop invariant synthesis, visual reasoning puzzles, and…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
Taxonomy
TopicsScientific Computing and Data Management · Advanced Data Storage Technologies
