The growing capabilities of Large Language Models (LLMs) have led to their widespread adoption for function completion within code repositories. Recent studies on such tasks show promising results when explicit instructions, often in the form of docstrings, are available to guide the completion. However, in real-world scenarios, clear docstrings are frequently absent. Under such conditions, LLMs typically fail to produce accurate completions. To enable more automated and accurate function completion in such settings, we aim to enable LLMs to accurately infer the developer's intent prior to code completion. Our key insight is that the preceding code, namely the code context before the function to be completed, often contains valuable cues that help the model understand the intended functionality. However, inferring intent from such implicit context is non-trivial and constitutes a core challenge in function-level code completion. To tackle this challenge, inspired by how humans interpret context, we propose a reasoning-based prompting framework that guides LLMs to utilize these contextual cues to infer intent step by step. To incentivize LLMs to reason through the preceding code and infer intent, we further curate a dataset of 40k examples, each annotated with intermediate reasoning traces and corresponding docstrings. Extensive experiments on DevEval and ComplexCodeEval demonstrate consistent performance improvements across multiple models, achieving over 25% relative gains in pass@1 for both DeepSeekCoder and CodeLLaMA families. Building upon our framework, we further develop an intent-interactive platform that supports lightweight human feedback. This platform allows developers to select from a set of candidate intentions or edit the intent to better guide the model. Our experiments show that this interactive approach leads to further performance improvements.


翻译:大型语言模型(LLMs)能力的不断增强使其在代码仓库中广泛用于函数补全。近期针对此类任务的研究表明,当存在明确的指令(通常以文档字符串形式)指导补全时,能获得令人满意的结果。然而在实际场景中,清晰的文档字符串往往缺失。在此类条件下,LLMs通常无法生成准确的补全。为在缺乏文档字符串的环境中实现更自动化和准确的函数补全,我们旨在使LLMs在代码补全前准确推断开发者的意图。我们的核心观点是:待补全函数之前的代码(即代码上下文)通常包含有价值线索,有助于模型理解预期功能。但从这种隐式上下文中推断意图并非易事,这构成了函数级代码补全的核心挑战。为应对该挑战,受人类理解上下文方式的启发,我们提出了一种基于推理的提示框架,引导LLMs逐步利用这些上下文线索推断意图。为激励LLMs通过前置代码进行推理并推断意图,我们进一步构建了包含4万个示例的数据集,每个示例均标注了中间推理轨迹及对应文档字符串。在DevEval和ComplexCodeEval上的大量实验表明,多个模型在性能上取得一致性提升,其中DeepSeekCoder和CodeLLaMA系列模型的pass@1指标相对提升超过25%。基于该框架,我们进一步开发了支持轻量级人类反馈的意图交互平台。该平台允许开发者从一组候选意图中选择或编辑意图以更好地引导模型。实验表明,这种交互式方法可带来进一步的性能提升。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
通过逻辑推理赋能大语言模型:综述
专知会员服务
32+阅读 · 2025年2月24日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
大型语言模型高效推理综述
专知会员服务
64+阅读 · 2024年4月23日
深度学习文本分类方法综述(代码)
中国人工智能学会
28+阅读 · 2018年6月16日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
Instruction Tuning for Large Language Models: A Survey
Arxiv
15+阅读 · 2023年8月21日
VIP会员
最新内容
无人机自主控制与人工智能:系统性综述
专知会员服务
1+阅读 · 10分钟前
巡飞弹与反无人机系统——现代战场的两大支柱
专知会员服务
1+阅读 · 41分钟前
《打造“黄金舰队”》57页报告
专知会员服务
0+阅读 · 43分钟前
《北约数字教官网络发展路径》128页报告
专知会员服务
1+阅读 · 今天6:33
ECCV 2026 | MIMFlow:MIM与归一化流统一图像生成
专知会员服务
6+阅读 · 6月25日
网状网络及其在军事领域的运用
专知会员服务
7+阅读 · 6月25日
无美国参与的欧洲战争方式(万字长文)
专知会员服务
8+阅读 · 6月25日
《国防领域敏感性分析白皮书》
专知会员服务
8+阅读 · 6月25日
综述 | 从问答到任务完成:Agent系统与Harness设计
Agentic RL:框架、实践与长程智能体训练
专知会员服务
10+阅读 · 6月24日
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
Top
微信扫码咨询专知VIP会员