arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2603.06593cs.CLcs.LG
收藏

层次嵌入融合用于检索增强的代码生成

Hierarchical Embedding Fusion for Retrieval-Augmented Code Generation

ITMO University(ITMO大学)

Nikita Sorokin, Ivan Sedykh, Valentin Malykh

AI总结:

HEF通过层次嵌入融合技术,实现了低延迟的仓库感知代码补全,有效减少检索延迟并提升准确度。

摘要:

检索增强的代码生成通常将解码器条件于大规模检索到的代码片段。这将在线推理成本与仓库大小联系起来,并引入了长上下文带来的噪声。我们提出了层次嵌入融合(HEF),一种用于仓库表示的两阶段方法用于代码补全。首先,一个离线缓存将仓库块压缩成可重用的密集向量层次结构,使用一个小的融合模型。其次,一个在线接口将少量检索到的向量映射为学习到的伪令牌,这些伪令牌被代码生成器所消耗。这在保持对仓库级信息访问的同时,用固定的伪令牌预算替代了数千个检索到的令牌。在RepoBench和RepoEval上,HEF与一个180亿参数的流水线实现的精确匹配准确度与基于片段的检索基线相当,同时在单个A100 GPU上运行时中位延迟低于秒。与我们在实验设置中的图基和迭代检索系统相比,HEF将中位端到端延迟减少了13到26倍。我们还引入了一个基于实用性的加权似然信号用于过滤训练上下文,并报告了关于伪令牌预算、嵌入模型以及对有害检索的鲁棒性的消融研究。总体而言,这些结果表明,层次密集缓存是低延迟、仓库感知代码补全的有效机制。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