更好的上下文造就更好的代码语言模型:函数调用参数补全案例研究
Better Context Makes Better Code Language Models: A Case Study on Function Call Argument Completion
AI总结:
本文构建含完整项目与依赖的 Python 数据集,研究函数调用参数补全,并利用程序分析器提供函数实现和用法等非局部上下文,显著提升代码模型性能。
摘要:
预训练代码语言模型已推动程序综合取得巨大进展。然而,常见方法仅考虑文件内局部上下文,因此会遗漏代码库其他部分及其外部依赖所施加的信息和约束。现有代码补全基准也缺乏此类上下文。为消除这些限制,我们整理了一个采用宽松许可的 Python 包新数据集,其中包含完整项目及其依赖,并提供借助程序分析器提取非局部信息的工具。随后,我们聚焦于函数调用参数补全任务,该任务要求预测函数调用的参数。我们表明,现有代码补全模型在我们的补全任务上无法取得良好结果。为更好地解决该任务,我们向程序分析器查询与给定函数调用相关的信息,并研究在推理和训练期间将分析器结果提供给不同代码补全模型的方式。实验表明,让模型访问函数实现和函数用法可显著提升参数补全性能。我们的消融研究进一步揭示了程序分析器提供的不同类型信息,以及纳入这些信息的不同方式如何影响模型性能。
英文摘要:
Pretrained code language models have enabled great progress towards program synthesis. However, common approaches only consider in-file local context and thus miss information and constraints imposed by other parts of the codebase and its external dependencies. Existing code completion benchmarks also lack such context. To resolve these restrictions we curate a new dataset of permissively licensed Python packages that includes full projects and their dependencies and provide tools to extract non-local information with the help of program analyzers. We then focus on the task of function call argument completion which requires predicting the arguments to function calls. We show that existing code completion models do not yield good results on our completion task. To better solve this task, we query a program analyzer for information relevant to a given function call, and consider ways to provide the analyzer results to different code completion models during inference and training. Our experiments show that providing access to the function implementation and function usages greatly improves the argument completion performance. Our ablation study provides further insights on how different types of information available from the program analyzer and different ways of incorporating the information affect the model performance.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。