Longformer's Dual Attention: Local Windows & Global Tokens

Longformer's hybrid attention combines local windowed attention, where each token attends to a fixed number of neighbors, with global attention for selected tokens that interact with the entire sequence, balancing efficiency and long-range context.

The top 3

  1. Longformer's Context Leap: Up to 16,384 Tokens: Longformer significantly expanded Transformer context from the typical 512 tokens to thousands, with some implementations reaching up to 16,384 tokens, enabling efficient processing of entire long documents.
  2. Linear Scaling: O(N) vs. O(N²) Attention Complexity: Longformer's hybrid attention mechanism drastically reduces the computational cost from the quadratic O(N²) of standard Transformer self-attention to linear O(N) or O(N*w), where 'w' is the window size, making long-sequence processing significantly more efficient.
  3. Dual Focus: Local Windows & Task-Specific Global Tokens: Longformer's attention mechanism combines fixed-size sliding windows for capturing local context and syntactic structure, with strategically chosen "global tokens" (e.g., CLS tokens for classification or question tokens for QA) that attend to the entire sequence for critical document-level information.

Sources

Open the full topic