跳转至

延伸:Grokking、信息瓶颈与不可约 Loss

更新日期:2026-04-26


一、不可约 Loss(Irreducible Loss)

1.1 Loss 的两个组成

Chinchilla 的公式 \(L(N,D) = E + A/N^\alpha + B/D^\beta\) 中,\(E\)不可约误差\(E\) 到底是什么?它是数据本身的随机性——即使完美模型也无法预测的部分。

1.2 为什么 \(E > 0\)

自然语言本身有不可消除的歧义。考虑句子"他走到了__"——下一个词可以是"门口"、"尽头"、"路边"等几十种合理选择。即使你完全理解了语言的所有规律,你也无法确定地预测下一个词——因为说话人的选择本身是随机的

\(E = H(X)\),即数据的真实条件熵。对自然语言,\(E\) 估计在 1.0-1.5 nats/token 左右(相当于每 token 1.4-2.2 bits 的固有不确定性)。

1.3 "随机熵"和"知识熵"

总不确定性可以分解:

\[ \text{Total Uncertainty} = \underbrace{\text{Aleatoric}}_{\text{数据本身随机性}} + \underbrace{\text{Epistemic}}_{\text{模型未学到的部分}} \]

Scaling 减少的只是 epistemic uncertainty。不管模型多大数据多多,aleatoric uncertainty 永远存在。这就是 \(E\) 不为零的根本原因。

1.4 不同数据集的 \(E\)

数据类型 估计 \(E\)(nats/token) 等价 bits 理由
自然语言(web) 1.0-1.5 1.4-2.2 多元有效续写 + 风格选择空间大
代码 0.3-0.8 0.4-1.2 语法约束强,token 选择更受限
数学(formal proof) 0.1-0.3 0.15-0.4 接近确定性
自然图像(pixel-level) 5-7 7-10 高熵分布,背景噪声占大头
离散 game state ~0 ~0 确定性环境(Chess / Go)

实操含义:code / math 的 \(E\) 比 web 低 2-3×,所以 code-only 训练的 loss 看着特别低(不是模型更聪明,是基线低)。Phi 路线有大半精髓就是利用 code/math 低 \(E\) 的特点用更少 tokens 达到看似相同的 loss。


二、Grokking:延迟泛化

2.1 什么是 Grokking

训练 loss 很早就到 0(完美记忆),但测试 accuracy 在很久之后才突然提升。模型先"记住"了答案,过了很久才"理解"了规律。参考 Power et al. 2022(OpenAI),最早在 modular addition \(a+b \mod p\) 上观察到。

                 Grokking 经典曲线

  100% ┤   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Train Acc
       │  ╱                                                   
       │ ╱                                                    
   50% ┤╱                              ╱━━━━━━━━━━━━━━━━━━━━━ Test Acc
       │                              ╱                       
       │                            ╱                         
    0% ┤━━━━━━━━━━━━━━━━━━━━━━━━━━━╱                         
       └─────────────────────────────────────────────────────→ steps
        1         100          10K        100K        1M       
                          Grokking 突变                        
                       (memorize → generalize)               

2.2 从压缩视角解释 Grokking

Grokking 的两个阶段恰好对应两种压缩策略(参考 A Two-Phase Perspective on Deep Learning Dynamics (2025)):

  • Phase 1 — Memorization:MDL 角度,模型为每个训练样本"独立编码"答案。等价于查表。描述长度 = \(|D_\text{train}| \times \log_2 V\) tokens。
  • Phase 2 — Compression:找到生成训练数据的底层规律。描述长度 ≈ \(O(\log p)\)(对 modular arithmetic 而言)。

Phase 1 → Phase 2 的转变就是模型从"存每个样本"切换到"存生成规律"。后者描述长度远小于前者 → 真正的压缩 / 理解 / 泛化。

2.3 为什么 Grokking 需要很久

权重衰减(weight decay)是关键。没有 WD 模型"满足于"记忆(Phase 1 就够让 \(L_\text{train} = 0\))。WD 持续压缩参数 → 最终逼模型找更短描述 → Phase 2。

Norm-Separation Delay Law (Mar 2026, arXiv:2603.13331) 给出精确 scaling

\[ T_\text{grok} - T_\text{mem} = \Theta\left( \frac{1}{\gamma_\text{eff}} \log \frac{\|\theta_\text{mem}\|^2}{\|\theta_\text{post}\|^2} \right) \]

