Let's Revise Step-by-Step: A Unified Local Search Framework for Code Generation with LLMs

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Lyu, Zhiyi, Huang, Jianguo, Deng, Yanchen, Hoi, Steven, An, Bo
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912531223674880
author Lyu, Zhiyi
Huang, Jianguo
Deng, Yanchen
Hoi, Steven
An, Bo
author_facet Lyu, Zhiyi
Huang, Jianguo
Deng, Yanchen
Hoi, Steven
An, Bo
contents Large Language Models (LLMs) with inference-time scaling techniques show promise for code generation, yet face notable efficiency and scalability challenges. Construction-based tree-search methods suffer from rapid growth in tree size, high token consumption, and lack of anytime property. In contrast, improvement-based methods offer better performance but often struggle with uninformative reward signals and inefficient search strategies. In this work, we propose \textbf{ReLoc}, a unified local search framework which effectively performs step-by-step code revision. Specifically, ReLoc explores a series of local revisions through four key algorithmic components: initial code drafting, neighborhood code generation, candidate evaluation, and incumbent code updating, each of which can be instantiated with specific decision rules to realize different local search algorithms such as Hill Climbing (HC) or Genetic Algorithm (GA). Furthermore, we develop a specialized revision reward model that evaluates code quality based on revision distance to produce fine-grained preferences that guide the local search toward more promising candidates. Finally, our extensive experimental results demonstrate that our approach achieves superior performance across diverse code generation tasks, significantly outperforming both construction-based tree search as well as the state-of-the-art improvement-based code generation methods.
format Preprint
id arxiv_https___arxiv_org_abs_2508_07434
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Let's Revise Step-by-Step: A Unified Local Search Framework for Code Generation with LLMs
Lyu, Zhiyi
Huang, Jianguo
Deng, Yanchen
Hoi, Steven
An, Bo
Computation and Language
Large Language Models (LLMs) with inference-time scaling techniques show promise for code generation, yet face notable efficiency and scalability challenges. Construction-based tree-search methods suffer from rapid growth in tree size, high token consumption, and lack of anytime property. In contrast, improvement-based methods offer better performance but often struggle with uninformative reward signals and inefficient search strategies. In this work, we propose \textbf{ReLoc}, a unified local search framework which effectively performs step-by-step code revision. Specifically, ReLoc explores a series of local revisions through four key algorithmic components: initial code drafting, neighborhood code generation, candidate evaluation, and incumbent code updating, each of which can be instantiated with specific decision rules to realize different local search algorithms such as Hill Climbing (HC) or Genetic Algorithm (GA). Furthermore, we develop a specialized revision reward model that evaluates code quality based on revision distance to produce fine-grained preferences that guide the local search toward more promising candidates. Finally, our extensive experimental results demonstrate that our approach achieves superior performance across diverse code generation tasks, significantly outperforming both construction-based tree search as well as the state-of-the-art improvement-based code generation methods.
title Let's Revise Step-by-Step: A Unified Local Search Framework for Code Generation with LLMs
topic Computation and Language
url https://arxiv.org/abs/2508.07434