EyeTrans: Merging Human and Machine Attention for Neural Code Summarization

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Zhang, Yifan, Li, Jiliang, Karas, Zachary, Bansal, Aakash, Li, Toby Jia-Jun, McMillan, Collin, Leach, Kevin, Huang, Yu
Natura: Preprint
Pubblicazione: 2024
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866916141965770752
author Zhang, Yifan
Li, Jiliang
Karas, Zachary
Bansal, Aakash
Li, Toby Jia-Jun
McMillan, Collin
Leach, Kevin
Huang, Yu
author_facet Zhang, Yifan
Li, Jiliang
Karas, Zachary
Bansal, Aakash
Li, Toby Jia-Jun
McMillan, Collin
Leach, Kevin
Huang, Yu
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2402_14096
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle EyeTrans: Merging Human and Machine Attention for Neural Code Summarization
Zhang, Yifan
Li, Jiliang
Karas, Zachary
Bansal, Aakash
Li, Toby Jia-Jun
McMillan, Collin
Leach, Kevin
Huang, Yu
Software Engineering
Artificial Intelligence
Human-Computer Interaction
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.
title EyeTrans: Merging Human and Machine Attention for Neural Code Summarization
topic Software Engineering
Artificial Intelligence
Human-Computer Interaction
url https://arxiv.org/abs/2402.14096