其中 \(\gamma_\text{eff}\) 是有效 weight decay rate。经 293 个训练 run 验证,\(R^2 > 0.97\)

直观:grokking 延迟与 WD 反比——WD 越大,泛化来得越快;但太大会破坏 fitting(见 §6.1 Goldilocks 区)。


三、信息瓶颈理论

3.1 Tishby 的框架

信息瓶颈(Information Bottleneck, IB)假说:深度学习分两阶段——拟合(增加互信息 \(I(X; T)\))然后压缩(减少 \(I(X; T)\) 同时保持 \(I(T; Y)\))。

参考 Shwartz-Ziv & Tishby. Opening the Black Box (2017)

目标:最大化 \(I(T; Y)\)(有用信息)同时最小化 \(I(X; T)\)(扔掉无用细节)。

3.2 两阶段训练动态

flowchart LR
    init["初始化<br/>I(X;T) ≈ 0"]
    fit["拟合阶段<br/>I(X;T) ↑<br/>I(T;Y) ↑"]
    compress["压缩阶段<br/>I(X;T) ↓<br/>I(T;Y) 保持"]
    gen["泛化<br/>(grokking 完成)"]

    init --> fit --> compress --> gen

    classDef stage fill:#fff,stroke:#cc785c,color:#1a1a1a;
    class init,fit,compress,gen stage
  • 拟合阶段:网络"记住"训练数据细节,\(I(X;T)\) 增加
  • 压缩阶段:网络"忘记"与任务无关细节(\(I(X;T)\) 减少),保留与输出相关信息(\(I(T;Y)\) 保持)

压缩阶段 = 泛化。模型通过丢弃无关信息获得泛化能力,与 MDL(最小描述长度)原则一致。

3.3 争议

Saxe et al. 2018 指出压缩阶段在 ReLU 网络中不总出现(仅在 tanh 等饱和激活中明显)。2025 Generalized IB Theory 用 "synergy" 重新表述 IB,在更广泛条件下成立。

3.4 和 LLM 训练的关系

LLM 训练规模上没人显式跑 IB-style mutual information 估算——估 \(I(X; T)\) 在亿级参数 + 万亿 token 上是 NP-hard。但 IB 视角给出几个 indirect 信号:

信号 对应 IB 解释
Loss 平台期之后突然下降 进入压缩阶段,丢弃冗余
Train / val loss gap 持续缩小 \(I(X;T)\) 下降但 \(I(T;Y)\) 保持
Activation 稀疏度上升(dead neuron) 网络扔掉无用 channel
Hidden state norm 下降趋势 Effective dimensionality 收缩

实操:这些信号都可以在 LLM 训练 dashboard 里直接看,比 MI 估算便宜。Anthropic / OpenAI 的训练日志公开提及 "compression phase signature" 现象。


四、Phase Transition(相变)

4.1 突然出现的能力

某些能力(CoT 推理、算术、in-context learning)不是渐进出现的,而是在某个模型规模突然涌现。这像物理学的相变——水在 100°C 突然变成蒸汽。

4.2 从压缩视角

相变 = 模型找到了一种更紧凑的表示。在达到某个临界容量之前,模型无法编码某种规律(就像不够大的容器装不下特定形状的物体)。一旦容量够了,规律被突然编码进去 → 能力突然出现。参考 Grokking as a First Order Phase Transition (ICLR 2024)

4.3 三个时间尺度的统一

Two-Phase Perspective (2025) 发现三个看似不同的现象共享同一个时间尺度

现象 表现层面 时间尺度
Grokking 延迟 algorithmic task \(T_\text{grok} - T_\text{mem}\)
LLM emergent capability scale-up benchmark 模型规模阈值
Loss curve "elbow" pretraining 训练动态 tokens 阈值

这三个"异常现象"是同一个底层过程的不同表现:模型从"记忆"切换到"压缩 / 理解"时的过渡行为。


五、对 LLM 训练实践的启示

实践问题 Grokking 视角答案
Validation loss 平台后该不该停? 不要。可能正在进入 compression phase,等几个 checkpoint
Weight decay 是否值得 sweep? 必须。WD 是 grokking 的主控变量(§6.1)
训练曲线异常突变怎么解读? 优先怀疑相变(learn 新能力),不是 bug
Long horizon 训练 vs 早停? LLM scaling 实证 long-horizon 几乎不出 grokking 突变(数据足够多 + 多任务,找规律和找记忆同步发生),但 algorithmic / 小数据下出
学术 baseline 跟 frontier 跑出不同 emergence? 可能 hyperparameter(特别 WD + LR)落在 Goldilocks 区外

