Preference-Guided Refactored Tuning for Retrieval Augmented Code Generation
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
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 into a more concise, efficient, and model-friendly version. It eliminates redundant information and noise, reducing the input length. Consequently, the generator receives higher-quality context, enabling it to produce more accurate results with lower inference costs. We conducted comprehensive experiments on multiple datasets. In the experiments, we confirmed the existence of a preference gap between the retriever and the generator, and RRG effectively bridges this gap. Specifically, RRG achieved significant performance improvements, with increases of up to 28% on EM, 13% on BLEU, and 6.8% on CodeBLEU.
Key facts. Cited by 10 papers in the map (data through 7 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 56 of its 66 references that are in the map. First posted on arXiv 24 Sep 2024.
Builds on
56 of 66 references.
Closest ancestors · 2
Same direction, newest first
- 2024EVOR: Evolving Retrieval for Code Generation19 Feb
- 2021Retrieval Augmented Code Generation and Summarization26 Aug
Other references · 54
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
- 2017Proximal Policy Optimization Algorithmscited by 14,441
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,383
- 2024Gemini 1.5: Unlocking multimodal understanding across millions of tokens of contextcited by 3,175
- 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,126
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,800
- 2021Improving language models by retrieving from trillions of tokenscited by 1,278
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
38 more
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023REPLUG: Retrieval-Augmented Black-Box Language Modelscited by 786
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
- 2023Active Retrieval Augmented Generationcited by 506
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
- 2023RRHF: Rank Responses to Align Language Models with Human Feedback without tearscited by 454
- 2022Large Language Models Struggle to Learn Long-Tail Knowledgecited by 452
- 2022A Systematic Evaluation of Large Language Models of Codecited by 360
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2024LLMLingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compressioncited by 343
- 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
- 2023Preference Ranking Optimization for Human Alignmentcited by 283
- 2023LLMLingua: Compressing Prompts for Accelerated Inference of Large Language Modelscited by 279
- 2024CodeAgent: Enhancing Code Generation with Tool-Integrated Agent Systems for Real-World Repo-level Coding Challengescited by 278
- 2023RECOMP: Improving Retrieval-Augmented LMs with Compression and Selective Augmentationcited by 253
- 2023RA-DIT: Retrieval-Augmented Dual Instruction Tuningcited by 194
- 2024Corrective Retrieval Augmented Generationcited by 187
- 2023Planning with Large Language Models for Code Generationcited by 179
- 2023SantaCoder: don't reach for the stars!cited by 169
- 2022DocPrompting: Generating Code by Retrieving the Docscited by 151
- 2023WebGLM: Towards An Efficient Web-Enhanced Question Answering System with Human Preferencescited by 100
- 2022Less is More: Task-aware Layer-wise Distillation for Language Model Compressioncited by 91
- 2022Coder Reviewer Reranking for Code Generationcited by 83
- 2023MindMap: Knowledge Graph Prompting Sparks Graph of Thoughts in Large Language Modelscited by 73
- 2023PanGu-Coder2: Boosting Large Language Models for Code with Ranking Feedbackcited by 69
- 2024Bridging the Preference Gap between Retrievers and LLMscited by 69
- 2023Shall We Pretrain Autoregressive Language Models with Retrieval? A Comprehensive Studycited by 63
- 2023Unlocking Context Constraints of LLMs: Enhancing Context Efficiency of LLMs with Self-Information-Based Content Filteringcited by 62
- 2022When Language Model Meets Private Librarycited by 54
- 2023InstructRetro: Instruction Tuning post Retrieval-Augmented Pretrainingcited by 53
- 2023Large Language Model-Aware In-Context Learning for Code Generationcited by 42
- 2022Nonparametric Masked Language Modelingcited by 39
- 2023PRCA: Fitting Black-Box Large Language Models for Retrieval Question Answering via Pluggable Reward-Driven Contextual Adaptercited by 38
- 2023ToolCoder: Teach Code Generation Models to use API search toolscited by 37
- 2024LTGC: Long-tail Recognition via Leveraging LLMs-driven Generated Contentcited by 33
- 2024AST-T5: Structure-Aware Pretraining for Code Generation and Understandingcited by 32
- 2024REPOFUSE: Repository-Level Code Completion with Fused Dual Contextcited by 32
50 most cited of 54 All 54 (JSON)
Built on by
Citing papers per year: 2025: 8; 2026: 2.
10 papers.
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 20
- 2026In Line with Context: Repository-Level Code Generation via Context Inliningcited by 18
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injectioncited by 15
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generationcited by 9
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generationcited by 3
- 2025Understanding and Bridging the Planner-Coder Gap: A Systematic Study on the Robustness of Multi-Agent Systems for Code Generationcited by 3
- 2025Isolating Language-Coding from Problem-Solving: Benchmarking LLMs with PseudoEvalcited by 2
- 2025Exploring the Security Threats of Retriever Backdoors in Retrieval-Augmented Code Generationcited by 1
- 2026Beyond Relevance: Utility-Centric Retrieval in the LLM Eracited by 0
- 2026Beyond Relevance: Utility-Centric Retrieval in the LLM Era10 Apr 2026
- 2026In Line with Context: Repository-Level Code Generation via Context Inlining1 Jan 2026
- 2025Exploring the Security Threats of Retriever Backdoors in Retrieval-Augmented Code Generation25 Dec 2025
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
- 2025Understanding and Bridging the Planner-Coder Gap: A Systematic Study on the Robustness of Multi-Agent Systems for Code Generation12 Oct 2025
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generation4 Jun 2025
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injection23 Apr 2025
- 2025Isolating Language-Coding from Problem-Solving: Benchmarking LLMs with PseudoEval26 Feb 2025
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generation5 Feb 2025
Similar, not cited
Close in wording, no citation either way
- 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2025SACL: Understanding and Combating Textual Bias in Code Retrieval with Semantic-Augmented Reranking and Localization
- 2026Context-Augmented Code Generation Using Programming Knowledge Graphs
- 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generation
- 2024Context-Augmented Code Generation Using Programming Knowledge Graphs