Lune

ASE2021顶会

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

Matteo Paltenghi, Michael Pradel

摘要

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.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 9 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • Automating Code-Related Tasks Through Transformers: The Impact of Pre-training 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Diet code is healthy: simplifying programs for pre-trained models of code 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language models 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • The EarlyBIRD Catches the Bug: On Exploiting Early Layers of Encoder Models for More Efficient Code Classification 引用了 AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language models
  • The EarlyBIRD Catches the Bug: On Exploiting Early Layers of Encoder Models for More Efficient Code Classification 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Generating realistic vulnerabilities via neural code editing: an empirical study 引用了 Hoppity: Learning Graph Transformations to Detect and Fix Bugs in Programs
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper9

  1. Diet code is healthy: simplifying programs for pre-trained models of codeZhaowei Zhang, Hongyu Zhang, Beijun Shen, Xiaodong GuFSE 2022 · 39 次引用
  2. Generating realistic vulnerabilities via neural code editing: an empirical studyYu Nong, Yuzhe Ou, Michael Pradel, Feng Chen 等FSE 2022 · 23 次引用
  3. AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language modelsJosé Antonio Hernández López, Martin Weyssow, Jesús Sánchez Cuadrado, Houari A. SahraouiASE 2022 · 18 次引用
  4. Automating Code-Related Tasks Through Transformers: The Impact of Pre-trainingRosalia Tufano, Luca Pascarella, Gabriele BavotaICSE 2023 · 15 次引用
  5. The EarlyBIRD Catches the Bug: On Exploiting Early Layers of Encoder Models for More Efficient Code ClassificationAnastasiia Grishina, Max Hort, Leon MoonenFSE 2023 · 15 次引用

它引用的 Paper14

  1. CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan 等EMNLP Findings 2020 · 2,828 次引用
  2. Global Relational Models of Source CodeVincent J. Hellendoorn, Charles Sutton, Rishabh Singh, Petros Maniatis 等ICLR 2020 · 252 次引用
  3. Interpretations are Useful: Penalizing Explanations to Align Neural Networks with Prior KnowledgeLaura Rieger, Chandan Singh, W. James Murdoch, Bin YuICML 2020 · 249 次引用
  4. Hoppity: Learning Graph Transformations to Detect and Fix Bugs in ProgramsElizabeth Dinella, Hanjun Dai, Ziyang Li, Mayur Naik 等ICLR 2020 · 212 次引用
  5. A Diagnostic Study of Explainability Techniques for Text ClassificationPepa Atanasova, Jakob Grue Simonsen, Christina Lioma, Isabelle AugensteinEMNLP 2020 · 158 次引用

相关 Paper

  1. Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code?Bonan Kou, Shengmai Chen, Zhijie Wang, Lei Ma 等FSE 2024 · 8 次引用
  2. Human Attention Maps for Text Classification: Do Humans and Neural Networks Focus on the Same Words?Cansu Sen, Thomas Hartvigsen, Biao Yin, Xiangnan Kong 等ACL 2020 · 56 次引用
  3. EyeTrans: Merging Human and Machine Attention for Neural Code SummarizationYifan Zhang, Jiliang Li, Zachary Karas, Aakash Bansal 等FSE 2024 · 15 次引用
  4. Do Transformer Models Show Similar Attention Patterns to Task-Specific Human Gaze?Oliver Eberle, Stephanie Brandl, Jonas Pilot, Anders SøgaardACL 2022
  5. A Critical Study of What Code-LLMs (Do Not) LearnAbhinav Anand, Shweta Verma, Krishna Narasimhan, Mira MeziniACL Findings 2024 · 2 次引用
黄昏的海面,两侧是细线勾勒的悬崖