# Attention

> The Attention is a mechanism that lets a neural network weigh the importance of different parts of the input.

## What is the attention mechanism in transformers?

The mechanism that allows a model to determine which parts of the input are most relevant to each other, for example linking a pronoun to the noun it refers to. The cost of attention grows with the length of the context.

- Topic: Training & Architecture
- Type: concept

## Interview questions

### What is self-attention?

Self-attention lets each token look at every other token in the same input and decide how much each one matters for its meaning.

### Why does attention get expensive with long context?

Standard attention compares every token with every other token, so compute and memory grow with the square of the input length.

### What is multi-head attention?

It runs several attention operations in parallel, so each head can focus on different relationships, like grammar or meaning.

## Related cards

- [Transformer](https://wonderium.dev/ai/transformer.md)
- [Context Window](https://wonderium.dev/ai/context-window.md)
- [Token](https://wonderium.dev/ai/token.md)
- [Context Rot](https://wonderium.dev/ai/context-rot.md)

---

- Level: [Artificial Intelligence](https://wonderium.dev/ai.md)
- HTML version: https://wonderium.dev/ai/attention
- Last updated: 2026-11-25
