Manuscript Offprint

arXiv:2611.04657

Exploiting Biases in Attention for Transformers

Charles Herr, Gabriele Spadaro, Enzo Tartaglione

Abstract

Attention is known to be sparse in vision transformers. In particular, we analyze the unequal relevance of attention-matrix columns to the final computation and show that this phenomenon becomes increasingly pronounced with network depth. This can be interpreted as saying that tokens have an absolute importance for the attention process, independently of queries. Inspired by this, we propose a reformulation of the attention formula that makes this phenomenon explicit by adding an input-dependent bias to the query-key dot product. We show that this new term gives each token a scalar value indicating its anticipated influence on other tokens during the attention process, and can thus serve as a proxy for pruning attention maps. Across multiple transformer model sizes, this allows us to substantially reduce the computational cost of attention, in terms of both FLOPs and inference latency, while retaining most of the original classification accuracy. We publicly released the code and models at https://github.com/EIDOSLAB/AttentionWithBias.

1. Introduction

Since the introduction of the vision transformer (ViT) [7], computer vision has been shifting away from traditional CNN-based architectures [11] to embrace the transformer architecture originally developed for natural language processing [27]. Transformers now achieve strong results across a wide range of visual tasks, including image classification [7], object detection [31], semantic segmentation [30], and image generation [23]. Their reach extends well beyond purely visual problems: by tokenizing images into sequences compatible with language models, the same architecture underpins today's large vision-language models, which jointly process visual and textual tokens for tasks such as visual question answering and instruction following [19]. This versatility has made the transformer a near-universal backbone for modern multimodal perception.

This article has been accepted for publication at the 2027 IEEE/CVF Winter Conference on Applications of Computer Vision (WACV 2027).

Figure

Figure 1. Bias-based column pruning. The learned bias provides a query-independent importance score for each token, allowing low-bias columns to be removed before computing keys and values. Attention is then evaluated only over the retained set K\mathcal{K}, reducing its size from N×NN \times N to N×∣K∣N \times |\mathcal{K}|.

This success, however, comes at a price: the self-attention mechanism at the core of transformers has a computational cost quadratic in the length of the processed sequence. The issue is particularly acute in vision, since for square images the number of tokens grows quadratically with the image resolution, and it is amplified further in multimodal settings, where long visual token streams are concatenated with text [19]. Reducing the cost of attention is thus an important and active research problem.

Existing approaches fall broadly into two families. The first rewrites the attention operator to lower its asymptotic cost, for instance by limiting attention to local windows [20] or replacing the softmax with a linear approximation [4, 16], usually at the expense of some accuracy. The second keeps standard attention but shortens the input sequence by suppressing tokens [1–3, 24], exploiting visual redundancy. Both families rely, explicitly or implicitly, on a notion of token importance, yet obtaining a reliable and cheap importance signal remains difficult and often requires auxiliary prediction modules and additional training objectives [24].

In this work, we take a different route. We start from a simple empirical observation: in the attention maps of trained ViTs, some columns receive a far greater share of attention than others. This effect becomes more pronounced in the deeper layers, where attention maps degenerate into a few near-vertical lines. This suggests that certain tokens carry an absolute importance for the attention process: an influence on other tokens that is largely independent of the query but varies across heads. The same phenomenon has recently been characterized from other angles, as attention sinks in language models [9, 29] and as high-norm register tokens in vision transformers [5, 15]; notably, Gu et al. [9] show that attention sinks behave like an input-independent key bias added inside the softmax. Whereas this line of work largely treats the effect as an artifact to be characterized or cleaned up, we argue that the underlying query-independent importance is a useful quantity that should be made explicit and exploited. As shown in Fig. 1, we then add a learnable, per-head, input-dependent bias to the query-key scores before the softmax. This bias yields, for each token and each head, a scalar quantifying how much that token is expected to influence others. Since this score is computed before keys and values are formed, it serves as a proxy for pruning attention maps, allowing us to skip computing keys and values for low-importance tokens.

Our contributions can be summarized as follows.

• We identify and analyze a query-independent form of column sparsity in ViT attention maps, which becomes increasingly pronounced with depth (Sec. 3.1 and Fig. 3).

• We introduce a minimal reparameterization of self-attention that assigns each token a learned, input-dependent bias, and use it to prune low-importance key-value columns before they are computed (Secs. 3.2 and 3.3).

• We show that bias-based pruning reduces attention computation and inference latency across different model sizes (Sec. 3.4 and Tab. 1), is complementary to sequence-reduction strategies (Sec. 4.3), and achieves a better accuracy-latency trade-off than the evaluated structured-pruning baseline (Sec. 4.4).

References (30)