arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2105.04297cs.PLcs.LGcs.SE
收藏

神经网络如何理解程序?

How could Neural Networks understand Programs?

University of Science and Technology of China(中国科学技术大学);Microsoft Research Asia(微软亚洲研究院)

Dinglan Peng, Shuxin Zheng, Yatao Li, Guolin Ke, Di He, Tie-Yan Liu

摘要:

程序的语义理解是程序设计语言处理的一个基本问题。最近基于NLP中的预训练技术学习代码表示的工作已经朝着这个方向推进了前沿。然而,PL和NL的语义有着本质的区别。这些被忽略,我们认为很难建立一个模型来更好地理解程序,要么直接将现成的NLP预训练技术应用于源代码,要么通过启发式向模型添加特征。事实上,程序的语义可以通过PL理论中的形式语义学来严格定义。例如,操作语义将有效程序的含义描述为更新环境(即,存储器地址-价值函数)。受此启发,我们提出了一种新的程序语义学习范式,模型应该学习的信息组成(1)的表示,以及对齐的基本操作在操作语义,(2)的环境转换,这是不可缺少的程序理解的信息。为了验证我们的建议,我们提出了一个分层的基于transformer的预训练模型OSCAR,以更好地促进程序的理解。OSCAR从中间表示(intermediate representation,IR)和从静态分析得到的编码表示中学习,它们分别用于表示基本操作和近似环境转换。OSCAR在许多实际的软件工程任务上显示出了出色的程序语义理解能力。

英文摘要:

Semantic understanding of programs is a fundamental problem for programming language processing (PLP). Recent works that learn representations of code based on pre-training techniques in NLP have pushed the frontiers in this direction. However, the semantics of PL and NL have essential differences. These being ignored, we believe it is difficult to build a model to better understand programs, by either directly applying off-the-shelf NLP pre-training techniques to the source code, or adding features to the model by the heuristic. In fact, the semantics of a program can be rigorously defined by formal semantics in PL theory. For example, the operational semantics, describes the meaning of a valid program as updating the environment (i.e., the memory address-value function) through fundamental operations, such as memory I/O and conditional branching. Inspired by this, we propose a novel program semantics learning paradigm, that the model should learn from information composed of (1) the representations which align well with the fundamental operations in operational semantics, and (2) the information of environment transition, which is indispensable for program understanding. To validate our proposal, we present a hierarchical Transformer-based pre-training model called OSCAR to better facilitate the understanding of programs. OSCAR learns from intermediate representation (IR) and an encoded representation derived from static analysis, which are used for representing the fundamental operations and approximating the environment transitions respectively. OSCAR empirically shows the outstanding capability of program semantics understanding on many practical software engineering tasks.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