arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2407.03611cs.SEcs.AI
收藏

大语言模型理解代码语义能力的实证研究

An Empirical Study on Capability of Large Language Models in Understanding Code Semantics

VNU University of Engineering and Technology(VNU工程技术大学);Faculty of Information Technology(信息技术学院)

Thu-Trang Nguyen, Thanh Trong Vu, Hieu Dinh Vo, Son Nguyen

AI总结:

本文提出EMPICA框架,通过受控代码变换实证评估代码大语言模型的语义理解能力,发现其在鲁棒性与敏感性上因任务和变换算子而异,并指出需重点提升模型对语义非等价变换的敏感性。

摘要:

面向代码的大语言模型(code LLMs)已在众多软件工程(SE)任务中展现出卓越性能,从而推动了代码大语言模型在软件开发中的广泛应用。尽管代码大语言模型取得了成功,但关于这些模型的实际能力与可靠性仍存在重大关切,即“这些模型是否真正从训练数据中学习到了代码语义,并利用所学知识来完成软件工程任务”。本文提出EMPICA,一个旨在系统且实证地评估代码大语言模型理解代码语义能力的综合框架。具体而言,EMPICA系统性地向输入代码引入受控的修改/变换,并考察模型的响应。一般而言,对于所有软件工程任务,代码大语言模型必须对语义等价的代码输入具有鲁棒性,并对语义非等价的输入具有敏感性。具体来说,对于每个软件工程任务,给定输入代码片段c及其语义等价变体,代码大语言模型必须鲁棒地产生一致/等价的输出;而对于c及其语义非等价变体,则期望模型生成不同的输出。我们在三个具有代表性的代码理解任务(包括代码摘要、方法名预测和输出预测)上的实验结果表明,最先进的代码大语言模型对代码变换的鲁棒性和敏感性在不同任务和变换算子之间存在显著差异。此外,代码大语言模型对语义保持变换的鲁棒性优于其对语义非保持变换的敏感性。这些结果凸显了增强模型理解代码语义能力的必要性,尤其是敏感性这一特性。

英文摘要:

Large Language Models for Code (code LLMs) have demonstrated remarkable performance across various software engineering (SE) tasks, increasing the application of code LLMs in software development. Despite the success of code LLMs, there remain significant concerns about the actual capabilities and reliability of these models, "whether these models really learn the semantics of code from the training data and leverage the learned knowledge to perform the SE tasks". In this paper, we introduce EMPICA, a comprehensive framework designed to systematically and empirically evaluate the capabilities of code LLMs in understanding code semantics. Specifically, EMPICA systematically introduces controlled modifications/transformations into the input code and examines the models' responses. Generally, code LLMs must be robust to semantically equivalent code inputs and be sensitive to non-equivalent ones for all SE tasks. Specifically, for every SE task, given an input code snippet c and its semantic equivalent variants, code LLMs must robustly produce consistent/equivalent outputs while they are expected to generate different outputs for c and its semantic non-equivalent variants. Our experimental results on three representative code understanding tasks, including code summarization, method name prediction, and output prediction, reveal that the robustness and sensitivity of the state-of-the-art code LLMs to code transformations vary significantly across tasks and transformation operators. In addition, the code LLMs exhibit better robustness to the semantic preserving transformations than their sensitivity to the semantic non-preserving transformations. These results highlight a need to enhance the model's capabilities of understanding code semantics, especially the sensitivity property.

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

↑