arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.09980cs.SEcs.AIcs.CL
收藏

利用程序执行补充信息进行代码表示预训练

Code Representation Pre-training with Complements from Program Executions

Tencent Security Big Data Lab(腾讯安全大数据实验室);UC Davis(加州大学戴维斯分校)

Jiabo Huang, Jianyu Zhao, Yuyang Rong, Yiwen Guo, Yifeng He, Hao Chen

AI总结:

本文提出 FuzzPretrain,通过定制模糊测试器获取测试用例,将程序执行揭示的动态语义信息作为补充嵌入代码表示预训练,在代码搜索任务上显著提升 mAP,证明了利用程序执行学习判别性代码表示的有效性。

摘要:

面向自然语言处理的大语言模型(LLMs)已被移植到编程语言建模中,以推进代码智能的发展。尽管代码可以用文本格式表示,但为了在给定任意输入时能够被正确编译或解释以执行一组期望的行为,代码在语法上更为严格。在这种情况下,现有工作借助语法表示(如抽象语法树、控制流图等)以更少歧义的方式从代码中学习。然而,具有相同目的的程序可以通过多种方式实现,呈现出不同的语法表示,而实现相似的程序却可能具有不同的行为。尽管这些关于功能的语义在执行过程中可以轻易体现,但直接从代码中学习它们却具有挑战性,尤其是在无监督的方式下。因此,在本文中,我们提出 FuzzPretrain,以探索程序通过其测试用例所揭示的动态信息,并将其作为补充嵌入到代码的特征表示中。测试用例借助定制化的模糊测试器(fuzzer)获得,并且仅在预训练阶段需要。FuzzPretrain 在代码搜索任务上相较于仅使用源代码或抽象语法树训练的对应方法,分别取得了超过 6%/9% 的 mAP 提升。我们广泛的实验结果表明,利用程序执行来学习具有判别力的代码表示具有显著优势。

英文摘要:

Large language models (LLMs) for natural language processing have been grafted onto programming language modeling for advancing code intelligence. Although it can be represented in the text format, code is syntactically more rigorous in order to be properly compiled or interpreted to perform a desired set of behaviors given any inputs. In this case, existing works benefit from syntactic representations to learn from code less ambiguously in the forms of abstract syntax tree, control-flow graph, etc. However, programs with the same purpose can be implemented in various ways showing different syntactic representations while the ones with similar implementations can have distinct behaviors. Though trivially demonstrated during executions, such semantics about functionality are challenging to be learned directly from code, especially in an unsupervised manner. Hence, in this paper, we propose FuzzPretrain to explore the dynamic information of programs revealed by their test cases and embed it into the feature representations of code as complements. The test cases are obtained with the assistance of a customized fuzzer and are only required during pre-training. FuzzPretrain yielded more than 6%/9% mAP improvements on code search over its counterparts trained with only source code or AST, respectively. Our extensive experimental results show the benefits of learning discriminative code representations with program executions.

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

↑