当前位置:AIGC资讯 > AIGC > 正文

LLAMA

RMSNorm

x b = RMSNorm ( x ) = x 1 n ∑ i = 1 n ( x i 2 ) + ϵ xb = \text{RMSNorm}(x) = \frac{x}{\sqrt{\frac{1}{n} \sum_{i=1}^{n} (x_i^2) + \epsilon}} xb=RMSNorm(x)=n1​∑i=1n​(xi2​)+ϵ ​x​

RoPE

对q,k进行PE

公式推导:

先给q(位置m),k(位置n)添加绝对位置信息: f(q, m), f(k, n)

相对位置信息:g(q, k, m-n)

即要构造出<f(q, m), f(k, n)> = g(q, k, m-n)

根据实部虚部推导就行,结果是 f ( q , m ) = q e i m θ f(q,m) = qe^{im\theta} f(q,m)=qeimθ, 即对q转 m θ m\theta mθ,即:

FFN

xb = RMSNorm(x, weight)

hb = xb @ w1, hb2 = xb @ w3

SwiGLU: hb * σ ( h b ) \sigma(hb) σ(hb) * hb2

xb = hb @ w2

残差处理: x += xb

更新时间 2024-02-18