Do Machines and Humans Focus on Similar Code? Exploring Explainability of Large Language Models in Code Summarization
作者: Jiliang Li, Yifan Zhang, Zachary Karas, Collin McMillan, Kevin Leach, Yu Huang
分类: cs.SE, cs.AI
发布日期: 2024-02-22
💡 一句话要点
探讨大型语言模型在代码摘要中的可解释性问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 代码摘要 可解释性 眼动追踪 语言模型 SHAP方法 软件工程 人机交互
📋 核心要点
- 现有的代码摘要语言模型缺乏可解释性,无法清晰理解其学习过程及关注点。
- 通过眼动追踪技术和SHAP方法,论文探讨了人类与模型在代码关注点上的一致性。
- 研究发现,语言模型与人类程序员的关注点没有显著关系,且这种关系不影响摘要质量。
📝 摘要(中文)
近年来,语言模型在源代码摘要方面表现出色。然而,代码的语言模型在可解释性方面仍然不足,缺乏对模型如何学习代码的直观理解。本文通过人类理解的视角,研究了语言模型在代码摘要中的可解释性。我们使用眼动追踪技术测量人类在代码摘要任务中的关注点,并采用SHAP方法来近似语言模型的关注点。结果显示,语言模型的关注与人类程序员的注意力之间没有显著关系,且这种关注的对齐并不影响生成摘要的质量。这一发现为未来的研究提出了多个开放性问题,涉及语言模型的训练机制及其与人类注意力的关系等。
🔬 方法详解
问题定义:本文旨在解决大型语言模型在代码摘要任务中的可解释性不足问题。现有方法未能有效对齐模型与人类程序员的关注点,导致对模型学习过程的理解有限。
核心思路:论文通过结合眼动追踪技术与SHAP方法,探讨人类与模型在代码关注点上的一致性,以此评估模型的可解释性。这样的设计旨在揭示模型与人类注意力之间的潜在关系。
技术框架:研究首先通过眼动追踪技术收集人类程序员在代码摘要任务中的关注数据,然后使用SHAP方法分析语言模型的关注点。整体流程包括数据收集、模型分析和结果对比三个主要阶段。
关键创新:本研究的创新点在于首次系统性地比较了语言模型与人类程序员在代码关注点上的一致性,揭示了二者之间的显著差异。这一发现为可解释性研究提供了新的视角。
关键设计:在实验中,眼动追踪技术用于获取人类的关注数据,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.