Longformer › Window Size and Its Effect on Coverage

Michael BrenndoerferUpdated June 25, 20252 min read
Language AI HandbookAll chapters
Part 17 of 67Efficient Attention
Chapter 121Longformer › Window Size and Its Effect on Coverage
Reading section 6 of 16 · Window Size and Its Effect on Coverage · 2 minSection 6 of 16 · 2 min

Book contents

Section 6 of 16 · 2 min read

Longformer › Window Size and Its Effect on CoverageOne section · Sections in this chapter6 / 16 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

The window size is the single most consequential hyperparameter in Longformer. Choosing it well requires understanding the trade-off between local coverage, memory usage, and the number of layers needed for full-sequence reasoning. The following visualization illustrates how different window sizes produce different attention density and coverage profiles.

Out[10]:
Visualization
Line chart showing attention density and per-layer memory usage as a function of window size for a 4096-token sequence.
Effect of window size on attention density and effective receptive field at different sequence lengths. Larger windows provide denser coverage per layer but increase memory usage; smaller windows require more layers for full-document coverage but reduce per-layer memory costs.

Notice that as window size increases, attention density rises and the number of layers needed for full-sequence coverage falls. A window of 64 tokens covers only 1.6% of a 4,096-token sequence per layer and would require 64 layers for a token to be influenced by the full document. A window of 512 tokens covers 12.5% per layer and requires only 8 layers for full propagation. A window of 2,048 tokens covers 50% but uses half as much memory as full attention, making it worth considering only for very dense tasks where far more than just local context matters.