# Attention Mechanism

- **Canonical URL:** https://getaimath.com/dictionary/attention-mechanism/
- **Topics:** [Transformer Architecture](https://getaimath.com/dictionary/category/transformer-architecture/)
- **Last updated:** 2026-11-25

## What is Attention Mechanism?

**In one sentence:** An attention mechanism is a way for a model to focus on the most useful parts of its input when producing each piece of output.

Humans do this naturally: when reading a question, you focus on the important words. Attention gives each part of the input a score for how relevant it is right now, and then mixes the information using those scores. Self-attention is one kind of attention.

![Transformers & Attention: The Smart Highlighter — Simple cartoon diagram showing how a Transformer reads a whole sentence at once and shines a bright highlighter beam from the word "IT" back to "trophy" so it knows what "IT" means.](https://getaimath.com/diagrams/transformer-architecture.png)
*Napkin Diagram (Transformer Architecture): Older AI read word-by-word and often lost track of earlier words; a Transformer highlights which words connect to which.*

## What is an example of Attention Mechanism?

When translating "red apple" into French, attention helps the model focus on "apple" while writing "pomme."

## Why does Attention Mechanism matter?

Attention lets models handle long, complicated inputs without losing track of what matters.

## Related Concepts

- [Self-Attention](https://getaimath.com/dictionary/self-attention/): Self-attention lets every word in a sentence look at every other word and decide which ones matter most for understanding it.
- [Multi-Head Attention (MHA)](https://getaimath.com/dictionary/multi-head-attention-mha/): Multi-head attention runs several attention processes side by side, so the model can notice different kinds of relationships at once.
- [Transformer](https://getaimath.com/dictionary/transformer/): A Transformer is a type of neural network design that reads all the words in a passage at once and works out how they relate, using attention.
- [Query (Q)](https://getaimath.com/dictionary/query-q/): In attention, the query is a list of numbers that represents what a word is looking for in other words.
- [Key (K)](https://getaimath.com/dictionary/key-k/): In attention, a key is a list of numbers that describes what a word offers, so queries can find it.
- [Value (V)](https://getaimath.com/dictionary/value-v/): In attention, a value is the actual information a word passes along when another word pays attention to it.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/attention-mechanism/)
