Masked Self-Attention
Properties
created
13.10.2024, 22:10
modified
15.02.2026, 10:11
published
Empty
sources
PV021 Neural Networks
topics
Self-Attention
authors
Empty
ai-assisted
No
A variant of self-attention used in autoregressive models (e.g., GPT) where a causal mask is applied to prevent attending to future tokens, ensuring that each position can only attend to past and current positions.
# Detailed Description
Assume an attention mechanism which, given an input sequence \(\vec{x}_1, \ldots, \vec{x}_T\), generates \(\vec{y}_1, \ldots, \vec{y}_T\).
The Problem: How to generate \(\vec{y}_k\) only based on \(\vec{x}_1, \ldots, \vec{x}_{k-1}\)?
Define a vector score for all \(i, j \in \{ 1, \ldots, T \}\) by:
This means that:
Define a sequence of outputs \(\vec{y}_1, \ldots, \vec{y}_T\) by: