What is local attention?

Definition

Local attention restricts which nearby tokens or image regions can directly interact. In a document image, a patch might attend to neighboring patches that contain the rest of a letter or word.

This can reduce computation compared with comparing every element with every other element. A model may combine it with other layers to gather information across distant regions.

ELI5

Imagine reading through a small window that shows a few words at a time. Nearby words help you work out what one word means.

You may still need to look at another part of the page to understand the whole sentence. Local attention similarly handles nearby context first.

Why use local attention?

It limits the number of comparisons a model needs to make at each position.

Can local attention see the entire input in one step?

It sees a limited neighborhood at each position. Other layers or operations can share information over longer distances.

  1. Károly Zsolnai-Fehér in a blue top against black beside the blue-and-white headline “Compressed Context”.
Definition card for local attention: What is local attention?

Local attention lets a model compare each input element with a limited neighborhood.