Beyond Self-learned Attention: Mitigating Attention Bias in Transformer-based Models Using Attention Guidance

Jiri Gesi, Iftekhar Ahmed
2/26/2024
cs.SEcs.AI

No confident code implementation found for this paper. 1 possible match can be shown below.

Abstract

Transformer-based models have demonstrated considerable potential for source code modeling tasks in software engineering. However, they are limited by their dependence solely on automatic self-attention weight learning mechanisms. Previous studies have shown that these models overemphasize delimiters added by tokenizers (e.g., [CLS], [SEP]), which may lead to overlooking essential information in the original input source code. To address this challenge, we introduce SyntaGuid, a novel approach that utilizes the observation that attention weights tend to be biased towards specific source code syntax tokens and abstract syntax tree (AST) elements in fine-tuned language models when they make correct predictions. SyntaGuid facilitates the guidance of attention-weight learning, leading to improved model performance on various software engineering tasks. We evaluate the effectiveness of SyntaGuid on multiple tasks and demonstrate that it outperforms existing state-of-the-art models in overall performance without requiring additional data. Experimental result shows that SyntaGuid can improve overall performance up to 3.25% and fix up to 28.3% wrong predictions. Our work represents the first attempt to guide the attention of Transformer-based models towards critical source code tokens during fine-tuning, highlighting the potential for enhancing Transformer-based models in software engineering.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 1 weaker match is hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{gesi2024beyond,
  title  = {Beyond Self-learned Attention: Mitigating Attention Bias in Transformer-based Models Using Attention Guidance},
  author = {Jiri Gesi and Iftekhar Ahmed},
  year   = {2024},
  eprint = {2402.16790},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2402.16790v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.16790.svg)](https://codeofpaper.com/paper/2402.16790)

Discussion