Alterna · learning material
15.4 Processing of each current separately
Attention is shifted between entries. A small FFN network then converts the representation of each item separately.
What this material covers
- Non-linearity within each position
Content and key concepts
On the previous page, position across the coordinates.
Attention is shifted between entries. A small FFN network then converts the representation of each item separately.
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.
Для изменения рисунка включитеJavaScript; расчёт и теория доступны далее.
Non-linearity within each position
Attention binds the entries; FFN mixes the coordinates of a separate entry. In ReLU:
F
(
X
)
=
ReLU
(
X
W
1
+
b
1
)
W
2
+
b
2
.
F(X)=\operatorname{ReLU}(XW_1+b_1)W_2+b_2.
F
(
X
)
=
ReLU
(
X
W
1
+
b
1
)
W
2
+
b
2
.
At X[n,d],W1[d,d_ff], W2[d_f,d]. All entries use the same webs, but different layers have their own matrices.
SwiGLU uses three matrices in the accepted non-bias option:
G
=
SiLU
(
X
W
g
)
,
U
=
X
W
u
,
F
(
X
)
=
(
G
⊙
U
)
W
d
.
G=\operatorname{SiLU}(XW_g),\quad U=XW_u,\quad
F(X)=(G\odot U)W_d.
G
=
SiLU
(
X
W
g
)
,
U
=
X
W
u
,
F
(
X
)
=
(
G
⊙
U
)
W
d
.
G and U have [n,d_ff], a coordinated work. This is not matmul G·U. Down projection returns widthd. L08 compares options with corrected hidden width;
our lab saves d_ff=2d
So SwiGLU contains more parameters than ReLU.
At d=4,d_ff=8 ReLU-FFN has 32+8+32+4=76 scalar cbias. Bebias SwiGLU has 3×32=96. The entrances and exits of the same shape do not mean equal value.
Research.
Compare the two architectures by tracking the complete list of webs, gate/up/product/down. The change in architecture control re-initiates the model; the comparison of random logs is not an experiment about the quality of the models trained. You can't say "SwiGLU understands better" just by the availability of gate.
d,hidden=4,8
relu_params=d*hidden+hidden+hidden*d+d
swiglu_params=3*d*hidden
assert (relu_params,swiglu_params)==(76,96)
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.
Gate/up/down; with a fixed d_ff budget different from ReLU.
How does this matter continue?
Python examples of Chapter 15
Academic base