arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1802.03691cs.AIcs.LGcs.PL
收藏

用于程序翻译的树到树神经网络

Tree-to-tree Neural Networks for Program Translation

UC Berkeley(加州大学伯克利分校)

Xinyun Chen, Chang Liu, Dawn Song

摘要:

程序翻译是将一种语言的遗留代码迁移到内置的另一种语言的生态系统中的重要工具。在这项工作中,我们是第一个使用深度神经网络来解决这个问题的人。我们观察到,程序翻译是一个模块化的过程,其中源树的子树被翻译成相应的目标子树在每一步。为了捕捉这种直觉,我们设计了一个树到树的神经网络来将源树转换为目标树。同时,针对树到树模型,提出了一种注意力机制,当解码器扩展目标树中的一个非终结符时,注意力机制会在源树中找到相应的子树,以指导解码器的扩展。我们评估我们的树到树模型对几个国家的最先进的方法的程序翻译能力。与其他神经翻译模型相比,我们观察到我们的方法始终优于基线,最高可达15个点。此外,我们的方法可以提高以前的国家的最先进的程序翻译方法的利润率的20个点的翻译现实世界的项目。

英文摘要:

Program translation is an important tool to migrate legacy code in one language into an ecosystem built in a different language. In this work, we are the first to employ deep neural networks toward tackling this problem. We observe that program translation is a modular procedure, in which a sub-tree of the source tree is translated into the corresponding target sub-tree at each step. To capture this intuition, we design a tree-to-tree neural network to translate a source tree into a target one. Meanwhile, we develop an attention mechanism for the tree-to-tree model, so that when the decoder expands one non-terminal in the target tree, the attention mechanism locates the corresponding sub-tree in the source tree to guide the expansion of the decoder. We evaluate the program translation capability of our tree-to-tree model against several state-of-the-art approaches. Compared against other neural translation models, we observe that our approach is consistently better than the baselines with a margin of up to 15 points. Further, our approach can improve the previous state-of-the-art program translation approaches by a margin of 20 points on the translation of real-world projects.

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

↑