六、Grokking 的 4 个维度因素

A Systematic Empirical Study of Grokking (2026, arXiv:2603.25009) 系统跑了 4 维度。结论:"grokking 是 优化-正则交互 现象,不是架构现象"。

6.1 Weight Decay — Goldilocks 区

最关键的控制变量。weight decay 太小或太大都不 grok:

        ↑ 泛化能力(test acc)
    1.0 ┤                                 
        │           ╱╲                    
        │          ╱  ╲                   
        │         ╱    ╲                  
        │        ╱      ╲                 
    0.5 ┤       ╱        ╲                
        │      ╱          ╲               
        │     ╱            ╲              
        │    ╱              ╲             
    0.0 ┤━━━╱                ╲━━━━━━━━━━ → wd  
        │ 0.001          0.1     1.0       
        │ 不够正则化   ↑ Goldilocks   过度
        │ 模型偷懒记   sweet spot     破坏 fitting
        │ 忆 不进 P2  Power 用 0.01   loss 升高

实证 sweet spot 在 \(10^{-2}\) 量级(Power 等用 1.0 weight scale = 0.01 effective WD)。具体值依模型 / 任务变化,需要 sweep。

6.2 Optimizer — AdamW vs SGD 关键差别

AdamW 比 SGD 更容易 grok。原因:

  • AdamW 把 weight decay 跟 gradient update 解耦。第二动量自适应缩放每个参数 → 即使梯度小(接近收敛)weight decay 仍持续把权重往 0 拉
  • SGD 没自适应缩放,梯度小 = 几乎不更新,weight decay 也几乎"看不到"被重新组织的可能

Norm-Separation Delay Law 给定量证明:grokking 需要 optimizer 能"在 fitting 平台期继续 contraction"。AdamW 行,SGD 在大多数 hyperparameter 下不行。

实操:Pre-AdamW (2017 前) 时代,grokking 更难观察。LLaMA 系全 AdamW,DeepSeek-V3 / Kimi K2 部分 Muon,都属"adaptive contraction" 类。

6.3 结构 — 维度依赖

A Systematic Empirical Study 主要发现:

  • Depth 非单调:depth-4 MLP 不 grok,depth-8 ResNet 能 grok。深度本身不够 —— 需要架构稳定化(残差 / Norm)
  • Transformer vs MLP 没本质差别:在匹配 hyperparameter 下 grokking 延迟仅相差 1.11×。"Transformer 才能 grok" 是早期实验混淆造成的伪相关
  • 激活函数依赖正则化区间:GELU 在某些 WD 下比 ReLU 快 4.3× grok;但弱正则化下两者无差别
  • Init scheme:不影响是否 grok,影响 grokking 时间

结构本身不决定 grok / 不 grok。结构决定的是到达 grokking 的速度。是否 grok 由 §6.1 + §6.2 控制。

6.4 数据 — Critical Fraction

Towards Understanding Grokking (NeurIPS 2022) 在 modular addition 上发现:

  • Training fraction < 30%:怎么训都不 grok(不存在足够规律可学)
  • Training fraction 30-40%:临界区,grokking 时间长且不稳定
  • Training fraction > 40%:稳定 grok,且 fraction 越大 grokking 越快

所以 "grokking 需要很久"的根因是 接近临界数据量。LLM 预训练数据 quantity 远远超过临界量,所以单个 emergence task 很少看到几小时级 plateau


七、机理研究:模型在 grok 时到底学到了什么

7.1 Modular Addition 是 Fourier Multiplication

Nanda et al. 2023 反向工程出 modular addition 训练完的 transformer 内部表示:

                  Embedding
                ┌─────┴─────┐
                ↓           ↓
              cos(2πk·a/p)  sin(2πk·a/p)        ← 模型自动学的 DFT!
                │           │                       (k = 频率分量)
                └─────┬─────┘
            cos / sin 三角恒等式 + biais
            cos(2πk·(a+b)/p) = cos·cos - sin·sin
                 output logit

模型不是查表,是用离散 Fourier 变换 + 三角恒等式做模乘。这是真正的"学到规律"。

7.2 双 Circuit 竞争(Circuit Efficiency)

