From 04e14a978b0f00bee248e768473b66f6f974aa53 Mon Sep 17 00:00:00 2001 From: KMnO4-zx <1021385881@qq.com> Date: Thu, 5 Jun 2025 10:54:45 +0800 Subject: [PATCH] =?UTF-8?q?docs(chapter5):=20=E4=BF=AE=E6=AD=A3RMSNorm?= =?UTF-8?q?=E5=85=AC=E5=BC=8F=E4=B8=AD=E7=9A=84=E5=8F=98=E9=87=8F=E5=92=8C?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将公式中的权重变量 $w_i$ 改为输入变量 $x_i$ 以匹配实际实现 - 添加可学习的缩放参数 $\gamma$ 到公式中 - 更新变量描述使其更准确 --- docs/chapter5/第五章 动手搭建大模型.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/chapter5/第五章 动手搭建大模型.md b/docs/chapter5/第五章 动手搭建大模型.md index dae9c0e..ff2b8a7 100644 --- a/docs/chapter5/第五章 动手搭建大模型.md +++ b/docs/chapter5/第五章 动手搭建大模型.md @@ -51,14 +51,14 @@ class ModelConfig(PretrainedConfig): `RMSNorm`可以用如下的数学公式表示: $$ -\text{RMSNorm}(x) = \frac{x}{\sqrt{\frac{1}{n}\sum_{i=1}^{n}w_i^2 + \epsilon}} +\text{RMSNorm}(x) = \frac{x}{\sqrt{\frac{1}{n}\sum_{i=1}^{n}x_i^2 + \epsilon}} \cdot \gamma $$ 其中: -- ( $x$ ) 是层的输入。 -- ( $w_i$ ) 代表层的权重。 -- ( $n$ ) 是权重的数量。 -- ( $\epsilon$ ) 是一个小常数,用于数值稳定性(以避免除以零的情况)。 +- $x_i$ 是输入向量的第 $i$ 个元素 +- $\gamma$ 是可学习的缩放参数(对应代码中的 `self.weight`) +- $n$ 是输入向量的维度数量 +- $\epsilon$ 是一个小常数,用于数值稳定性(以避免除以零的情况) 这种归一化有助于通过确保权重的规模不会变得过大或过小来稳定学习过程,这在具有许多层的深度学习模型中特别有用。