Q1:和 DreamerV2 的本质区别?
V2 每个 Atari game 都要调 KL 系数;V3 靠 symlog/twohot/return-norm/dyn-rep KL 拆分 + free bits,让所有超参(除 replay ratio 和 model size)跨 150+ 任务固定。V2 只在图像上用离散 latent;V3 把离散通用化到 proprio 输入。📎
论文:Hafner, Pasukonis, Ba, Lillicrap. Mastering Diverse Domains through World Models. Google DeepMind / University of Toronto. arXiv:2301.04104, 2023;正式收录 Nature 2025(vol. 640, pp. 647–653;Nature 版改题 Mastering diverse control tasks through world models)。🌐
让智能体在脑里彩排学本事,不必真去试。秘诀是一套固定参数跑通一百五十多种游戏。📎好比一个不挑剧本的演员——悲剧、喜剧、武打片,一套演技都能演。注意:算法级参数固定,模型大小和数据倍率仍按域微调。
要解决的问题:让一个智能体在一百五十多种任务上都学好。不靠每个任务单独调参。📎
老办法的痛点:以前"世界模型"类的算法对每个环境都要单独调参。📎学习率、损失权重、模型大小都得重设。换个游戏就得调一周。
先说"世界模型"是什么:智能体脑里装一个"想象器"——一个学出来的小模型。📎它专学一件事:「如果我现在做动作 a,下一步世界会变成什么样」。它看着自己走过的路学,慢慢能在脑里把世界"演下去"。
为什么有用:想象的经验近乎无限。还不会在真环境里搞砸。于是智能体能在脑里彩排上千步,再决定怎么动。
DreamerV3 的真本事:靠想象训练不是它首创。它的独门是一套固定参数通吃多任务。以前的根本障碍是各任务的"分数"差好几个数量级。Atari 一局几百上千分,机器人控制分数还不到 1。同一套学习率没法同时应付。
怎么抹平量级差:DreamerV3 用两个归一化 trick。symlog 把大数和小数压到同一把尺子。twohot 把"打多少分"变成"分到哪个格子"的分类题。loss 只看格子、不看数值大小。这样 Atari 和 Control 共用同一套参数。它还在 Minecraft 第一次不用人类数据采到钻石。📎
一句话类比:DreamerV3 之于强化学习,像一个不挑剧本的演员。悲剧、喜剧、武打片,一套演技都能演。而且先在脑里彩排。
核心机制·三件事:(1) 学一个能想象的世界模型;(2) 在想象里训 actor 和 critic;(3) 用归一化让所有任务共享一套固定超参。📎
世界模型的结构(RSSM):状态分两部分。确定性 $h_t$ 像短期记忆,一步一步递推。离散随机 $z_t$ 像掷骰子,捕捉未来不确定性。📎h 由上一步的 h、随机 z、动作 a 经 GRU 推出。z 是看到观测后从后验里采的离散码。z 由若干个 categorical 组成,每个 32 类。200M 默认模型对应 64 个 categorical × 32 类 = 2048 维离散 latent。这是 V3 的关键:把 V2 的离散 latent 通用化到所有 domain。包括 DMC proprio 输入——之前 V2 只在图像上用离散。
在想象里训 actor-critic:actor 完全在想象轨迹上训。从 replay 抽种子状态,用 prior 滚出想象的 latent 轨迹(horizon = 15)。critic 则同时在想象轨迹和 replay 真实轨迹上训。replay 锚定防 critic 漂移(见下「常见误区」与下方「双 critic loss」)。📎
怎么做到跨域固定超参:这是 V3 的灵魂。三个工程 trick:
常见误区(先抛一个):觉得"想象训练 = 错的模拟器"——其实 V3 不在错的模型上规划。它把想象和真实数据混合训 critic(双 loss:imagined 权重 1.0、replay 权重 0.3)。这让 critic 既学想象的、又学真实的。📎
RSSM 完整方程(论文 Eq. 1):
$$h_t = f_\theta(h_{t-1}, z_{t-1}, a_{t-1}) \quad \text{(GRU, deterministic)}$$
$$\hat z_t \sim p_\theta(\hat z_t \mid h_t) \quad \text{(prior, encoder-agnostic, 用于 imagination)}$$
$$z_t \sim q_\theta(z_t \mid h_t, o_t) \quad \text{(posterior, 仅训练时看观测)}$$
$z_t$ 由 $d/16$ 个 categorical 组成,每个 categorical 32 类。categorical 个数随 model size 变化——默认 200M 模型 $d=1024$ 对应 64 个 categorical × 32 类 = 2048 维离散 latent。📎
Sequence model 架构细节(Sec. Networks):
世界模型训练损失(Eq. 2–3):
$$\mathcal{L}(\theta) = \mathbb{E}_{q_\theta, p_\theta}\!\left[\sum_{t=1}^{T}\Big(\beta_{\text{pred}}\,\mathcal{L}_\text{pred} + \beta_{\text{dyn}}\,\mathcal{L}_\text{dyn} + \beta_{\text{rep}}\,\mathcal{L}_\text{rep}\Big)\right]$$
三个 KL 项差别在条件(论文 Eq. 3):
$$\mathcal{L}_\text{dyn} = \max\!\Big(1,\;\mathrm{KL}\big(\text{sg}(q_\phi(z_t|h_t,x_t))\,\|\,p_\phi(z_t|h_t)\big)\Big) \quad\text{(动态损失)}$$
$$\mathcal{L}_\text{rep} = \max\!\Big(1,\;\mathrm{KL}\big(q_\phi(z_t|h_t,x_t)\,\|\,\text{sg}(p_\phi(z_t|h_t))\big)\Big) \quad\text{(表征损失)}$$
$\text{sg}$ 是 stop-gradient。dynamic loss 和 representational loss 拆分是 V3 的关键设计——dyn loss 逼 prior 自己预测(防止 posterior 偷懒只看观测),rep loss 鼓励 posterior 编码观测里超出 prior 预测的信息。分别加权($\beta_\text{dyn}=1.0$, $\beta_\text{rep}=0.1$)。
Free bits 精确机制($\max(1,\cdot)$):当 KL 值低于 1 nat 时,loss 被 clip 到 1(梯度为 0),相当于把这条 KL 项"冻结";只有当 KL 飙升超过 1 nat 时才产生梯度把它压回去。这种「下限保护」避免 KL 项压倒重建、把表征压成平凡。注意 free bits 是 1 nat ≈ 1.44 bits(论文原文),不是「每维 1 nat」——KL 是对所有 $d/16$ categorical 整体计算的总 KL。3D 复杂环境细节多需要弱 regularizer,2D 像素游戏像素细节重要也需弱 regularizer,free bits 让两边都满足。
Actor-Critic 在想象中训(Eq. 4–7):actor 完全在想象轨迹上训——从 replay 抽种子 $(h_1, z_1)$,用 prior $p_\phi$ 滚出想象的 latent 轨迹($H=15$ imagination horizon,Table 4),在想象轨迹上训 actor $\pi_\theta$。critic 同时在想象轨迹($\beta_\text{val}=1.0$)和 replay 真实轨迹($\beta_\text{repval}=0.3$)上训——后者用 imagination rollout 起点的 $\lambda$-return 当作 replay 轨迹的 on-policy value 标注,是防 critic 漂移的关键(见下「双 critic loss」)。Discount $\gamma$ 由「discount horizon」$1/(1-\gamma)=333$ 推出 $\gamma \approx 0.997$(Table 4 的 fixed 值,跨域共享; γ domain-specific 是误读)。
Critic 用 twohot 分类分布(Eq. 5):输出对称指数间隔 bin 上的分类分布,bin 集合 $B = \mathrm{symexp}(-20\ldots+20)$——把 $[-20, +20]$ 用 symexp 映射成指数间隔的 bin 位置,默认 255 个 bin。twohot encoding 在最接近的两个 bin 上线性插值,两值之和 = 1,是 onehot 在连续值上的推广。
双 critic loss(Sec. Critic learning):critic loss 同时施加在两套轨迹上——imagined 权重 $\beta_\text{val}=1.0$,replay buffer 权重 $\beta_\text{repval}=0.3$(把 imagination rollout 起点的 $\lambda$-return 当作 replay 轨迹的 on-policy value annotation)。Critic EMA regularizer(loss scale 1)+ Critic EMA decay 0.98 + reward predictor 和 critic 的 output weight 零初始化——这三条避免训练初期随机网络 hallucinate 大 reward/value。注意别把符号串行:$\beta_\text{pol}=1$ 是 actor loss scale,0.99 是 actor RetNorm decay,都不是 critic EMA 的参数。
Actor loss + return normalization(Eq. 6–7):用 REINFORCE + entropy,return batch 的 5%–95% 百分位差(不是 max-min——为抗 outlier)做 scale,EMA(decay 0.99)平滑;$S<1$ 时强制 $\max(1,S)$——只缩放大 return、不动小 return。这是 V3 跨 domain 通用的灵魂 trick:Atari return 几百、Minecraft 几千、Control 小于 1,固定 entropy 系数 $\eta=3\times10^{-4}$ 全适用。$\eta$ 不归一化(绝对量),让 entropy bonus 的相对作用随训练衰减——探索期强、收敛期弱。
Symlog / symexp(Eq. 8–9):
$$\mathrm{symlog}(x) = \mathrm{sign}(x)\,\ln(|x|+1), \qquad \mathrm{symexp}(x) = \mathrm{sign}(x)\,(\exp(|x|)-1)$$
关键性质:① 压缩大值量级;② 关于原点对称、保留符号(解决 log 不能处理负值的痛点);③ 原点附近近似恒等函数($\mathrm{symlog}(x)\approx x$ for $|x|\ll 1$)——小值预测不受影响。
超参表(Table 4「General」,全部 domain 共享;表头标「算法级固定 vs data/compute 杠杆按域调」):
| 超参 | 值 |
|---|---|
| Replay capacity | $5\times10^6$ transitions |
| Batch size × length | 16 × 64(=1024 transitions/梯度步) |
| Sequence model | GRU with block-diagonal recurrent weights, 8 blocks, RMSNorm + SiLU |
| Recurrent units | $8d$(block size = $d$) |
| Codes per latent | $d/16$,每个 32 类 |
| Hidden size $d$ (MLP) | 256/384/512/768/1024/1536 → 12M/25M/50M/100M/200M/400M |
| Imagination horizon $H$ | 15 |
| Discount horizon $1/(1-\gamma)$ | 333(即 $\gamma\approx 0.997$,全 domain 共享) |
| $\lambda$(TD($\lambda$)) | 0.95 |
| Critic loss scale $\beta_\text{val}$ | 1.0 |
| Critic replay loss scale $\beta_\text{repval}$ | 0.3 |
| Critic EMA regularizer | 1 |
| Critic EMA decay | 0.98 |
| Actor loss scale $\beta_\text{pol}$ | 1 |
| Actor entropy $\eta$ / unimix | $\mathbf{3\times10^{-4}}$(固定)/ 1% |
| Actor RetNorm scale / limit / decay | $\text{Per}(R,95)-\text{Per}(R,5)$ / 1 / 0.99 |
| $\beta_\text{pred}$, $\beta_\text{dyn}$ | 1.0 |
| $\beta_\text{rep}$ | 0.1 |
| Free nats | 1 nat |
| Learning rate | $\mathbf{4\times10^{-5}}$(单一值,world model / actor / critic 共用) |
| Activation | RMSNorm + SiLU(非 ReLU/GELU) |
| Gradient clipping | AGC(0.3)(Adaptive Gradient Clipping,clip per-tensor 到对应 weight matrix L2 norm 的 30%) |
| Optimizer | LaProp($\epsilon=10^{-20}$, $\beta_1=0.9$, $\beta_2=0.99$) |
Replay ratio 仍 domain-specific(Table 2,逐 benchmark):Minecraft 32 / DMLab 32 / ProcGen 64 / Atari 32 / Atari100K 128 / BSuite 1024 / Proprio Control 512 / Visual Control 512。其中 DMLab 与 Atari 同为 32,ProcGen 单列为 64。除 replay ratio 和 model size(Control 用 12M)外,所有算法超参固定——论文原话:「The same values are used across all benchmarks... We do not use any hyperparameter annealing, prioritized replay, weight decay, or dropout.」📎
实验覆盖 150+ 任务:
消融(Appendix C):去掉 symlog twohot,reward 跨度大的 domain(Atari/Minecraft)训不动;去掉 dyn/rep KL 拆分,posterior 偷看观测、prior 学不到长程;去掉 unimix,categorical prior 容易 mode collapse;去掉 critic EMA/target net,critic 震荡、actor 不稳定;去掉 actor return normalization,跨 domain 失败。
局限:
图谱定位:DreamerV3 是 T09 World Model 主线 A「model-based RL 复兴」的当前制高点。📎它是第一个固定超参就跨 150+ 任务(含 Minecraft 钻石)的 model-based RL 算法。Nature 2025 收录正是因为这一普遍性——把 latent world model 从学术玩具变成可 scale 的范式。
演化谱系(Dreamer 三代):
| 版本 | 年份 | 关键改进 | 通用性 |
|---|---|---|---|
| Dreamer (V1) | 2020, arxiv:1912.01603 | 首次提出在 latent RSSM imagination 里训 actor-critic | DMC only |
| DreamerV2 | 2021, arxiv:2010.02193 | 离散 latent z,Atari 超越 model-free | Atari 调 KL |
| DreamerV3 | 2023, arxiv:2301.04104 | symlog/twohot/return-norm/dyn-rep KL 拆分 | 固定超参 150+ 任务 |
建立在:World Models [Ha & Schmidhuber 2018, arxiv:1803.10122]、PlaNet [Hafner 2018]、Dreamer V1/V2、TD($\lambda$)、categorical VAE [VQ-VAE 系]。🌐
同期/后续 model-based RL:IRIS [Micheli 2022, arxiv:2209.00588](Transformer + discrete autoencoder tokenize)、TWM [Robine 2023]、Δ-IRIS、DayDreamer(应用到真机)。🌐
对照生成式 world model:Genie / Cosmos / 1X WM——像素级生成、当 simulator;和 DreamerV3 的 latent 想象是平行而非替代。这两条线对应 T09 主线 A(latent WM / Dreamer 谱系)与主线 B(生成式 WM / Cosmos 谱系)。
副产品·想象训练范式的事实标准:在 latent 空间 rollout + actor-critic 这套工程被后来所有 model-based RL 沿用。[未确认]
Open problems:
"固定超参 = 完全不调" —— 不准确。replay ratio 按 benchmark 在 32–1024 间调,model size 在 Control 用 12M。论文主张 replay ratio 是 compute/efficiency 杠杆、不算「需调超参」,但字面意义并非"零调整"。📎
算法级超参(lr、γ、η、batch、free bits、模型结构)固定,data/compute 杠杆仍按 benchmark 调。
"世界模型 = 仿真器" —— 错。DreamerV3 是 latent world model,不生成像素,不能像 Cosmos/Genie/1X WM 当 data engine 喂 image-based VLA。训练才用 decoder,部署只跑 latent。📎
latent WM 用于"在脑里彩排训 policy",生成式 WM 用于"生成训练数据",两者目的不同。
"想象训练节省算力" —— 不一定。sample efficient(环境步数少)但 wall-clock 不省——每步要做 H=15 的 imagination rollout。📎
sample efficient ≠ wall-clock efficient。
"Minecraft 钻石靠运气" —— 错。难点是论文原话四项:稀疏 reward + 探索难 + 长 horizon + 程序生成的开放世界。📎此前方法都靠人类专家数据或课程才采到钻——MineRL Diamond 竞赛(2019-2021)冠军都是 BC+RL(model-free 系),用了 MineRL 提供的人类专家轨迹数据集;VPT 也是用 contractor 录的键鼠数据做 BC、再 RL finetune,才采到钻。DreamerV3 是第一个不用人类数据、from scratch 采到钻的算法(PDF 原话 "first algorithm to collect diamonds in Minecraft from scratch")。
真正的区分点是 from-scratch vs 用人类数据,不是 model-based vs model-free——model-free 用人类数据早就采到过;里程碑在于「靠世界模型长程想象、不靠人类示范」。📎
"用 Adam 训就行" —— 错。V3 用 LaProp + AGC(Adaptive Gradient Clipping),不用 Adam。LaProp 解耦归一化和动量,配合 $\epsilon=10^{-20}$ 解决 Adam 在长训练偶发的 spike。📎
复现时 optimizer 不能换。
用"不挑剧本的演员"或自己的类比,用自己的话解释:DreamerV3 凭什么让一套参数通吃一百五十多种任务?
💡 参考答案
"世界模型"到底是什么?为什么智能体要在脑里彩排,而不是直接在真环境里试?
💡 参考答案
DreamerV3 在 Minecraft 第一次采到钻石为什么被当成大事?它和此前方法的关键区别是什么?
💡 参考答案
DreamerV3 说"一套固定参数通吃所有 benchmark"。这是字面意义上的完全不调吗?
💡 参考答案
为什么"各任务的分数差好几个数量级"会让同一套参数跑不通?symlog 和 twohot 各解决哪一面?
💡 参考答案
V2 每个 Atari game 都要调 KL 系数;V3 靠 symlog/twohot/return-norm/dyn-rep KL 拆分 + free bits,让所有超参(除 replay ratio 和 model size)跨 150+ 任务固定。V2 只在图像上用离散 latent;V3 把离散通用化到 proprio 输入。📎
间接可以。DayDreamer 已把 Dreamer 谱系搬到真机。但 V3 本身不生成像素、不解决 sim-real gap,做真机还得配 domain randomization 或 residual policy。[未确认]
V2 实验发现离散 latent 在 Atari 上更强(categorical VAE 思路),V3 把这个发现通用化。离散 latent 配 1% unimix 防 mode collapse,配 free bits 防 KL 压倒重建。📎
64×64,stride-2 conv 编码到 6×6 或 4×4,sigmoid 输出。DMC proprio 任务用一个 MLP 替代 conv encoder。📎
需要 MineRL v0.4.4 + 64 env instance + 100M steps(≈100 游戏天内),10 seeds 才能可靠报 diamond 比例。论文修正了原 MineRL 环境的若干 bug(破 diamond ore 提前终止、jump 按键 200ms 等)。📎