With the prevalence of publicly available source code repositories to train deep neural network models, neural program models can do well in source code analysis tasks such as predicting method names in given programs that cannot be easily done by traditional program analysis techniques. Although such neural program models have been tested on various existing datasets, the extent to which they generalize to unforeseen source code is largely unknown. Since it is very challenging to test neural program models on all unforeseen programs, in this paper, we propose to evaluate the generalizability of neural program models with respect to semantic-preserving transformations: a generalizable neural program model should perform equally well on programs that are of the same semantics but of different lexical appearances and syntactical structures. We compare the results of various neural program models for the method name prediction task on programs before and after automated semantic-preserving transformations. We use three Java datasets of different sizes and three state-of-the-art neural network models for code, namely code2vec, code2seq, and GGNN, to build nine such neural program models for evaluation. Our results show that even with small semantically preserving changes to the programs, these neural program models often fail to generalize their performance. Our results also suggest that neural program models based on data and control dependencies in programs generalize better than neural program models based only on abstract syntax trees. On the positive side, we observe that as the size of the training dataset grows and diversifies the generalizability of correct predictions produced by the neural program models can be improved too. Our results on the generalizability of neural program models provide insights to measure their limitations and provide a stepping stone for their improvement.
翻译:用于培养深层神经网络模型的公开源代码储存库非常普遍, 神经程序模型可以在源代码分析任务中做得很好, 例如预测特定程序中的方法名称, 而传统程序分析技术无法轻易做到。 虽然这些神经程序模型已经通过各种现有数据集测试, 但是它们推广为意外源代码的程度基本上还不清楚。 由于测试所有意外方案的神经程序模型非常困难, 我们在本文件中建议评估神经程序模型在语义保存变异方面的通用神经程序模型的通用性: 一个普遍适用的神经程序模型应该同样在具有相同语义但具有不同立体外观和合成结构的方案中运行。 我们比较了各种神经程序模型的结果, 用于在自动化的语义保留变异性变之后对程序进行预测。 我们使用三个不同尺寸的爪哇数据集和三种状态的神经网络模型来进行代码变异性变换: 一个通用的神经程序模型, 也就是 更精确变变变换的系统, 更精确的神经机变的神经程序, 更精确的神经程序, 更精确的神经程序也显示我们的系统变的系统变的模型。