Building A Coding Assistant via the Retrieval-Augmented Language Model
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
Pretrained language models have shown strong effectiveness in code-related tasks, such as code retrieval, code generation, code summarization, and code completion tasks. In this paper, we propose COde assistaNt viA retrieval-augmeNted language model (CONAN), which aims to build a code assistant by mimicking the knowledge-seeking behaviors of humans during coding. Specifically, it consists of a code structure aware retriever (CONAN-R) and a dual-view code representation-based retrieval-augmented generation model (CONAN-G). CONAN-R pretrains CodeT5 using Code-Documentation Alignment and Masked Entity Prediction tasks to make language models code structure-aware and learn effective representations for code snippets and documentation. Then CONAN-G designs a dual-view code representation mechanism for implementing a retrieval-augmented code generation model. CONAN-G regards the code documentation descriptions as prompts, which help language models better understand the code semantics. Our experiments show that CONAN achieves convincing performance on different code generation tasks and significantly outperforms previous retrieval augmented code generation models. Our further analyses show that CONAN learns tailored representations for both code snippets and documentation by aligning code-documentation data pairs and capturing structural semantics by masking and predicting entities in the code data. Additionally, the retrieved code snippets and documentation provide necessary information from both program language and natural language to assist the code generation process. CONAN can also be used as an assistant for Large Language Models (LLMs), providing LLMs with external knowledge in shorter code document lengths to improve their effectiveness on various code tasks. It shows the ability of CONAN to extract necessary information and help filter out the noise from retrieved code documents.
Key facts. Cited by 5 papers in the map (data through 7 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 52 of its 78 references that are in the map. First posted on arXiv 21 Oct 2024.
Builds on
52 of 78 references.
Closest ancestors · 4
Same direction, newest first
- 2023Retrieval-Augmented Code Generation for Universal Information Extraction6 Nov
- 2022ReACC: A Retrieval-Augmented Code Completion Framework15 Mar
- 2021Retrieval Augmented Code Generation and Summarization26 Aug
- 2020Retrieval-Augmented Generation for Code Summarization via Hybrid GNN9 Jun
Other references · 48
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,266
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,049
- 2020Dense Passage Retrieval for Open-Domain Question Answeringcited by 3,779
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2020Exploring Simple Siamese Representation Learningcited by 2,853
- 2017Billion-scale similarity search with GPUscited by 2,477
- 2019HuggingFace's Transformers: State-of-the-art Natural Language Processingcited by 2,201
- 2021SimCSE: Simple Contrastive Learning of Sentence Embeddingscited by 2,168
36 more
- 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,126
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2020Leveraging Passage Retrieval with Generative Models for Open Domain Question Answeringcited by 1,203
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
- 2015Effective Approaches to Attention-based Neural Machine Translationcited by 1,024
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2020Approximate Nearest Neighbor Negative Contrastive Learning for Dense Text Retrievalcited by 846
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
- 2019ERNIE: Enhanced Language Representation with Informative Entitiescited by 525
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
- 2021Unified Pre-training for Program Understanding and Generationcited by 361
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
- 2019Representation Degeneration Problem in Training Natural Language Generation Modelscited by 250
- 2021ConSERT: A Contrastive Framework for Self-Supervised Sentence Representation Transfercited by 231
- 2020Sparse, Dense, and Attentional Representations for Text Retrievalcited by 213
- 2020CLEAR: Contrastive Learning for Sentence Representationcited by 186
- 2020CERT: Contrastive Self-supervised Learning for Language Understandingcited by 169
- 2021Condenser: a Pre-training Architecture for Dense Retrievalcited by 162
- 2020Answering Complex Open-Domain Questions with Multi-Hop Dense Retrievalcited by 160
- 2022DocPrompting: Generating Code by Retrieving the Docscited by 151
- 2021Simple Entity-Centric Questions Challenge Dense Retrieverscited by 140
- 2021COCO-LM: Correcting and Contrasting Text Sequences for Language Model Pretrainingcited by 126
- 2018Mapping Language to Code in Programmatic Contextcited by 104
- 2022CERT: Continual Pre-Training on Sketches for Library-Oriented Code Generationcited by 87
- 2020Coreferential Reasoning Learning for Language Representationcited by 80
- 2021Few-Shot Conversational Dense Retrievalcited by 71
- 2021DOBF: A Deobfuscation Pre-Training Objective for Programming Languagescited by 68
- 2022Universal Vision-Language Dense Retrieval: Learning A Unified Representation Space for Multi-Modal Retrievalcited by 57
- 2023SkCoder: A Sketch-based Approach for Automatic Code Generationcited by 40
- 2023RepoFusion: Training Code Models to Understand Your Repositorycited by 40
- 2023Structure-Aware Language Model Pretraining Improves Dense Retrieval on Structured Datacited by 23
- 2022CodeRetriever: Unimodal and Bimodal Contrastive Learning for Code Searchcited by 21
- 2021More Robust Dense Retrieval with Contrastive Dual Learningcited by 15
Built on by
Citing papers per year: 2025: 3; 2026: 2.
5 papers.
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 20
- 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generationcited by 3
- 2026HCAG: Hierarchical Abstraction and Retrieval-Augmented Generation on Theoretical Repositories with LLMscited by 1
- 2025DeepCodeSeek: Real-Time API Retrieval for Context-Aware Code Generationcited by 0
- 2026The Laws of Context Allocation: Causal Measurement and Closed-Loop Orchestration in Generative Searchcited by 0
- 2026The Laws of Context Allocation: Causal Measurement and Closed-Loop Orchestration in Generative Search24 Aug 2026
- 2026HCAG: Hierarchical Abstraction and Retrieval-Augmented Generation on Theoretical Repositories with LLMs19 Mar 2026
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025DeepCodeSeek: Real-Time API Retrieval for Context-Aware Code Generation30 Sep 2025
- 2025Across Programming Language Silos: A Study on Cross-Lingual Retrieval-augmented Code Generation4 Jun 2025
Similar, not cited
Close in wording, no citation either way
- 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities
- 2025SACL: Understanding and Combating Textual Bias in Code Retrieval with Semantic-Augmented Reranking and Localization
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyond
- 2026Retrieval-Augmented Generation for Scientific Code Understanding
- 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generation
- 2026Context-Augmented Code Generation Using Programming Knowledge Graphs
- 2024Context-Augmented Code Generation Using Programming Knowledge Graphs
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?