AI Glossary Term

What does “Sliding Window Attention” mean?

Definition

An attention pattern where each token attends only to a fixed-size window of nearby tokens to reduce compute.

How Sliding Window Attention works

Diagram for Sliding Window Attention comparing Full attention (Every token sees every earlier token, Cost grows fast with length) versus Sliding window (Each token sees only the last W tokens, Cost grows in a straight line).Full attentionEvery token seesevery earlier tokenCost grows fastwith lengthSliding windowEach token seesonly the last WtokensCost grows in astraight linevs

Example

With a window of 4,096, a token at position 50,000 attends only to the previous 4,096 tokens. Stacked layers still pass information further, so earlier content can influence it indirectly.

Why it matters

It makes long inputs cheaper to process. Details outside the window can be lost unless layers carry them forward.

Common questions

Which models use it?

Several open models, including some from Mistral and Longformer-style designs, use windowed attention.

Does the model forget old text?

Direct access is limited, though information can propagate through layers.

Window size vs context length?

The window limits direct attention; total context can be larger because layers stack.

Learn more in our free guides

Test yourself

See also