paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Thinking Like a Developer? Comparing the Attention of Humans with Neural Models of Code

像开发者一样思考?比较人类与代码神经模型的注意力
ASE 2021 36th IEEE/ACM International Conference on Automated Software Engineering (ASE)2021匹配度 2/10 · 该论文研究代码神经模型的注意力与人类注意力的相似性,属于可解释性和人机对齐,并未涉及静态分析、形式化验证、Agentic LLM 程序或浮点/贝叶斯程序分析等用户核心方向。虽然与“PL+AI”广义交叉,但距离用户正在追的具体问题较远。引用 21 inbox
Matteo Paltenghi, Michael Pradel
crossref: 2026-09-12

AI 速览

一句话:通过1508份人类注意力图,比较代码神经模型的注意力与人类推理,发现 copy attention 更接近人类。

神经代码模型在多种预测任务上表现优异,但其内部推理是否与熟练人类理解代码的方式一致仍不清楚,这可能导致模型因错误原因而正确并依赖虚假相关。本文提出记录人类注意力的方法,收集了91名参与者的1,508张人类注意力图,构建了据作者所知最大的人类注意力数据集。作者计算人类注意力与神经模型注意力之间的相关性。结果显示,模型的 copy attention 常与人类推理显著相关(Spearman 秩相关系数为0.49和0.47),为 copy attention 的直觉提供了实证支持;而常规注意力大多与人类注意力不相关。模型与人类有时关注不同 token,例如字符串对人类重要但常被模型忽略。此外,人类与模型的一致性正相关于模型预测准确率,表明应设计更接近人类推理的神经模型。作者计划公开数据集以促进未来神经代码模型理解和人类启发模型研究。

问题
神经代码模型表现优异,但其注意力是否与人类理解代码的推理一致尚不明确,可能导致模型依赖虚假相关。
方法
提出记录人类注意力的方法,收集91名参与者共1,508张人类注意力图,并与有效神经模型的注意力权重做相关性分析。
评估
通过 Spearman 秩相关比较人类与模型注意力,发现 copy attention 与人类一致性较高(0.49/0.47),常规注意力大多不相关,且一致性正相关于预测准确率。
原文摘要(Abstract)

Neural models of code are successfully tackling various prediction tasks, complementing and sometimes even outperforming traditional program analyses. While most work focuses on end-to-end evaluations of such models, it often remains unclear what the models actually learn, and to what extent their reasoning about code matches that of skilled humans. A poor understanding of the model reasoning risks deploying models that are right for the wrong reason, and taking decisions based on spurious correlations in the training dataset. This paper investigates to what extent the attention weights of effective neural models match the reasoning of skilled humans. To this end, we present a methodology for recording human attention and use it to gather 1,508 human attention maps from 91 participants, which is the largest such dataset we are aware of. Computing human-model correlations shows that the copy attention of neural models often matches the way humans reason about code (Spearman rank coefficients of 0.49 and 0.47), which gives an empirical justification for the intuition behind copy attention. In contrast, the regular attention of models is mostly uncorrelated with human attention. We find that models and humans sometimes focus on different kinds of tokens, e.g., strings are important to humans but mostly ignored by models. The results also show that human-model agreement positively correlates with accurate predictions by a model, which calls for neural models that even more closely mimic human reasoning. Beyond the insights from our study, we envision the release of our dataset of human attention maps to help understand future neural models of code and to foster work on human-inspired models.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot6506,
  title = {Thinking Like a Developer? Comparing the Attention of Humans with Neural Models of Code},
  author = {Matteo Paltenghi and Michael Pradel},
  booktitle = {ASE},
  year = {2021},
  doi = {10.1109/ase51524.2021.9678712}
}