# 元强化学习

元强化学习（meta-RL）在一个任务分布上训练强化学习智能体，使其能够从少量经验中适应新任务。<sup>[1](https://arxiv.org/html/2301.08028v4)</sup> 该方法在外层“元训练”循环中使用样本效率较低的机器学习，来学习一个样本效率高的强化学习过程或其组成部分，该过程在内层“适应”循环中运行。<sup>[1](https://arxiv.org/html/2301.08028v4)</sup> 在测试时，适应采取不同形式：对学习到的初始化进行几次梯度更新、在循环网络的隐藏状态中积累经验，或对潜在任务变量进行后验推断。核心权衡是提高测试时的样本效率，代价是降低训练时的样本效率以及对训练分布之外任务的泛化能力。<sup>[1](https://arxiv.org/html/2301.08028v4)</sup>

| 关键事实 | 详情 |
|---|---|
| 元目标 | \( J(\theta) = \mathbb{E}_{M \sim p(M)}\big[\mathbb{E}_{D}[G(D) \mid \pi_{f_{\theta}(D)}, M]\big] \)，内层循环 \( f_{\theta} \) 按任务适应，外层循环更新 \( \theta \)<sup>[1](https://arxiv.org/html/2301.08028v4)</sup> |
| 经典算法 | MAML（元梯度、学习到的初始化）和 RL²（依赖历史的循环策略）<sup>[1](https://arxiv.org/html/2301.08028v4)</sup> |
| PEARL 样本效率 | 异策略任务推断方法，样本效率比先前元强化学习算法高 20–100 倍<sup>[2](https://proceedings.mlr.press/v97/rakelly19a.html)</sup> |
| 基准实际耗时 | Meta-World+ 训练：在配备 NVIDIA A100 GPU 的 AMD Epyc 7402 上，MT10 约 6 小时，MT25 约 12 小时，MT50 约 25 小时<sup>[3](https://papers.nips.cc/paper_files/paper/2025/file/da295a7037612bb3bfc1334a6f8fc8bd-Paper-Datasets_and_Benchmarks_Track.pdf)</sup> |
| Transformer 上下文内强化学习 | ECET 在 \( 5 \times 10^{7} \) 时间步预算内，ML10 平均成功率超过 0.8，ML45 超过 0.6，比基线高约 20%<sup>[4](https://proceedings.iclr.cc/paper_files/paper/2025/file/bbc0df00853596fcf4bbcbef853a880a-Paper-Conference.pdf)</sup> |
| 算力上限 | 元学习强化学习算法本身可能需要数千 TPU 月的算力<sup>[5](https://rlj.cs.umass.edu/2025/papers/RLJ_RLC_2025_218.pdf)</sup> |
| 主要替代方案 | 多任务预训练后微调，在真正不同的任务上与 Reptile、PEARL 和 RL² 表现相当或更好，同时更简单、更便宜<sup>[6](https://proceedings.neurips.cc/paper_files/paper/2022/file/a951f595184aec1bb885ce165b47209a-Paper-Conference.pdf)</sup> |

## 工作原理

元强化学习假设马尔可夫决策过程（MDP）上存在一个分布 \( p(M) \)。元目标为 \( J(\theta) = \mathbb{E}_{M \sim p(M),\, D_{\rm adapt} \sim p(D \mid M)}\big[J_{M}(\pi_{f_{\theta}(D_{\rm adapt})})\big] \)，其中 \( f_{\theta} \) 是内层循环过程，将来自某任务的适应经验 \( D_{\rm adapt} \) 映射为适应后的策略参数，回报 \( J_{M} \) 在 \( M \) 中适应后的轨迹上评估，外层循环根据所有元轨迹更新元参数 \( \theta \)。<sup>[1](https://arxiv.org/html/2301.08028v4)</sup> 由于 \( f \) 的学习发生在外层，而学习到的 \( f \) 执行适应，因此结构是双层的。<sup>[1](https://arxiv.org/html/2301.08028v4)</sup>

不同方法以不同方式实例化 \( f_{\theta} \)，这是区分它们最清晰的方式。MAML 学习一个初始化：内层循环从学习到的初始化 \( \phi \) 计算 \( \phi'_{i} = \phi - \alpha \nabla_{\phi} L_{T_{i}}(\phi) \)，外层循环应用 \( \phi \leftarrow \phi - \beta \nabla_{\phi} \sum_{T_{i} \sim p(T)} L_{T_{i}}(\phi'_{i}) \)，因此元梯度是梯度的梯度，需要额外的反向传播来计算海森矩阵与向量的乘积。<sup>[7](https://doi.org/10.48550/arxiv.1703.03400)</sup> RL² 学习一个依赖历史的策略：循环网络在同一任务的各回合之间将交互历史保存在隐藏状态中，因此适应发生在隐藏状态中，测试时不更新任何参数。<sup>[1](https://arxiv.org/html/2301.08028v4)</sup><sup> • </sup><sup>[8](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/meta-rl)</sup> PEARL 学习摊销的贝叶斯任务推断：它对潜在任务变量 \( z \) 进行在线概率滤波，以从少量经验中推断如何解决新任务，其概率解释支持用于结构化探索的后验采样。<sup>[2](https://proceedings.mlr.press/v97/rakelly19a.html)</sup> MAML 本身可以重新表述为经验贝叶斯，即在跨任务共享参数的层次贝叶斯模型中进行概率推断。<sup>[9](https://cocosci.princeton.edu/papers/gradient-based_meta-learning.pdf)</sup> 另一类方法是元梯度强化学习，它对更新规则本身进行元学习：由元参数 \( \eta \) 参数化的内层损失 \( L_{\mathrm{inner}}^{\eta} \) 驱动更新，可微的外层损失通过更新序列来更新 \( \eta \)。

## 实现方法

实践者首先定义 MDP 上的任务分布 \( p(M) \) 和适应预算：在少样本多任务元强化学习中，智能体必须在几个回合内适应，探索回合数 \( K \) 类似于少样本分类中的“样本数”。<sup>[1](https://arxiv.org/html/2301.08028v4)</sup> 对于在 half-cheetah 和 ant 目标速度或方向等连续控制基准上的 MAML，内层循环更新使用普通策略梯度（REINFORCE），以信赖域策略优化（TRPO）作为元优化器，单次梯度更新即可实现快速适应。<sup>[7](https://doi.org/10.48550/arxiv.1703.03400)</sup> 对于 RL²，使用标准强化学习算法跨任务训练循环策略；最初发表的算法使用 TRPO，后续工作表明使用 PPO 表现更好。<sup>[10](https://arxiv.org/html/2602.19837v1)</sup> 对于 PEARL，训练一个异策略算法，配备从经验中推断任务变量的上下文编码器。<sup>[2](https://proceedings.mlr.press/v97/rakelly19a.html)</sup><sup> • </sup><sup>[6](https://proceedings.neurips.cc/paper_files/paper/2022/file/a951f595184aec1bb885ce165b47209a-Paper-Conference.pdf)</sup> 在测试时，智能体根据方法不同，用少量回合或梯度步进行适应。<sup>[1](https://arxiv.org/html/2301.08028v4)</sup> 标准基准包括 [Meta-World](https://www.edgepedia.org/zh/meta-world)，这是一个用于多任务和元强化学习的基准与评估套件，包含 ML10 和 ML45 等任务集。<sup>[11](https://doi.org/10.48550/arxiv.1910.10897)</sup>

## 起源

元学习早于深度强化学习：最早的系统包括 乌特戈夫（Utgoff） 于 1986 年提出的 STABB（转向更好的偏置）和元遗传编程。<sup>[12](http://www.scholarpedia.org/article/Metalearning)</sup> 该领域的现代深度形式建立在两项几乎同时出现的贡献之上。模型无关元学习由 [切尔西·芬恩](https://www.edgepedia.org/zh/chelsea-finn)（Chelsea Finn）、皮特·阿贝尔（Pieter Abbeel） 和 [谢尔盖·莱文](https://www.edgepedia.org/zh/sergey-levine)（Sergey Levine） 于 2017 年在 arXiv 上提出。<sup>[7](https://doi.org/10.48550/arxiv.1703.03400)</sup> 使用循环网络实现学习到的强化学习过程的深度元强化学习——“学会强化学习”——由 简·X·王（Jane X. Wang） 及其同事于 2016 年在 arXiv 上报告。<sup>[13](https://doi.org/10.48550/arxiv.1611.05763)</sup> PEARL 为异策略元强化学习引入了概率上下文变量，由 凯特·拉凯利（Kate Rakelly） 及其同事于 2019 年在 arXiv 上提出。<sup>[14](https://doi.org/10.48550/arxiv.1903.08254)</sup>

## 变体

**一阶和黑盒方法。** Reptile 是一种基于梯度的元强化学习方法。<sup>[6](https://proceedings.neurips.cc/paper_files/paper/2022/file/a951f595184aec1bb885ce165b47209a-Paper-Conference.pdf)</sup> 一阶 MAML 变体如 Taming-MAML 和 DICE，以及无需海森矩阵的 MAML 和隐式 MAML，避免了二阶梯度。<sup>[10](https://arxiv.org/html/2602.19837v1)</sup>

**近端和贝叶斯方法。** ProMP：近端元策略搜索，由 约纳斯·罗特富斯（Jonas Rothfuss） 及其同事（2018）提出，建立在低方差曲率（LVC）代理目标之上，用 KL 惩罚控制适应前后策略之间的[统计距离](https://www.edgepedia.org/zh/statistical-distance)。<sup>[15](https://doi.org/10.48550/arxiv.1810.06784)</sup> MAML 的贝叶斯视角启发了 LLAMA（轻量拉普拉斯近似元适应），它用基于 K-FAC 曲率估计的拉普拉斯近似替代 MAML 的点估计。<sup>[9](https://cocosci.princeton.edu/papers/gradient-based_meta-learning.pdf)</sup> VariBAD：通过元学习的变分贝叶斯自[适应](https://www.edgepedia.org/zh/adaptation)深度强化学习，由 路易莎·青特格拉夫（Luisa Zintgraf） 及其同事（2021）提出，是一个里程碑式的任务推断方法。<sup>[10](https://arxiv.org/html/2602.19837v1)</sup>

**元学习算法和 Transformer。** FRODO（在线发现灵活强化目标）在单个智能体生命周期内在线元学习更新目标。TrMRL（Transformer 是元强化学习器）由 卢克西亚诺·C·梅洛（Luckeciano C. Melo） 于 2022 年报告。<sup>[16](https://doi.org/10.48550/arxiv.2206.06614)</sup> PSBL 元训练一个 Transformer 来执行最优策略预测后验分布的摊销推断（训练好的网络即时推断答案而非计算答案），用冻结参数采样动作，当测试分布严格偏离训练分布时显著优于标准元强化学习方法。<sup>[17](https://raw.githubusercontent.com/mlresearch/v235/main/assets/xu24o/xu24o.pdf)</sup> AMAGO-2，由 杰克·格里格斯比（Jake Grigsby） 及其同事（2024）提出，针对基于 Transformer 的元强化学习中的多任务障碍。<sup>[18](https://doi.org/10.48550/arxiv.2411.11188)</sup>

## 应用

已发表的评估集中在机器人风格的连续控制和操作基准上：MAML 的 MuJoCo 运动任务，<sup>[7](https://doi.org/10.48550/arxiv.1703.03400)</sup> MAML、RL²、PEARL 和 Transformer 后继方法的 Meta-World 操作套件，<sup>[11](https://doi.org/10.48550/arxiv.1910.10897)</sup><sup> • </sup><sup>[4](https://proceedings.iclr.cc/paper_files/paper/2025/file/bbc0df00853596fcf4bbcbef853a880a-Paper-Conference.pdf)</sup> ECET 的 ManiSkill PickSingleYCB，<sup>[4](https://proceedings.iclr.cc/paper_files/paper/2025/file/bbc0df00853596fcf4bbcbef853a880a-Paper-Conference.pdf)</sup> 以及元梯度方法的 Atari。

## 局限与替代方案

**二阶梯度和同策略限制。** MAML 元梯度需要海森矩阵与向量的乘积，即通过网络进行额外的反向传播。<sup>[7](https://doi.org/10.48550/arxiv.1703.03400)</sup> 由于任务特定的价值函数在未知环境动力学下不可微，原始 MAML 元强化学习范式只能应用策略梯度方法，使其成为同策略方法。<sup>[10](https://arxiv.org/html/2602.19837v1)</sup>

**分布偏移和基准敏感性。** PEARL 在不相交的训练-测试划分上失败，因为其上下文编码器无法为未见任务提供有用的上下文，因为它在适应时不更新参数；在测试时添加梯度微调有助于基于上下文的元强化学习在分布外环境中工作。<sup>[6](https://proceedings.neurips.cc/paper_files/paper/2022/file/a951f595184aec1bb885ce165b47209a-Paper-Conference.pdf)</sup> 基准细节很重要：在 Meta-World+ 上，MAML-V1、MAML-V2 和 RL²-V2 在 ML10/ML45 上统计上没有差异，但 RL² 在 V1 奖励上表现出大幅性能下降，可能是由于观测中未归一化的原始奖励。<sup>[3](https://papers.nips.cc/paper_files/paper/2025/file/da295a7037612bb3bfc1334a6f8fc8bd-Paper-Datasets_and_Benchmarks_Track.pdf)</sup> 算力是另一个限制：强化学习中的元学习实验可能需要数千 TPU 月。<sup>[5](https://rlj.cs.umass.edu/2025/papers/RLJ_RLC_2025_218.pdf)</sup>

**替代方案。** 当 MDP 表示已知时，多任务强化学习是问题的更简单版本，而元强化学习在多任务强化学习失败的地方仍然可能有效，例如使用无法零样本泛化的独热任务表示时。<sup>[1](https://arxiv.org/html/2301.08028v4)</sup> 经验上，当元强化学习算法在真正不同的任务而非同一任务的变体上评估时，多任务预训练后微调的表现与 Reptile、PEARL 和 RL² 相当或更好，同时更简单、计算成本更低。<sup>[6](https://proceedings.neurips.cc/paper_files/paper/2022/file/a951f595184aec1bb885ce165b47209a-Paper-Conference.pdf)</sup> 自 2023 年以来，基于 Transformer 的上下文内强化学习变得突出：算法蒸馏，由 迈克尔·拉斯金（Michael Laskin） 及其同事于 2022 年报告，给 Transformer 完整的强化学习历史，并在上下文中预测下一个动作而无需参数更新，<sup>[8](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/meta-rl)</sup> 而 AnyMDP，一个程序生成的表格 MDP 套件，支持 OmniRL 等模型的大规模元训练，这些模型能泛化到更广泛的任务家族。<sup>[19](https://papers.nips.cc/paper_files/paper/2025/file/fa9e9b2a5176c6f72e78269087b9fe60-Paper-Conference.pdf)</sup> 然而，更强的上下文内泛化以增加任务多样性需求和更长适应期为代价。<sup>[19](https://papers.nips.cc/paper_files/paper/2025/file/fa9e9b2a5176c6f72e78269087b9fe60-Paper-Conference.pdf)</sup>

## References

1. [A Tutorial on Meta-Reinforcement Learning](https://arxiv.org/html/2301.08028v4)
2. [Efficient Off-Policy Meta-Reinforcement Learning via Probabilistic Context Variables (PEARL)](https://proceedings.mlr.press/v97/rakelly19a.html)
3. [Meta-World+: An Improved, Standardized, RL Benchmark (NeurIPS 2025)](https://papers.nips.cc/paper_files/paper/2025/file/da295a7037612bb3bfc1334a6f8fc8bd-Paper-Datasets_and_Benchmarks_Track.pdf)
4. [ECET: Efficient Cross-Episodic Transformers for Online Meta-RL (ICLR 2025)](https://proceedings.iclr.cc/paper_files/paper/2025/file/bbc0df00853596fcf4bbcbef853a880a-Paper-Conference.pdf)
5. [How Should We Meta-Learn Reinforcement Learning Algorithms? (RLC 2025)](https://rlj.cs.umass.edu/2025/papers/RLJ_RLC_2025_218.pdf)
6. [On the Effectiveness of Fine-tuning Versus Meta-reinforcement Learning (NeurIPS 2022)](https://proceedings.neurips.cc/paper_files/paper/2022/file/a951f595184aec1bb885ce165b47209a-Paper-Conference.pdf)
7. [Finn, Chelsea, Abbeel, Pieter, Levine, Sergey (2017). Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1703.03400)
8. [Hands-on Modern RL, Section 11.3: Meta-Reinforcement Learning and Contextual Adaptation](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter13_imitation_meta_rl/meta-rl)
9. [How to train your MAML (MAML as hierarchical Bayesian inference / LLAMA)](https://cocosci.princeton.edu/papers/gradient-based_meta-learning.pdf)
10. [Meta-Learning and Meta-Reinforcement Learning - Tracing the Path towards DeepMind's Adaptive Agent](https://arxiv.org/html/2602.19837v1)
11. [Yu, Tianhe and colleagues (2019). Meta-World: A Benchmark and Evaluation for Multi-Task and Meta Reinforcement Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1910.10897)
12. [Metalearning - Scholarpedia](http://www.scholarpedia.org/article/Metalearning)
13. [Wang, Jane X and colleagues (2016). Learning to reinforcement learn. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1611.05763)
14. [Rakelly, Kate and colleagues (2019). Efficient Off-Policy Meta-Reinforcement Learning via Probabilistic Context Variables. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1903.08254)
15. [Rothfuss, Jonas and colleagues (2018). ProMP: Proximal Meta-Policy Search. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1810.06784)
16. [Melo, Luckeciano C. (2022). Transformers are Meta-Reinforcement Learners. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2206.06614)
17. [Meta-Reinforcement Learning Robust to Distributional Shift Via Performing Lifelong In-Context Learning (PSBL, ICML 2024)](https://raw.githubusercontent.com/mlresearch/v235/main/assets/xu24o/xu24o.pdf)
18. [Grigsby, Jake and colleagues (2024). AMAGO-2: Breaking the Multi-Task Barrier in Meta-Reinforcement Learning with Transformers. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2411.11188)
19. [Towards Large-Scale In-Context Reinforcement Learning by Meta-Training in Randomized Worlds (AnyMDP / OmniRL, NeurIPS 2025)](https://papers.nips.cc/paper_files/paper/2025/file/fa9e9b2a5176c6f72e78269087b9fe60-Paper-Conference.pdf)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Machine learning methods

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/meta-reinforcement-learning

English original: https://www.edgepedia.org/meta-reinforcement-learning
