Jump to content

Autoregressive decoder-only Transformer: Difference between revisions

From Wikibase
No edit summary
Line 6: Line 6:
== Defining property: Causal restriction ==
== Defining property: Causal restriction ==


The [[self-attention]] '''causal mask''' forbids position $j$ from attending to any position after $j$ in an ADoT.
See [[self-attention causal mask (Transformer)]]
 
Standard scaled dot-product attention computes
 
$$
\mathbf{S} = \frac{\mathbf{Q}\mathbf{K}^\top}{\sqrt{d_k}} \qquad\text{(raw scores, shape } L\times L\text{)}
$$
 
where $L$ is the sequence length.
 
The causal mask is a matrix $\mathbf{M} \in \mathbb{R}^{L\times L}$ defined as
 
$$
\mathbf{M}_{ij} =
\begin{cases}
0, & j \le i \quad\text{(past and present are allowed)}\\[4pt]
-\infty, & j > i \quad\text{(future is forbidden)}
\end{cases}
$$
 
The masked attention is then
 
$$
\operatorname{Attn}_{\text{causal}}(\mathbf{Q},\mathbf{K},\mathbf{V})
= \operatorname{softmax}\!\bigl(\mathbf{S} + \mathbf{M}\bigr)\,\mathbf{V} .
$$
 
=== Example ===


== Characteristics ==
== Characteristics ==

Revision as of 08:46, 12 November 2026

Languages: English · français · Esperanto


An autoregressive decoder-only Transformer (ADoT) is a Transformer architecture that retains only the decoder stack, so that each position attends to itself and to earlier positions only.

Defining property: Causal restriction

See self-attention causal mask (Transformer)

Characteristics

Training

$$ P_\theta(x_t\mid x_{1:t-1}),\, t=1,\cdots,T, $$

can be calculated simultaneously if $\vec x=(x_1,\dots,x_T)$ is fully known. So training can be highly parallelised.

Inference

$$ P_\theta(x_1,\cdots,x_T)=\prod_{t=1}^{T}P_\theta(x_t\mid x_{1:t-1}), $$

Hence ADoT is highly adapted for sequential next token prediction.