EyeTrans: Merging Human and Machine Attention for Neural Code Summarization
Yifan Zhang, Jiliang Li, Zachary Karas, Aakash Bansal, Toby Jia-Jun Li, Collin McMillan, Kevin Leach, Yu Huang
Abstract
Neural code summarization leverages deep learning models to automatically generate brief natural language summaries of code snippets. The development of Transformer models has led to extensive use of attention during model design. While existing work has primarily and almost exclusively focused on static properties of source code and related structural representations like the Abstract Syntax Tree (AST), few studies have considered human attention -that is, where programmers focus while examining and comprehending code. In this paper, we develop a method for incorporating human attention into machine attention to enhance neural code summarization. To facilitate this incorporation and vindicate this hypothesis, we introduce EyeTrans, which consists of three steps: (1) we conduct an extensive eye-tracking human study to collect and pre-analyze data for model training, (2) we devise a data-centric approach to integrate human attention with machine attention in the Transformer architecture, and (3) we conduct comprehensive experiments on two code summarization tasks to demonstrate the effectiveness of incorporating human attention into Transformers. Integrating human attention leads to an improvement of up to 29.91% in Functional Summarization and up to 6.39% in General Code Summarization performance, demonstrating the substantial benefits of this combination. We further explore performance in terms of robustness and efficiency by creating challenging summarization scenarios in which EyeTrans exhibits interesting properties. We also visualize the attention map to depict the simplifying effect of machine attention in the Transformer by incorporating human attention. This work has the potential to propel AI research in software engineering by introducing more human-centered approaches and data. CCS Concepts: • Software and its engineering → Software creation and management; • Computing methodologies → Artificial intelligence; • Human-centered computing → Interaction design.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext d1a2b0a4-b9cf-46b5-8c2e-7f246174cca2Cited by top-tier papers4
- EyeMulator: Improving Code Language Models by Mimicking Human Visual AttentionYifan Zhang, Chen Huang, Yueke Zhang, Jiahao Zhang et al.ACL 2026 · 4 citations
- Programmers' Visual Attention on Function Call Graphs During Code SummarizationSamantha McLoughlin, Zachary Karas, Robert Wallace, Aakash Bansal et al.ASE 2025 · 1 citation
- On Behavioral Alignment of Model-Code and Human-Code Understandability via Behavioral ProxiesXiaokai Rong, Aashish Yadavally, Hridya Dhulipala, Anh H. N. Nguyen et al.ISSTA 2026
- Seeing Eye to AI: Human Alignment via Gaze-Based Response Rewards for Large Language ModelsÁngela López-Cardona, Carlos Segura, Alexandros Karatzoglou, Sergi Abadal et al.ICLR 2025
Builds on12
- GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng et al.ICLR 2021 · 1,644 citations
- An extensive study on pre-trained models for program understanding and generationZhengran Zeng, Hanzhuo Tan, Haotian Zhang, Jing Li et al.ISSTA 2022 · 142 citations
- jTrans: jump-aware transformer for binary code similarity detectionHao Wang, Wenjie Qu, Gilad Katz, Wenyu Zhu et al.ISSTA 2022 · 139 citations
- QueryFormer: A Tree Transformer Model for Query Plan RepresentationYue Zhao, Gao Cong, Jiachen Shi, Chunyan MiaoVLDB 2022 · 117 citations
- Improving Natural Language Processing Tasks with Human Gaze-Guided Neural AttentionEkta Sood, Simon Tannert, Philipp Müller, Andreas BullingNeurIPS 2020 · 91 citations
Related papers
- ScanCoder: Leveraging Human Attention Patterns to Enhance LLMs for CodeYueke Zhang, Yifan Zhang, Zihan Fang, Greg Trafton et al.FSE 2026
- Retrieval-based neural source code summarizationJian Zhang, Xu Wang, Hongyu Zhang, Hailong Sun et al.ICSE 2020 · 242 citations
- AST-Trans: Code Summarization with Efficient Tree-Structured AttentionZe Tang, Xiaoyu Shen, Chuanyi Li, Jidong Ge et al.ICSE 2022 · 57 citations
- Integrating Tree Path in Transformer for Code RepresentationHan Peng, Ge Li, Wenhan Wang, Yunfei Zhao et al.NeurIPS 2021 · 56 citations
- Pyramid Attention For Source Code SummarizationLei Chai, Ming LiNeurIPS 2022 · 12 citations
