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

机器与人类是否关注相似的代码?探究大语言模型在代码摘要中的可解释性

Do Machines and Humans Focus on Similar Code? Exploring Explainability of Large Language Models in Code Summarization

Vanderbilt University(范德堡大学);University of Notre Dame(圣母大学)

Jiliang Li, Yifan Zhang, Zachary Karas, Collin McMillan, Kevin Leach, Yu Huang

AI总结:

本文通过眼动追踪与 SHAP 方法比较人类程序员和语言模型在代码摘要中的关注点,发现二者无显著相关性且对齐程度不影响摘要质量,从而揭示现有可解释性方法的局限并提出未来研究方向。

摘要:

近期的语言模型已展现出对源代码进行摘要的能力。然而,与机器学习中的许多其他领域一样,代码语言模型缺乏足够的可解释性。通俗地说,我们缺乏对模型从代码中学习什么以及如何学习的公式化或直观理解。如果随着模型学会生成更高质量的代码摘要,它们也能够在认定哪些代码部分重要上与人类程序员所识别的部分保持一致,那么语言模型的可解释性就可以得到部分提供。在本文中,我们通过人类理解的视角,报告了我们对代码摘要中语言模型可解释性研究的负面结果。我们使用眼动追踪指标(如注视次数和注视时长)来测量人类在代码摘要任务中对代码的关注。为了近似语言模型的关注,我们采用了一种最先进的、模型无关的、黑盒的、基于扰动的方法 SHAP(SHapley Additive exPlanations),来识别哪些代码标记会影响摘要的生成。在这些设置下,我们发现语言模型的关注与人类程序员的注意力之间不存在统计学上显著的关系。此外,在该设置中,模型与人类关注点之间的一致性似乎并不决定 LLM 生成摘要的质量。我们的研究突显了无法将人类关注与基于 SHAP 的模型关注度量对齐。这一结果呼吁未来对代码摘要以及更广泛的软件工程任务中可解释语言模型的多个开放性问题进行研究,包括代码语言模型的训练机制、人类与模型在代码上的注意力之间是否存在一致性、人类注意力是否能改进语言模型的开发,以及还有哪些其他模型关注度量适合用于提高可解释性。

英文摘要:

Recent language models have demonstrated proficiency in summarizing source code. However, as in many other domains of machine learning, language models of code lack sufficient explainability. Informally, we lack a formulaic or intuitive understanding of what and how models learn from code. Explainability of language models can be partially provided if, as the models learn to produce higher-quality code summaries, they also align in deeming the same code parts important as those identified by human programmers. In this paper, we report negative results from our investigation of explainability of language models in code summarization through the lens of human comprehension. We measure human focus on code using eye-tracking metrics such as fixation counts and duration in code summarization tasks. To approximate language model focus, we employ a state-of-the-art model-agnostic, black-box, perturbation-based approach, SHAP (SHapley Additive exPlanations), to identify which code tokens influence that generation of summaries. Using these settings, we find no statistically significant relationship between language models' focus and human programmers' attention. Furthermore, alignment between model and human foci in this setting does not seem to dictate the quality of the LLM-generated summaries. Our study highlights an inability to align human focus with SHAP-based model focus measures. This result calls for future investigation of multiple open questions for explainable language models for code summarization and software engineering tasks in general, including the training mechanisms of language models for code, whether there is an alignment between human and model attention on code, whether human attention can improve the development of language models, and what other model focus measures are appropriate for improving explainability.

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

↑