Repository-level code generation with Large Language Models (LLMs) remains challenging, primarily due to complex dependencies and limited context windows. Recent approaches adopt retrieval-augmented generation (RAG) and the planning mechanism to reuse potential callee functions in the repository. However, these approaches often suffer from two limitations: lack of test-driven behavioral guidance during planning and overlooking the implementation logic embedded in repository code during reuse. As a result, generated plans may not align with expected behaviors, and retrieved functions may not be effectively reused. In this paper, we propose TICoder, a novel repository-level code generation framework that improves both planning and reuse. TICoder introduces a test-driven iterative planning mechanism that leverages test cases as behavioral specifications to refine implementation steps. Furthermore, TICoder employs an implementation-aware code reuse strategy, which retrieves potential callee functions using a dual-view similarity that captures both functional and implementation aspects. We then identify relevant usage patterns through a dual-stage selection strategy, combining structure-based clustering and perplexity-based filtering. We conduct extensive experiments on widely used repository-level code generation benchmarks with various LLMs. Experimental results demonstrate that TICoder outperforms state-of-the-art (SOTA) methods, achieving an average improvement of 11.52%.


翻译:大型语言模型在仓库级代码生成任务中仍面临挑战,主要源于复杂依赖关系与有限上下文窗口的限制。现有方法采用检索增强生成与规划机制复用仓库中的潜在被调用函数,但存在两大局限:规划阶段缺乏测试驱动的行为引导,以及复用过程中忽视仓库代码的实现逻辑。这导致生成的规划可能与预期行为不符,且检索到的函数难以有效复用。本文提出TICoder——一种新型仓库级代码生成框架,从规划与复用两个维度进行优化。该框架引入测试驱动迭代规划机制,利用测试用例作为行为规范优化实施方案;同时采用实现感知代码复用策略,通过融合功能相似性与实现相似性的双视角检索获取候选被调用函数,并基于结构聚类与困惑度过滤的两阶段选择策略识别相关使用模式。我们在主流仓库级代码生成基准上使用多种大语言模型进行广泛实验,结果表明TICoder性能优于现有最先进方法,平均提升幅度达11.52%。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
博士论文 | 用代码结构感知方法推进代码大模型
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
30+阅读 · 2025年1月1日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
基于大语言模型的复杂任务自主规划处理框架
专知会员服务
103+阅读 · 2024年4月12日
一个牛逼的 Python 调试工具
机器学习算法与Python学习
15+阅读 · 2019年4月30日
Forge:如何管理你的机器学习实验
专知
11+阅读 · 2018年12月1日
深度学习时代的目标检测算法
炼数成金订阅号
40+阅读 · 2018年3月19日
推荐|上交大推出Texygen:文本生成模型的基准测试平台
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
13+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 5月18日
VIP会员
最新内容
《无人机脆弱性利用:网络空间力量的新域》
专知会员服务
2+阅读 · 8月1日
美空军如何将人工智能从战场部署至后方机关
专知会员服务
11+阅读 · 7月31日
《史诗怒火行动:多域前瞻评估》49页报告
专知会员服务
7+阅读 · 7月31日
《英国防部:未来空战系统数字化战略》33页
专知会员服务
5+阅读 · 7月31日
《面向自主飞行网络的智能体人工智能架构》
专知会员服务
7+阅读 · 7月31日
“史诗怒火”行动:现代多域作战的重要节点
专知会员服务
8+阅读 · 7月30日
《下一代无线网络中的多无人机通信资源管理》
相关基金
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
13+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员