AlgoViz

Attention and the context window

easy 7 min

Self-attention lets a position mix information from other eligible positions.

Trace the example

Follow the evidence through each stage, then test a change in the case.

How much attention can “it” give an earlier word?

How much attention can “it” give an earlier word?. Selected component: Token positions inside Request.
Open full-size diagram

Request

“The parcel arrived. It …”

At the position for It, the model can use earlier permitted positions. The example isolates two candidate keys to make one attention head’s calculation visible.

The source paragraph was truncated before inference. Can raising its attention weight recover it?

Combine two attention values

Weighted value 7.00

The two scalar values are 8 and 4. All attention not assigned to the first key goes to the second.