mlsanityData to 7 Oct 2026

Preference-Guided Refactored Tuning for Retrieval Augmented Code Generation

arXiv 2409.15895 ↗First posted 24 Sep 2024cs.SEcited by 10

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

  1. 2024EVOR: Evolving Retrieval for Code Generation19 Feb
  2. 2021Retrieval Augmented Code Generation and Summarization26 Aug

Other references · 54

  1. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  2. 2020Language Models are Few-Shot Learnerscited by 32,199
  3. 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
  4. 2017Proximal Policy Optimization Algorithmscited by 14,441
  5. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  6. 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,383
  7. 2024Gemini 1.5: Unlocking multimodal understanding across millions of tokens of contextcited by 3,175
  8. 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,126
  9. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  10. 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,800
  11. 2021Improving language models by retrieving from trillions of tokenscited by 1,278
  12. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
38 more
  1. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
  2. 2023REPLUG: Retrieval-Augmented Black-Box Language Modelscited by 786
  3. 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
  4. 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
  5. 2023Active Retrieval Augmented Generationcited by 506
  6. 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
  7. 2023RRHF: Rank Responses to Align Language Models with Human Feedback without tearscited by 454
  8. 2022Large Language Models Struggle to Learn Long-Tail Knowledgecited by 452
  9. 2022A Systematic Evaluation of Large Language Models of Codecited by 360
  10. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
  11. 2024LLMLingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compressioncited by 343
  12. 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
  13. 2023Preference Ranking Optimization for Human Alignmentcited by 283
  14. 2023LLMLingua: Compressing Prompts for Accelerated Inference of Large Language Modelscited by 279
  15. 2024CodeAgent: Enhancing Code Generation with Tool-Integrated Agent Systems for Real-World Repo-level Coding Challengescited by 278
  16. 2023RECOMP: Improving Retrieval-Augmented LMs with Compression and Selective Augmentationcited by 253
  17. 2023RA-DIT: Retrieval-Augmented Dual Instruction Tuningcited by 194
  18. 2024Corrective Retrieval Augmented Generationcited by 187
  19. 2023Planning with Large Language Models for Code Generationcited by 179
  20. 2023SantaCoder: don't reach for the stars!cited by 169
  21. 2022DocPrompting: Generating Code by Retrieving the Docscited by 151
  22. 2023WebGLM: Towards An Efficient Web-Enhanced Question Answering System with Human Preferencescited by 100
  23. 2022Less is More: Task-aware Layer-wise Distillation for Language Model Compressioncited by 91
  24. 2022Coder Reviewer Reranking for Code Generationcited by 83
  25. 2023MindMap: Knowledge Graph Prompting Sparks Graph of Thoughts in Large Language Modelscited by 73
  26. 2023PanGu-Coder2: Boosting Large Language Models for Code with Ranking Feedbackcited by 69
  27. 2024Bridging the Preference Gap between Retrievers and LLMscited by 69
  28. 2023Shall We Pretrain Autoregressive Language Models with Retrieval? A Comprehensive Studycited by 63
  29. 2023Unlocking Context Constraints of LLMs: Enhancing Context Efficiency of LLMs with Self-Information-Based Content Filteringcited by 62
  30. 2022When Language Model Meets Private Librarycited by 54
  31. 2023InstructRetro: Instruction Tuning post Retrieval-Augmented Pretrainingcited by 53
  32. 2023Large Language Model-Aware In-Context Learning for Code Generationcited by 42
  33. 2022Nonparametric Masked Language Modelingcited by 39
  34. 2023PRCA: Fitting Black-Box Large Language Models for Retrieval Question Answering via Pluggable Reward-Driven Contextual Adaptercited by 38
  35. 2023ToolCoder: Teach Code Generation Models to use API search toolscited by 37
  36. 2024LTGC: Long-tail Recognition via Leveraging LLMs-driven Generated Contentcited by 33
  37. 2024AST-T5: Structure-Aware Pretraining for Code Generation and Understandingcited by 32
  38. 2024REPOFUSE: Repository-Level Code Completion with Fused Dual Contextcited by 32

50 most cited of 54 All 54 (JSON)

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 8; 2026: 2.

10 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities
  2. 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond
  3. 2024Repoformer: Selective Retrieval for Repository-Level Code Completion
  4. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
  5. 2025SACL: Understanding and Combating Textual Bias in Code Retrieval with Semantic-Augmented Reranking and Localization
  6. 2026Context-Augmented Code Generation Using Programming Knowledge Graphs
  7. 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generation
  8. 2024Context-Augmented Code Generation Using Programming Knowledge Graphs