Automatically generating source code from natural language descriptions has been a growing field of research in recent years. However, current large-scale code generation models often encounter difficulties when selecting appropriate APIs for specific contexts. These models may generate APIs that do not meet requirements or refer to non-existent APIs in third-party libraries, especially for lesser-known or private libraries. Inspired by the process of human developers using tools to search APIs, we propose ToolCoder, a novel approach that integrates API search tools with existing models to assist in code generation and API selection. To teach our model to use tools, we introduce an automated data annotation method using ChatGPT to add tool usage information into the source code data and fine-tune code generation models. During inference, we integrate API search tools into the generation process so that our model can automatically use the search tool to get suggestions when selecting an API. Our experimental results demonstrate that ToolCoder exhibits excellent performance and generalization across five public and private library code generation benchmarks, with at least 6.21\% improvement on average pass@1 metrics and 9.64\% improvement on average pass@10 metrics compared to state-of-the-art methods. Furthermore, we show that our relatively small ToolCoder model is comparable to one of the current best models, GPT-3.5, highlighting the potential of incorporating programming tools into the code generation process.


翻译:近年来,从自然语言描述中自动生成源代码已成为一个不断发展的研究领域。然而,当前大规模代码生成模型在为特定上下文选择合适API时常常遇到困难。这些模型可能生成不符合需求的API,或引用第三方库中不存在的API,尤其是对于较不为人知或私有库而言。受人类开发者使用工具搜索API过程的启发,我们提出了ToolCoder——一种将API搜索工具与现有模型相结合的新方法,以辅助代码生成和API选择。为教会模型使用工具,我们引入了一种自动化数据标注方法,利用ChatGPT向源代码数据添加工具使用信息,并微调代码生成模型。在推理过程中,我们将API搜索工具集成到生成流程中,使模型在选定API时能够自动使用搜索工具获取建议。实验结果表明,ToolCoder在五个公共和私有库代码生成基准测试中展现出卓越的性能和泛化能力,与最先进方法相比,平均pass@1指标提升至少6.21%,平均pass@10指标提升至少9.64%。此外,我们展示了相对较小的ToolCoder模型可与当前最佳模型之一GPT-3.5相媲美,凸显了将编程工具融入代码生成过程的潜力。

0
下载
关闭预览

相关内容

这个新版本的工具会议系列恢复了从1989年到2012年的50个会议的传统。工具最初是“面向对象语言和系统的技术”,后来发展到包括软件技术的所有创新方面。今天许多最重要的软件概念都是在这里首次引入的。2019年TOOLS 50+1在俄罗斯喀山附近举行,以同样的创新精神、对所有与软件相关的事物的热情、科学稳健性和行业适用性的结合以及欢迎该领域所有趋势和社区的开放态度,延续了该系列。 官网链接:http://tools2019.innopolis.ru/
【2023新书】使用Python进行统计和数据可视化,554页pdf
专知会员服务
130+阅读 · 2023年1月29日
专知会员服务
46+阅读 · 2020年10月31日
Linux导论,Introduction to Linux,96页ppt
专知会员服务
82+阅读 · 2020年7月26日
[综述]深度学习下的场景文本检测与识别
专知会员服务
78+阅读 · 2019年10月10日
机器学习入门的经验与建议
专知会员服务
94+阅读 · 2019年10月10日
【SIGGRAPH2019】TensorFlow 2.0深度学习计算机图形学应用
专知会员服务
41+阅读 · 2019年10月9日
Transferring Knowledge across Learning Processes
CreateAMind
29+阅读 · 2019年5月18日
强化学习的Unsupervised Meta-Learning
CreateAMind
18+阅读 · 2019年1月7日
无监督元学习表示学习
CreateAMind
27+阅读 · 2019年1月4日
Unsupervised Learning via Meta-Learning
CreateAMind
44+阅读 · 2019年1月3日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
18+阅读 · 2018年12月24日
【推荐】RNN/LSTM时序预测
机器学习研究会
25+阅读 · 2017年9月8日
【推荐】GAN架构入门综述(资源汇总)
机器学习研究会
10+阅读 · 2017年9月3日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
1+阅读 · 2008年12月31日
Arxiv
0+阅读 · 2023年6月27日
Arxiv
0+阅读 · 2023年6月21日
VIP会员
最新内容
《基于深度强化学习的反无人机技术研究》178页
“史诗怒火”行动与“AI中心战”模式的浮现
专知会员服务
3+阅读 · 6月10日
【CVPR2026教程】扩散模型的解析理解
专知会员服务
0+阅读 · 6月10日
马赛克战:俄乌战场透析
专知会员服务
13+阅读 · 6月10日
《利用人工智能增强军事决策》
专知会员服务
5+阅读 · 6月10日
《自动机器学习在军事数据耕耘法中的应用》
专知会员服务
7+阅读 · 6月10日
为何指挥所生存能力要求范式转变
专知会员服务
5+阅读 · 6月10日
打造“新蛛网”模式与高科技动员
专知会员服务
4+阅读 · 6月10日
“蛛网”行动一周年:远程无人机战争
专知会员服务
3+阅读 · 6月10日
【剑桥博士论文】智能体-环境协同优化
专知会员服务
7+阅读 · 6月9日
相关资讯
Transferring Knowledge across Learning Processes
CreateAMind
29+阅读 · 2019年5月18日
强化学习的Unsupervised Meta-Learning
CreateAMind
18+阅读 · 2019年1月7日
无监督元学习表示学习
CreateAMind
27+阅读 · 2019年1月4日
Unsupervised Learning via Meta-Learning
CreateAMind
44+阅读 · 2019年1月3日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
18+阅读 · 2018年12月24日
【推荐】RNN/LSTM时序预测
机器学习研究会
25+阅读 · 2017年9月8日
【推荐】GAN架构入门综述(资源汇总)
机器学习研究会
10+阅读 · 2017年9月3日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
1+阅读 · 2008年12月31日
Top
微信扫码咨询专知VIP会员