Repository-level code generation has attracted growing attention in recent years. Unlike function-level code generation, it requires the model to understand the entire repository, reasoning over complex dependencies across functions, classes, and modules. However, existing approaches such as retrieval-augmented generation (RAG) or context-based function selection often fall short: they primarily rely on surface-level similarity and struggle to capture the rich dependencies that govern repository-level semantics. In this paper, we introduce InlineCoder, a novel framework for repository-level code generation. InlineCoder enhances the understanding of repository context by inlining the unfinished function into its call graph, thereby reframing the challenging repository understanding as an easier function-level coding task. Given a function signature, InlineCoder first generates a draft completion, termed an anchor, which approximates downstream dependencies and enables perplexity-based confidence estimation. This anchor drives a bidirectional inlining process: (i) Upstream Inlining, which embeds the anchor into its callers to capture diverse usage scenarios; and (ii) Downstream Retrieval, which integrates the anchor's callees into the prompt to provide precise dependency context. The enriched context, combining draft completion with upstream and downstream perspectives, equips the LLM with a comprehensive repository view.


翻译:近年来,仓库级代码生成日益受到关注。与函数级代码生成不同,它要求模型理解整个代码仓库,并推理函数、类和模块之间复杂的依赖关系。然而,现有方法如检索增强生成(RAG)或基于上下文的函数选择往往存在不足:它们主要依赖表层相似性,难以捕捉决定仓库级语义的丰富依赖关系。本文提出InlineCoder,一个用于仓库级代码生成的新型框架。InlineCoder通过将未完成的函数内联到其调用图中,从而将具有挑战性的仓库理解问题重构为更简单的函数级编码任务,以此增强对仓库上下文的理解。给定函数签名,InlineCoder首先生成一个草稿补全,称为锚点,该锚点近似下游依赖关系并支持基于困惑度的置信度估计。该锚点驱动一个双向内联过程:(i)上游内联,将锚点嵌入其调用者中以捕捉多样化的使用场景;(ii)下游检索,将锚点的被调用者集成到提示中,以提供精确的依赖上下文。结合了草稿补全以及上游和下游视角的丰富上下文,为大型语言模型提供了全面的仓库视图。

0
下载
关闭预览

相关内容

通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
《大型语言模型代码生成》综述
专知会员服务
68+阅读 · 2024年6月4日
《大型语言模型中基于检索的文本生成》综述
专知会员服务
59+阅读 · 2024年4月18日
【文本生成现代方法】Modern Methods for Text Generation
专知会员服务
44+阅读 · 2020年9月11日
强化学习与文本生成
微信AI
41+阅读 · 2019年4月4日
基于深度学习的文本生成【附217页PPT下载】
专知
35+阅读 · 2018年11月24日
深度学习文本分类方法综述(代码)
中国人工智能学会
28+阅读 · 2018年6月16日
论文报告 | Graph-based Neural Multi-Document Summarization
科技创新与创业
15+阅读 · 2017年12月15日
TextInfoExp:自然语言处理相关实验(基于sougou数据集)
全球人工智能
12+阅读 · 2017年11月12日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
VIP会员
相关资讯
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员