Alterna · learning material

15.1 One current passes through one block

Let's look at normalization, attention, straight path, and neural layers one by one. A big scheme will be needed after understanding each transition.

What this material covers

Content and key concepts

Attention, neural layers and straight branches are separated.
Let's look at normalization, attention, straight path, and neural layers one by one. A big scheme will be needed after understanding each transition.
The vector obtains positional information, exchanges information and updates its status separately. Residual amounts maintain the same path. The last table gives estimates of the dictionary.
One block of already familiar operations
Общая модель требуетJavaScript; её вычисления, формулы и код разобраны в открытом тексте далее.
Connecting operations already studied
The training decoder uses pre-norm: first the entry of the substrate is normalized, then the conversion is calculated and residual added. For X[n,d]:
N
1
=
LN
⁡
(
X
)
,
R
=
X
+
MHA
⁡
(
N
1
)
,
H
=
R
+
FFN
⁡
(
LN
⁡
(
R
)
)
.
N_1=\operatorname{LN}(X),\quad R=X+\operatorname{MHA}(N_1),\quad
H=R+\operatorname{FFN}(\operatorname{LN}(R)).
N
1
​
=
LN
(
X
)
,
R
=
X
+
MHA
(
N
1
​
)
,
H
=
R
+
FFN
(
LN
(
R
))
.
LN considers mean and population representation
separate for each line
is used by eps=1e - 5 and affine Δ,β. Causal output does not allow the position to read the future. FFN applies to each entry with a common light. Residual folding forms are consistent.
L06 describes the original post-norm encoder-decoder: LayerNorm is standing after residual, and the decoder has a cross-attentation to encoder. This is another, clearly defined pre-norma decodr-only architecture. It includes real calculations of all components, but is not an exact copy of GPT-2 or another specific model.
A hand-held sublayer fixture.
For string[1, -1], Δ=[1.1],β=[0.0] normalized vector[1 - 1]/ G(1+eps). With one available key, the coefficient of attribution1. If the projections are identity, reidual is[1+s, -1 -s],s=1/G(1 +eps), no operation requires "intelligence" of the line.
Experiment.
Take a lock in stages and compare N1,Q/K/V,A,R,N2,F,H. The parameters and activations are separated into an inspector.
not trained in language
The trained tokenizer does not turn random weights into LLM, which can respond in a meaningful way.
from math import sqrt
s=1/sqrt(1+1e-5)
R=[1+s,-1-s]
assert abs(R[0]+R[1])<1e-12
The code repeats the operations just taken care of.
Completely checked Python-example Chapter
Available with a separate file; the short piece shown does not replace its implementation.
Residual adds the result of the subsoil to its abnormal entrance.
Why does the order of words matter? How does this question continue?
Python examples of Chapter 15
Academic base

Textbook contents map