Machine learning (ML) has been increasingly used in a variety of domains, while solving ML programming tasks poses unique challenges because of the fundamentally different nature and construction from general programming tasks, especially for developers who do not have ML backgrounds. Automatic code generation that produces a code snippet from a natural language description can be a promising technique to accelerate ML programming tasks. In recent years, although many deep learning-based neural code generation models have been proposed with high accuracy, the fact that most of them are mainly evaluated on general programming tasks calls into question their effectiveness and usefulness in ML programming tasks. In this paper, we set out to investigate the effectiveness of existing neural code generation models on ML programming tasks. For our analysis, we select six state-of-the-art neural code generation models, and evaluate their performance on four widely used ML libraries, with newly-created 83K pairs of natural-language described ML programming tasks. Our empirical study reveals some good, bad, and missing aspects of neural code generation models on ML tasks, with a few major ones listed below. (Good) Neural code generation models perform significantly better on ML tasks than on non-ML tasks. (Bad) Most of the generated code is semantically incorrect. (Bad) Code generation models cannot significantly improve developers' completion time. (Good) The generated code can help developers write more correct code by providing developers with clues for using correct APIs. (Missing) The observation from our user study reveals the missing aspects of code generation for ML tasks, e.g., decomposing code generation for divide-and-conquer into two tasks: API sequence identification and API usage generation.
翻译:机器学习(ML)已越来越多地应用于各个领域,然而,解决ML编程任务因其与通用编程任务在本质和构造上的根本不同而面临独特挑战,尤其对于没有ML背景的开发者而言。从自然语言描述生成代码片段的自动代码生成,是加速ML编程任务的一项有前景的技术。近年来,尽管许多基于深度学习的神经代码生成模型已被提出并取得了高准确率,但大多数模型主要在通用编程任务上进行评估,这一事实引发了人们对其在ML编程任务中的有效性和实用性的质疑。在本文中,我们着手调查现有神经代码生成模型在ML编程任务上的有效性。为进行分析,我们选取了六个最先进的神经代码生成模型,并在四个广泛使用的ML库上,利用新创建的83,000对自然语言描述的ML编程任务来评估其性能。我们的实证研究揭示了神经代码生成模型在ML任务上的一些“善”、“恶”和“缺失”的方面,以下列举主要几点。(善)神经代码生成模型在ML任务上的表现显著优于在非ML任务上的表现。(恶)大多数生成的代码在语义上是不正确的。(恶)代码生成模型并不能显著改善开发者的完成时间。(善)生成的代码可以通过为开发者提供使用正确API的线索,帮助他们编写更正确的代码。(缺失)我们用户研究中的观察揭示了代码生成在ML任务上的缺失方面,例如,将“分而治之”的代码生成分解为两个子任务:API序列识别与API用法生成。