基于深度学习的代码推荐器在多大程度上通过从训练集中克隆代码来生成预测?
To What Extent do Deep Learning-based Code Recommenders Generate Predictions by Cloning Code from the Training Set?
摘要:
深度学习(DL)模型已被广泛用于支持代码完成。这些模型一旦被适当地训练,就可以将不完整的代码组件(例如,GitHub Copilot是通过在数百万个开源存储库上训练DL模型而构建的代码推荐器的示例:这些存储库的源代码充当训练数据,允许模型学习“如何编程”。这种代码的使用通常受自由和开放源码软件(FOSS)许可证的约束,该许可证规定了许可代码可以重新分发或修改的条件。到目前为止,还不清楚在开源代码上训练的DL模型生成的代码应该被视为“新”还是“衍生”工作,可能会对许可证侵权产生影响。在这项工作中,我们进行了一项大规模的研究,调查DL模型在推荐代码完成时倾向于从其训练集中克隆代码的程度。这样的探索性研究可以帮助评估前面提到的潜在许可问题的严重程度:如果这些模型倾向于生成在训练集中看不到的新代码,那么许可问题就不太可能发生。否则,这些许可证的修订将促使人们规范这些模型生成的代码在商业环境中使用时应如何处理。我们的结果显示,最先进的基于DL的代码完成工具生成的预测中,约有10%到0.1%是训练集中实例的Type-1克隆,具体取决于预测代码的大小。长期预测不太可能被复制。
英文摘要:
Deep Learning (DL) models have been widely used to support code completion. These models, once properly trained, can take as input an incomplete code component (e.g., an incomplete function) and predict the missing tokens to finalize it. GitHub Copilot is an example of code recommender built by training a DL model on millions of open source repositories: The source code of these repositories acts as training data, allowing the model to learn "how to program". The usage of such a code is usually regulated by Free and Open Source Software (FOSS) licenses, that establish under which conditions the licensed code can be redistributed or modified. As of Today, it is unclear whether the code generated by DL models trained on open source code should be considered as "new" or as "derivative" work, with possible implications on license infringements. In this work, we run a large-scale study investigating the extent to which DL models tend to clone code from their training set when recommending code completions. Such an exploratory study can help in assessing the magnitude of the potential licensing issues mentioned before: If these models tend to generate new code that is unseen in the training set, then licensing issues are unlikely to occur. Otherwise, a revision of these licenses urges to regulate how the code generated by these models should be treated when used, for example, in a commercial setting. Highlights from our results show that ~$10% to ~0.1% of the predictions generated by a state-of-the-art DL-based code completion tool are Type-1 clones of instances in the training set, depending on the size of the predicted code. Long predictions are unlikely to be cloned.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。