Hierarchical Embedding Fusion for Retrieval-Augmented Code Generation
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
Retrieval-augmented code generation often conditions the decoder on large retrieved code snippets. This ties online inference cost to repository size and introduces noise from long contexts. We present Hierarchical Embedding Fusion (HEF), a two-stage approach to repository representation for code completion. First, an offline cache compresses repository chunks into a reusable hierarchy of dense vectors using a small fuser model. Second, an online interface maps a small number of retrieved vectors into learned pseudo-tokens that are consumed by the code generator. This replaces thousands of retrieved tokens with a fixed pseudo-token budget while preserving access to repository-level information. On RepoBench and RepoEval, HEF with a 1.8B-parameter pipeline achieves exact-match accuracy comparable to snippet-based retrieval baselines, while operating at sub-second median latency on a single A100 GPU. Compared to graph-based and iterative retrieval systems in our experimental setup, HEF reduces median end-to-end latency by 13 to 26 times. We also introduce a utility-weighted likelihood signal for filtering training contexts and report ablation studies on pseudo-token budget, embedding models, and robustness to harmful retrieval. Overall, these results indicate that hierarchical dense caching is an effective mechanism for low-latency, repository-aware code completion.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 22 of its 26 references that are in the map. First posted on arXiv 4 Feb 2026.
Builds on
22 of 26 references.
Closest ancestors · 4
Same direction, newest first
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?20 Jun
- 2024GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Model11 Jun
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completion15 Mar
- 2021Retrieval Augmented Code Generation and Summarization26 Aug
Other references · 18
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,297
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,170
- 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,915
- 2020Dense Passage Retrieval for Open-Domain Question Answeringcited by 3,824
- 2021The Power of Scale for Parameter-Efficient Prompt Tuningcited by 3,795
- 2020Longformer: The Long-Document Transformercited by 3,413
- 2021SimCSE: Simple Contrastive Learning of Sentence Embeddingscited by 2,173
- 2020REALM: Retrieval-Augmented Language Model Pre-Trainingcited by 2,141
- 2019Transformer-XL: Attentive Language Models Beyond a Fixed-Length Contextcited by 1,850
- 2020Big Bird: Transformers for Longer Sequencescited by 1,684
- 2019Compressive Transformers for Long-Range Sequence Modellingcited by 726
- 2021P-Tuning v2: Prompt Tuning Can Be Comparable to Fine-tuning Universally Across Scales and Taskscited by 689
6 more
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
- 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
- 2023RepoFusion: Training Code Models to Understand Your Repositorycited by 40
- 2024Dataflow-Guided Retrieval Augmentation for Repository-Level Code Completioncited by 40
- 2025Cramming 1568 Tokens into a Single Vector and Back Again: Exploring the Limits of Embedding Space Capacitycited by 28
- 2024ICLERB: In-Context Learning Embedding and Reranker Benchmarkcited by 1
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2025SaraCoder: Orchestrating Semantic and Structural Cues for Resource-Optimized Repository-Level Code Completion
- 2025GRACE: Graph-Guided Repository-Aware Code Completion through Hierarchical Code Fusion
- 2024Retrieval-augmented code completion for local projects using large language models
- 2025Practical Code RAG at Scale: Task-Aware Retrieval Design Choices under Compute Budgets
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches
- 2026Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation
- 2026Do Not Treat Code as Natural Language: Implications for Repository-Level Code Generation and Beyond
- 2025Impact-driven Context Filtering For Cross-file Code Completion