Transformer: Difference between revisions
| (6 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Transformer]][[Category:Proper name]] | |||
A Transformer is, at the time of writing(2026-08), the most popular architecture for building [[LLM|Large Language Models]]. | A Transformer is, at the time of writing(2026-08), the most popular architecture for building [[LLM|Large Language Models]]. | ||
== Intuition == | == Intuition == | ||
Rongzhou's ''[[User:Rongzhou/Transformer-Intuition|Transformer is a super charged next word prediction algorithm]]'' provides a short intuition for Transformers. | Rongzhou's ''[[User:Rongzhou/Transformer-Intuition|Transformer is a super-charged next word prediction algorithm]]'' provides a short intuition for Transformers. | ||
<blockquote> | |||
As [[User:Rongzhou/BehindScenes/Transformer-Intuition|the author explains himself]], the story doubles as a live demonstration of Transformers: parts of the story were co-authored by a Transformer model. | |||
</blockquote> | |||
== Mathematical | == Mathematical representation == | ||
A Transformer is a mathematical [[function]] ($f_\theta$) parametrised by [[model parameters]] $\theta$, composed of $N$ independent smaller mathematical functions ('''layers'''): | |||
$$ | |||
f_\theta=\varphi^{(N)}\circ\cdots\circ\varphi^{(1)}, | |||
$$ | |||
=== Layers: $\varphi^{(n)}$ === | |||
Typically | |||
$$ | |||
1 \text{ Layer}= 2 \text{ Residual connection} | |||
$$ | |||
(See [[residual connection (Transformer)]]) | |||
==== One popular configuration ==== | |||
$$ | |||
\varphi^{(n)}: X \mapsto X'' \\ | |||
\begin{cases} | |||
\mathbf{X}'=\mathbf{X}+\operatorname{Attn}\left(\operatorname{LN}\left(\mathbf{X}\right)\right),\\ | |||
\mathbf{X}''=\mathbf{X}'+\operatorname{FFN}\left(\operatorname{LN}\left(\mathbf{X}'\right)\right), | |||
\end{cases} | |||
$$ | |||
{| class="wikitable" | |||
|- | |||
| $\operatorname{Attn}$ | |||
| '''Attention''', typically [[self-attention]] | |||
|- | |||
| $\operatorname{LN}$ | |||
| '''[[Layer-normalisation]]''' | |||
|- | |||
| $\operatorname{FFN}$ | |||
| '''[[feed-Forward Network (FFN) Sub-Layer (Transformer)|Feed-Forward Network (FFN)]]''' | |||
|} | |||
== Inference == | |||
See [[forward pass]]. | |||
== History == | == History == | ||
== See also == | == See also == | ||
Latest revision as of 11:05, 16 November 2026
A Transformer is, at the time of writing(2026-08), the most popular architecture for building Large Language Models.
Intuition
Rongzhou's Transformer is a super-charged next word prediction algorithm provides a short intuition for Transformers.
As the author explains himself, the story doubles as a live demonstration of Transformers: parts of the story were co-authored by a Transformer model.
Mathematical representation
A Transformer is a mathematical function ($f_\theta$) parametrised by model parameters $\theta$, composed of $N$ independent smaller mathematical functions (layers):
$$ f_\theta=\varphi^{(N)}\circ\cdots\circ\varphi^{(1)}, $$
Layers: $\varphi^{(n)}$
Typically
$$ 1 \text{ Layer}= 2 \text{ Residual connection} $$ (See residual connection (Transformer))
One popular configuration
$$\begin{gathered} \varphi^{(n)}: X \mapsto X'' \\ \begin{cases} \mathbf{X}'=\mathbf{X}+\operatorname{Attn}\left(\operatorname{LN}\left(\mathbf{X}\right)\right),\\ \mathbf{X}''=\mathbf{X}'+\operatorname{FFN}\left(\operatorname{LN}\left(\mathbf{X}'\right)\right), \end{cases} \end{gathered}$$
| $\operatorname{Attn}$ | Attention, typically self-attention |
| $\operatorname{LN}$ | Layer-normalisation |
| $\operatorname{FFN}$ | Feed-Forward Network (FFN) |
Inference
See forward pass.