Skip to main content
Back to Glossary
Technical

Attention Mechanism

A technique that allows neural networks to focus on the most relevant parts of the input when producing each part of the output.


Focusing on What Matters

Attention mechanisms solve a fundamental problem: not everything in the input matters equally. When translating "The cat sat on the mat" to French, the word "cat" is most relevant when generating "chat." Attention lets the model dynamically focus on different parts of the input at different times.

Before attention, models crammed entire sentences into fixed-size vectors. Long sentences got compressed, and information got lost. Attention creates a direct pathway between relevant parts of the input and output, no matter how far apart they are.

How Attention Works

Think of attention as a lookup system. For each output position, the model computes how relevant each input position is, then takes a weighted combination. High attention weight means "pay attention to this." Low weight means "mostly ignore this."

Self-attention takes this further by letting each position in a sequence attend to all other positions in the same sequence. This is how transformers work - every word considers every other word when building its representation. The result is rich, context-aware understanding.

Attention has become the dominant paradigm in AI because it's effective and scalable. Multi-head attention runs multiple attention operations in parallel, letting models capture different types of relationships simultaneously. It's one of those ideas that seems obvious in retrospect but took years to discover.

Related Terms

More in Technical