Hierarchical Embedding Fusion for Retrieval-Augmented Code Generation

Nikita Sorokin, Ivan Sedykh, Valentin Malykh
2/4/2026
cs.CLcs.LG
rag

No confident code implementation found for this paper.

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{sorokin2026hierarchical,
  title  = {Hierarchical Embedding Fusion for Retrieval-Augmented Code Generation},
  author = {Nikita Sorokin and Ivan Sedykh and Valentin Malykh},
  year   = {2026},
  eprint = {2603.06593},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2603.06593v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2603.06593.svg)](https://codeofpaper.com/paper/2603.06593)

Discussion