Varma et al. 2023, arXiv:2309.02390 提出"两个 circuit 同时学,谁 efficient 谁胜"模型:

flowchart TB
    init["训练开始<br/>memorize circuit + generalize circuit<br/>都从 0 开始"]
    early["早期<br/>memorize 快 (低参数复杂度)<br/>占主导"]
    mid["中期<br/>generalize 慢但持续提升<br/>memorize 接近饱和"]
    late["后期 (grokking)<br/>generalize circuit 效率追上<br/>weight decay 让 memorize 萎缩"]
    final["结束<br/>generalize 胜出<br/>test acc 突变上去"]

    init --> early --> mid --> late --> final

    classDef phase fill:#fff,stroke:#cc785c,color:#1a1a1a;
    class init,early,mid,late,final phase

为什么 grokking 是突变:测试 acc 由 generalize circuit 主导。直到 generalize 强度超过 memorize 的"残余"那一刻,test acc 才突然跳上去。WD 加速 memorize 衰减 → 加速这个交叉点。

7.3 Norm Threshold(规模无关)

A Systematic Empirical Study 关键发现之一:grokking 总在某个 RMS weight norm 阈值发生,不论 architecture / activation / optimizer。

→ 暗示 grokking 本质是 weight norm 减少到某个临界值 → 模型被迫使用 generalize circuit。

7.4 Grokking at Edge of Numerical Stability

arXiv:2501.04697 (2025) 发现 grokking 临界点跟 softmax 数值稳定性 相关。weight norm 太大 → softmax 饱和 → 梯度消失 → grokking 不再发生。这给"WD 区上限"一个数值层面的解释。

7.5 与 LLM 涌现的连接(待研究)

LLM 的"涌现能力"(emergent capability)跟小模型 grokking 有几个共同点:

  • 突变(不是渐进)
  • 临界规模 / 数据量
  • 内部 circuit 重组(mech interp 工作正在挖)

但本质是否相同还在争议中Schaeffer et al. 2023, "Are Emergent Abilities a Mirage?" 论证部分涌现是 metric 选择伪像;其他工作则认为是真实相变。


八、给 walker 的实操建议

场景 借鉴 grokking 教训
跑 algorithmic / 数学小模型 RL weight decay 必须 sweep,AdamW + warmup 别省
LLM pretrain 不用专门为 grokking 调,但 long-horizon LR schedule 给后期"压缩阶段"留时间
训练曲线诊断 平台期不要慌,看 weight norm 是否在下降;下降 = compression 进行中
可解释性研究 小数据 grokking 是 mech interp 的最佳 testbed(2-layer transformer + modular add 已有几十篇 paper 反向工程)

参考文献

  • [1] Power et al. Grokking (modular arithmetic). 2022. arXiv:2201.02177
  • [2] Liu et al. Towards Understanding Grokking: Effective Theory of Representation Learning. NeurIPS 2022. arXiv:2205.10343
  • [3] Nanda et al. Progress Measures for Grokking via Mechanistic Interpretability. ICLR 2023. arXiv:2301.05217
  • [4] Varma et al. Explaining Grokking through Circuit Efficiency. 2023. arXiv:2309.02390
  • [5] Grokking at the Edge of Numerical Stability. 2025. arXiv:2501.04697
  • [6] A Systematic Empirical Study of Grokking: Depth, Architecture, Activation, Regularization. 2026. arXiv:2603.25009
  • [7] Norm-Separation Delay Law of Grokking. 2026. arXiv:2603.13331
  • [8] Shwartz-Ziv & Tishby. Opening the Black Box (IB Theory). 2017. arXiv:1703.00810
  • [9] Saxe et al. On the IB Theory of Deep Learning. ICLR 2018. openreview
  • [10] Generalized IB Theory. 2025. arXiv:2509.26327
  • [11] A Two-Phase Perspective on Deep Learning Dynamics. 2025. arXiv:2504.12700
  • [12] Why Do We Need Weight Decay in Modern Deep Learning?. NeurIPS 2024. proceedings
  • [13] Schaeffer et al. Are Emergent Abilities a Mirage?. NeurIPS 2023. arXiv:2304.15004
  • [14] Loshchilov & Hutter. AdamW: Decoupled Weight Decay. ICLR 2019. arXiv:1711.05101
  • [15] Grünwald. The Minimum Description Length Principle. MIT Press, 2007.

上级 · A5.1 压缩即智能:信息论推导