# Causal Attention

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

## What is Causal Attention?

**In one sentence:** Causal attention only lets each word look at the words before it, never the words after.

When a model writes text, it should not cheat by peeking at future words that do not exist yet. Causal attention blocks those future positions using a mask, so the model learns to predict truly from left to right.

![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 Causal Attention?

When predicting the 5th word, causal attention lets the model see words 1 to 4 only.

## Why does Causal Attention matter?

Causal attention is what makes GPT-style models able to generate text one token at a time.

## Related Concepts

- [Scaled Dot-Product Attention](https://getaimath.com/dictionary/scaled-dot-product-attention/): Scaled dot-product attention is the standard math recipe for attention: compare queries and keys, scale the results, softmax them, and mix the values.
- [Masked Attention](https://getaimath.com/dictionary/masked-attention/): Masked attention is attention where some positions are hidden, so certain words cannot look at certain other words.
- [Attention Scores](https://getaimath.com/dictionary/attention-scores/): Attention scores are numbers that show how much each word should focus on every other word.
- [Cross-Attention](https://getaimath.com/dictionary/cross-attention/): Cross-attention lets one part of a model pay attention to a different input, like a decoder looking at an encoder's output.
- [Value Matrix](https://getaimath.com/dictionary/value-matrix/): The value matrix is a grid of learned weights that turns each word's numbers into the value it shares.
- [Multi-Query Attention (MQA)](https://getaimath.com/dictionary/multi-query-attention-mqa/): Multi-query attention is a faster type of attention where all heads share one set of keys and values but keep separate queries.

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