Gradient

Courses

∇\nabla∇The maths behind AI0/72
π\piπMaths0/84
⋆\star⋆AI for everyone0/10
Γ\GammaΓGame theory0/49
py\texttt{py}pyPython for AI0/15
y^\hat{y}y^​Build your own AI0/15
All courses

Tuition

My tuitionOlympiad trackCompetitions

Practice

ProjectsAsk a questionTrain on a GPUExplorationsMaths StoriesUnsolved problemsPlaygroundScience labsMock testsOlympiad

Reference

GlossaryBlogDiscoveries
Glossary › Causal mask

What is causal mask?

The rule that stops a token from attending to tokens that come after it, so the model cannot see the answer it is being trained to predict.

Where it is taught

Attention. Attention lets each token ask a question of every token before it and take a weighted mix of the answers. It is built from dot products and softmax.

What the lesson leaves you with

  • Each token produces a query, a key and a value.
  • Scores are dot products of queries with keys. Softmax turns them into weights. The output is a weighted mix of values.
  • The causal mask stops tokens from attending to later positions.
Open the lesson

Questions

What is causal mask?
The rule that stops a token from attending to tokens that come after it, so the model cannot see the answer it is being trained to predict.
Where is causal mask used in AI?
Attention lets each token ask a question of every token before it and take a weighted mix of the answers. It is built from dot products and softmax.
What is the key idea to remember about causal mask?
Each token produces a query, a key and a value.
Where can I learn causal mask step by step?
In the lesson “Attention” in Gradient’s course on the maths behind AI, with interactive diagrams and questions.

Related terms

  • Attention
  • Attention head
  • Autoregressive
  • Byte-pair encoding
  • Context length
  • Layer normalisation