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

代码的通用表示

Universal Representation for Code

Tufts University(塔夫茨大学);Amazon Web Services(亚马逊网络服务)

Linfeng Liu, Hoan Nguyen, George Karypis, Srinivasan Sengamedu

摘要:

从源代码中学习通常需要大量的标记数据。尽管可能缺乏标记数据,但经过训练的模型具有高度的任务特定性,并且缺乏对不同任务的可移植性。在这项工作中,我们提出了有效的预训练策略,在一个新的基于图形的代码表示,以产生通用的代码表示。具体来说,我们基于图形的表示捕捉了代码元素之间的重要语义(例如,控制流和数据流)。我们在表示上预训练图神经网络以提取通用代码属性。然后,预训练的模型可以进行微调,以支持各种下游应用。我们在两个真实世界的数据集上评估我们的模型-跨越30 M Java方法和770 K Python方法。通过可视化,我们揭示了我们的通用代码表示的歧视性质。通过比较多个基准测试,我们证明了所提出的框架在方法名称预测和代码图链接预测方面取得了最先进的结果。

英文摘要:

Learning from source code usually requires a large amount of labeled data. Despite the possible scarcity of labeled data, the trained model is highly task-specific and lacks transferability to different tasks. In this work, we present effective pre-training strategies on top of a novel graph-based code representation, to produce universal representations for code. Specifically, our graph-based representation captures important semantics between code elements (e.g., control flow and data flow). We pre-train graph neural networks on the representation to extract universal code properties. The pre-trained model then enables the possibility of fine-tuning to support various downstream applications. We evaluate our model on two real-world datasets -- spanning over 30M Java methods and 770K Python methods. Through visualization, we reveal discriminative properties in our universal code representation. By comparing multiple benchmarks, we demonstrate that the proposed framework achieves state-of-the-art results on method name prediction and code graph link prediction.

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

↑