Learn AI Math

Sliding Window Attention

What is Sliding Window Attention?

In one sentence: Sliding window attention lets each token look only at a fixed number of nearby earlier tokens, instead of all of them.

It is like reading with a window that only shows the last few pages. This saves a lot of memory and compute for long texts. Information can still travel further because layers stack on top of each other.

What does Sliding Window Attention look like?

With a 4,096-token window, token 10,000 attends only to tokens 5,905 to 10,000.

Why does Sliding Window Attention matter?

It helps models handle long inputs more efficiently.

Last updated · Fact-checked by The AI Math

Linking to this page from a lesson or article?

Like this explanation? Get one every week.

The AI Math newsletter turns confusing AI news into plain English. No hype, no jargon walls.