Skip to main content
QUICK REVIEW

[Paper Review] PolaFormer: Polarity-aware Linear Attention for Vision Transformers

Weikang Meng, Yadan Luo|ArXiv.org|Jan 25, 2025
CCD and CMOS Imaging SensorsEngineering3 citations
TL;DR

PolaFormer introduces polarity-aware linear attention for Vision Transformers to recover negative query-key interactions and reduce attention entropy, improving accuracy and efficiency across vision tasks.

ABSTRACT

Linear attention has emerged as a promising alternative to softmax-based attention, leveraging kernelized feature maps to reduce complexity from quadratic to linear in sequence length. However, the non-negative constraint on feature maps and the relaxed exponential function used in approximation lead to significant information loss compared to the original query-key dot products, resulting in less discriminative attention maps with higher entropy. To address the missing interactions driven by negative values in query-key pairs, we propose a polarity-aware linear attention mechanism that explicitly models both same-signed and opposite-signed query-key interactions, ensuring comprehensive coverage of relational information. Furthermore, to restore the spiky properties of attention maps, we provide a theoretical analysis proving the existence of a class of element-wise functions (with positive first and second derivatives) that can reduce entropy in the attention distribution. For simplicity, and recognizing the distinct contributions of each dimension, we employ a learnable power function for rescaling, allowing strong and weak attention signals to be effectively separated. Extensive experiments demonstrate that the proposed PolaFormer improves performance on various vision tasks, enhancing both expressiveness and efficiency by up to 4.6%.

Motivation & Objective

  • Motivate the limitations of non-negative linear attention and information loss compared to softmax-based attention in Vision Transformers.
  • Develop a polarity-aware mechanism that explicitly models same-signed and opposite-signed query-key interactions.
  • Introduce a learnable, channel-wise power-based rescaling to recover sharp, spiky attention akin to softmax while maintaining linear complexity.
  • Provide theoretical and empirical evidence that the proposed approach improves expressiveness and efficiency across vision benchmarks.

Proposed method

  • Decompose queries and keys into positive and negative components to recover same-signed and opposite-signed interactions.
  • Compute polarity-aware attention using two streams with learnable coefficients Gs and Go to mix same-signed and opposite-signed similarities.
  • Split the value vector along the channel dimension to handle same-signed and opposite-signed responses without extra parameters.
  • Introduce a learnable, per-dimension power function p to rescale features, reducing entropy and preserving sharp attention peaks.
  • Provide a theoretical result showing there exists a function with positive first and second derivatives that reduces positive-sequence entropy (PSE) of the attention map.
  • Demonstrate linear-time complexity Omega = 5Nd^2 + 4Ndd' + k^2Nd + Nd and empirical efficiency gains over baselines.

Experimental results

Research questions

  • RQ1How does polarity-aware linear attention capture full query-key interactions including negative components compared to existing linear attention methods?
  • RQ2Can a learnable, per-dimension power-based rescaling reduce attention entropy to resemble softmax-like sharpness while preserving linear complexity?
  • RQ3Do polarity-aware mechanisms improve performance on standard vision benchmarks (classification, detection, segmentation) and long-range tasks?
  • RQ4What is the impact of polarity coefficients and auxiliary convolutions on representational capacity and efficiency?

Key findings

  • PolaFormer achieves up to 4.6% accuracy/efficiency gains over baselines on vision tasks.
  • On ImageNet-1K, PolaFormer variants outperform many DeiT and Swin baselines with comparable FLOPs.
  • Polarity-aware coefficients Gs and Go improve performance by approximately 1.8% in ablations, indicating complementary handling of same- and opposite-signed interactions.
  • Theoretical analysis shows a function with positive first and second derivatives can reduce the entropy of positive sequences in the attention map, explaining sharper attention.
  • A channel-wise learnable power function effectively preserves sharp attention while maintaining linear complexity.
  • PolaFormer variants (PolaFormer on PVT/Swin backbones) deliver notable improvements in object detection and semantic segmentation with modest FLOP overhead.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.