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.
Paper Type: long
Research Area: Information Retrieval and Text Mining
Contribution Types: NLP engineering experiment
Languages Studied: English, Python (Programming Language), Java (Programming Language)
Preprint Status: There is a non-anonymous preprint (URL specified in the next question).
A1: yes
A2: n/a
A3: yes
B: yes
B1: yes
B1 Section Or Justification: Section 5 and Apendix C.3
B2: n/a
B3: n/a
B4: n/a
B5: yes
B5 Section Or Justification: Appendix C.3
B6: yes
B6 Section Or Justification: Appendix C.1
C: yes
C1: yes
C1 Section Or Justification: Appendix C.3
C2: yes
C2 Section Or Justification: Section 5 and Appendix C.3
C3: yes
C3 Section Or Justification: Appendix C.3
C4: yes
C4 Section Or Justification: Section 5 and Appendix C.3
D: no
D1: n/a
D2: n/a
D3: n/a
D4: n/a
D5: n/a
E: no
E1: n/a
0 Replies
Loading