Lune

ASE2024Top-tier venue

Preference-Guided Refactored Tuning for Retrieval Augmented Code Generation

Xinyu Gao, Yun Xiong, Deze Wang, Zhenhan Guan, Zejian Shi, Haofen Wang, Shanshan Li

Abstract

Retrieval-augmented code generation utilizes Large Language Models as the generator and significantly expands their code generation capabilities by providing relevant code, documentation, and more via the retriever. The current approach suffers from two primary limitations: 1) information redundancy. The indiscriminate inclusion of redundant information can result in resource wastage and may misguide generators, affecting their effectiveness and efficiency. 2) preference gap. Due to different optimization objectives, the retriever strives to procure code with higher ground truth similarity, yet this effort does not substantially benefit the generator. The retriever and the generator may prefer different golden code, and this gap in preference results in a suboptimal design. Additionally, differences in parameterization knowledge acquired during pre-training result in varying preferences among different generators. To address these limitations, in this paper, we propose RRG (Retrieve, Refactor, Generate), a novel framework for effective and efficient code generation. This framework introduces a code refactorer module between the retriever and the generator to bridge them. The refactoring process transforms the raw retrieved code

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.

7 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

  • Securing Retrieval-Augmented Code Generation via Contextual Knowledge Injection: A Case for Embedded IoT Applications cites RESCUE: Retrieval Augmented Secure Code Generation
  • Securing Retrieval-Augmented Code Generation via Contextual Knowledge Injection: A Case for Embedded IoT Applications cites Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injection
  • Improving Language Models by Retrieving from Trillions of Tokens cites Generalization through Memorization: Nearest Neighbor Language Models
  • Improving Language Models by Retrieving from Trillions of Tokens cites Language Models are Few-Shot Learners
  • Improving Language Models by Retrieving from Trillions of Tokens cites Retrieval Augmented Language Model Pre-Training
  • RESCUE: Retrieval Augmented Secure Code Generation cites Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injection
  • Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injection cites Language Models are Few-Shot Learners
  • ProofFusion: Improving Neural Theorem Proving via Adaptive Retrieval-Augmented Reasoning cites Generalization through Memorization: Nearest Neighbor Language Models
  • Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflection cites Retrieval Augmented Language Model Pre-Training
  • Retrieval Augmented Language Model Pre-Training cites Generalization through Memorization: Nearest Neighbor Language Models
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers7

  1. RESCUE: Retrieval Augmented Secure Code GenerationJiahao Shi, Tianyi ZhangICLR 2026 · 15 citations
  2. Securing Retrieval-Augmented Code Generation via Contextual Knowledge Injection: A Case for Embedded IoT ApplicationsTong Sun, Jingyi Su, Yi Gao, Wei DongUSENIX Security 2026
  3. Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge InjectionBo Lin, Shangwen Wang, Yihao Qin, Liqian Chen et al.CCS 2025
  4. ProofFusion: Improving Neural Theorem Proving via Adaptive Retrieval-Augmented ReasoningManqing Zhang, Yunwei Dong, Lingru Zhou, Bingxu Xiao et al.FSE 2026
  5. In Line with Context: Repository-Level Code Generation via Context InliningChao Hu, Wenhao Zeng, Yuling Shi, Beijun Shen et al.FSE 2026

Builds on31

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Retrieval Augmented Language Model Pre-TrainingKelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat et al.ICML 2020 · 2,937 citations
  3. Self-RAG: Learning to Retrieve, Generate, and Critique through Self-ReflectionAkari Asai, Zeqiu Wu, Yizhong Wang, Avirup Sil et al.ICLR 2024 · 1,798 citations
  4. Improving Language Models by Retrieving from Trillions of TokensSebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai et al.ICML 2022 · 1,629 citations
  5. Generalization through Memorization: Nearest Neighbor Language ModelsUrvashi Khandelwal, Omer Levy, Dan Jurafsky, Luke Zettlemoyer et al.ICLR 2020 · 1,038 citations

Related papers

  1. SRACG: A Code Generation Framework with Selective Retrieval AugmentationMengzhen Wang, Shukai Ma, Songwen Gong, Jiexin Wang et al.AAAI 2026
  2. SelfRACG: Enabling LLMs to Self-Express and Retrieve for Code GenerationQian Dong, Jia Chen, Qingyao Ai, Hongning Wang et al.EMNLP 2025
  3. R²AG: Incorporating Retrieval Information into Retrieval Augmented GenerationFuda Ye, Shuangyin Li, Yongqi Zhang, Lei ChenEMNLP Findings 2024 · 18 citations
  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. Bridging Relevance and Reasoning: Rationale Distillation in Retrieval-Augmented GenerationPengyue Jia, Derong Xu, Xiaopeng Li, Zhaocheng Du et al.ACL Findings 2025 · 5 citations
Dusk over the sea between two cliffs drawn in fine vertical lines