mlsanityData to 7 Oct 2026

Retrieval-augmented code completion for local projects using large language models

arXiv 2408.05026 ↗First posted 9 Aug 2024cs.SE cs.LGcited by 1

On the map: Retrieval-augmented generation → RAG for code

Abstract (arXiv)

The use of large language models (LLMs) is becoming increasingly widespread among software developers. However, privacy and computational requirements are problematic with commercial solutions and the use of LLMs. In this work, we focus on using relatively small and efficient LLMs with 160M parameters that are suitable for local execution and augmentation with retrieval from local projects. We train two open transformer-based models, the generative GPT-2 and the retrieval-adapted RETRO, on open-source Python files, and empirically compare them, confirming the benefits of embedding-based retrieval. Furthermore, we improve our models' performance with In-context retrieval-augmented generation (RAG), which retrieves code snippets using the Jaccard similarity of tokens. We evaluate In-context RAG on larger models and determine that, despite its simplicity, the approach is more suitable than using the RETRO architecture. Experimental results indicate that In-context RAG improves the code completion baseline by over 26%, while RETRO improves over the similarly sized GPT-2 baseline by 12%. We highlight the key role of proper tokenization in achieving the full potential of LLMs in code completion.

Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 43 of its 52 references that are in the map. First posted on arXiv 9 Aug 2024.

Builds on

43 of 52 references.

Closest ancestors · 3

Same direction, newest first

  1. 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar
  2. 2022ReACC: A Retrieval-Augmented Code Completion Framework15 Mar
  3. 2021Retrieval Augmented Code Generation and Summarization26 Aug

Other references · 40

  1. 2017Attention Is All You Needcited by 59,932
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  3. 2014Adam: A Method for Stochastic Optimizationcited by 36,960
  4. 2020Language Models are Few-Shot Learnerscited by 32,199
  5. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
  6. 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
  7. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  8. 2020Scaling Laws for Neural Language Modelscited by 6,411
  9. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
  10. 2020Dense Passage Retrieval for Open-Domain Question Answeringcited by 3,779
  11. 2021Program Synthesis with Large Language Modelscited by 3,509
  12. 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,898
28 more
  1. 2017Billion-scale similarity search with GPUscited by 2,477
  2. 2023G-Eval: NLG Evaluation using GPT-4 with Better Human Alignmentcited by 2,205
  3. 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,126
  4. 2020GLU Variants Improve Transformercited by 1,724
  5. 2022Fast Inference from Transformers via Speculative Decodingcited by 1,615
  6. 2021Improving language models by retrieving from trillions of tokenscited by 1,278
  7. 2020Leveraging Passage Retrieval with Generative Models for Open Domain Question Answeringcited by 1,203
  8. 2016Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphscited by 853
  9. 2023StarCoder: may the source be with you!cited by 790
  10. 2019Generalization through Memorization: Nearest Neighbor Language Modelscited by 788
  11. 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
  12. 2023In-Context Retrieval-Augmented Language Modelscited by 694
  13. 2021Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LMcited by 621
  14. 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
  15. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
  16. 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 346
  17. 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
  18. 2016Using the Output Embedding to Improve Language Modelscited by 266
  19. 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 181
  20. 2020Enabling Language Models to Fill in the Blankscited by 121
  21. 2022Repository-Level Prompt Generation for Large Language Models of Codecited by 106
  22. 2023A Large-Scale Survey on the Usability of AI Programming Assistants: Successes and Challengescited by 75
  23. 2022Out of the BLEU: how should we assess quality of the Code Generation models?cited by 65
  24. 2024Getting the most out of your tokenizer for pre-training and domain adaptationcited by 65
  25. 2023Shall We Pretrain Autoregressive Language Models with Retrieval? A Comprehensive Studycited by 63
  26. 2024Token Alignment via Character Matching for Subword Completioncited by 9
  27. 2024Context Composing for Full Line Code Completioncited by 4
  28. 2023Dynamic Retrieval-Augmented Generationcited by 1

Built on by

Cited by year

Citing papers per year: 2025: 1.

1 paper.

Similar, not cited

Close in wording, no citation either way

  1. 2025A Deep Dive into Retrieval-Augmented Generation for Code Completion: Experience on WeChat
  2. 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generation
  3. 2025SpareCodeSearch: Searching for Code Context When You Have No Spare GPU
  4. 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunities
  5. 2026Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
  6. 2024GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model
  7. 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
  8. 2024A Lightweight Framework for Adaptive Retrieval In Code Completion With Critique Model