Lune

ACL2024Top-tier venue

Rewriting the Code: A Simple Method for Large Language Model Augmented Code Search

Haochen Li, Xin Zhou, Zhiqi Shen

Abstract

In code search, the Generation-Augmented Retrieval (GAR) framework, which generates exemplar code snippets to augment queries, has emerged as a promising strategy to address the principal challenge of modality misalignment between code snippets and natural language queries, particularly with the demonstrated code generation capabilities of Large Language Models (LLMs). Nevertheless, our preliminary investigations indicate that the improvements conferred by such an LLM-augmented framework are somewhat constrained. This limitation could potentially be ascribed to the fact that the generated codes, albeit functionally accurate, frequently display a pronounced stylistic deviation from the ground truth code in the codebase. In this paper, we extend the foundational GAR framework and propose a simple yet effective method that additionally Rewrites the Code (ReCo) within the codebase for style normalization. Experimental results demonstrate that ReCo significantly boosts retrieval accuracy across sparse (up to 35.7%), zero-shot dense (up to 27.6%), and fine-tuned dense (up to 23.6%) retrieval settings in diverse search scenarios. To further elucidate the advantages of ReCo and stimulate research in code style normalization, we introduce Code Style Similarity, the first metric tailored to quantify stylistic similarities in code. Notably, our empirical findings reveal the inadequacy of existing metrics in capturing stylistic nuances. The source code and data are available at https: //github.com/Alex-HaochenLi/ReCo .

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

4 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis cites Language Models are Few-Shot Learners
  • GiFT: Gibbs Fine-Tuning for Code Generation cites WizardCoder: Empowering Code Large Language Models with Evol-Instruct
  • Uncertainty-Aware Contrastive Learning with Hard Negative Sampling for Code Search Tasks cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Uncertainty-Aware Contrastive Learning with Hard Negative Sampling for Code Search Tasks cites GraphCodeBERT: Pre-training Code Representations with Data Flow
  • EpiCoder: Encompassing Diversity and Complexity in Code Generation cites Language Models are Few-Shot Learners
  • EpiCoder: Encompassing Diversity and Complexity in Code Generation cites WizardCoder: Empowering Code Large Language Models with Evol-Instruct
  • WizardCoder: Empowering Code Large Language Models with Evol-Instruct cites CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
  • WizardCoder: Empowering Code Large Language Models with Evol-Instruct cites Language Models are Few-Shot Learners
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers4

  1. Uncertainty-Aware Contrastive Learning with Hard Negative Sampling for Code Search TasksHan Liu, Jiaqing Zhan, Qin ZhangAAAI 2025 · 1 citation
  2. GiFT: Gibbs Fine-Tuning for Code GenerationHaochen Li, Wanjin Feng, Xin Zhou, Zhiqi ShenACL 2025
  3. EpiCoder: Encompassing Diversity and Complexity in Code GenerationYaoxiang Wang, Haoling Li, Xin Zhang, Jie Wu et al.ICML 2025
  4. Function-to-Style Guidance of LLMs for Code TranslationLonghui Zhang, Bin Wang, Jiahao Wang, Xiaofeng Zhao et al.ICML 2025

Builds on14

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan et al.EMNLP Findings 2020 · 2,828 citations
  3. GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng et al.ICLR 2021 · 1,644 citations
  4. WizardCoder: Empowering Code Large Language Models with Evol-InstructZiyang Luo, Can Xu, Pu Zhao, Qingfeng Sun et al.ICLR 2024 · 945 citations
  5. CodeGen: An Open Large Language Model for Code with Multi-Turn Program SynthesisErik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu et al.ICLR 2023 · 234 citations

Related papers

  1. What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and BeyondWenchao Gu, Juntao Chen, Yanlin Wang, Tianyue Jiang et al.ICSE 2026 · 1 citation
  2. Beyond Functional Correctness: Investigating Coding Style Inconsistencies in Large Language ModelsYanlin Wang, Tianyue Jiang, Mingwei Liu, Jiachi Chen et al.FSE 2025 · 6 citations
  3. Preference-Guided Refactored Tuning for Retrieval Augmented Code GenerationXinyu Gao, Yun Xiong, Deze Wang, Zhenhan Guan et al.ASE 2024 · 1 citation
  4. AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code CompletionTianyue Jiang, Yanlin Wang, Yanli Wang, Daya Guo et al.ASE 2025 · 2 citations
  5. SRACG: A Code Generation Framework with Selective Retrieval AugmentationMengzhen Wang, Shukai Ma, Songwen Gong, Jiexin Wang et al.AAAI 2026
Dusk over the sea between two cliffs drawn in fine vertical lines