# 离策略学习

离策略学习是一种强化学习方法，它使用由另一个策略（行为策略）生成的数据来评估或改进某个决策策略（目标策略）；它包括离线强化学习，即价值估计和策略优化完全从记录或历史数据中进行，不再与环境交互。在实验不可能、有风险或不道德的场景中，这一点至关重要：离策略评估（OPE）从由另一策略产生的历史数据中估计某个评估策略的平均奖励，它对离线强化学习最为关键，因为后者不允许进一步实验。<sup>[1](https://ar5iv.labs.arxiv.org/html/2212.06355)</sup> 在离线强化学习中，数据集由行为策略 \( \pi_{\beta} \) 一次性收集，训练过程从不与[马尔可夫决策过程](https://www.edgepedia.org/zh/markov-decision-process)交互，策略只有在完全训练之后才会部署。<sup>[2](https://arxiv.org/pdf/2005.1643)</sup>

| 关键事实 | 数值或陈述 | 来源 |
|---|---|---|
| OPE 估计什么 | 从不同行为策略的数据中估计评估策略的平均奖励 | <sup>[1](https://ar5iv.labs.arxiv.org/html/2212.06355)</sup> |
| 行为策略与目标策略 | 行为策略生成数据；目标策略是其价值被学习的策略 | <sup>[3](https://mlanthology.org/icml/2000/precup2000icml-eligibility/)</sup> |
| 重要性采样比 | | <sup>[4](http://www.incompleteideas.net/609%20dropbox/slides%20%28pdf%20and%20keynote%29/22-23-offpolicy.pdf)</sup> |
| 视野诅咒 | 逐步 IS 估计器的 MSE 随视野呈指数增长 | <sup>[1](https://ar5iv.labs.arxiv.org/html/2212.06355)</sup> |
| 覆盖量 | 集中度 \( C^{*} = \max_{s,a} d^{\pi^{*}}(s,a) / d^{\pi_{b}}(s,a) \) | <sup>[5](https://cs.mcgill.ca/~comp579/W26/Lectures/20-BatchRL-2026.pdf)</sup> |
| 致命三要素 | 函数逼近、自举和离策略学习三者结合会导致不稳定 | <sup>[4](http://www.incompleteideas.net/609%20dropbox/slides%20%28pdf%20and%20keynote%29/22-23-offpolicy.pdf)</sup> |
| 双重稳健保证 | 若行为策略已知或模型正确，则无偏 | <sup>[2](https://arxiv.org/pdf/2005.1643)</sup> |

## 工作原理

需要区分两个平稳马尔可夫策略：用于生成数据的行为策略，以及其价值函数被求解的目标策略。<sup>[3](https://mlanthology.org/icml/2000/precup2000icml-eligibility/)</sup> 由于数据遵循 \( \pi_{\beta} \) 而问题关注的是 \( \pi \)，需要通过修正对轨迹重新加权。每步比率为 \( \rho_{t} = \pi(a_{t} \mid s_{t}) / \pi_{\beta}(a_{t} \mid s_{t}) \)；在一条轨迹上，修正量相乘，众所周知重要性采样估计可能遭受很大的、甚至可能是无限的方差，主要原因是每步比率乘积的方差。<sup>[4](http://www.incompleteideas.net/609%20dropbox/slides%20%28pdf%20and%20keynote%29/22-23-offpolicy.pdf)</sup><sup> • </sup><sup>[6](https://proceedings.neurips.cc/paper_files/paper/2016/file/c3992e9a68c5ae12bd18488bc579b30d-Paper.pdf)</sup> 逐步重要性采样估计器 \( Q_{\mathrm{PD}} \) 是 \( Q^{\pi} \) 的一致无偏估计器，而加权逐步估计器是一致的但有偏。<sup>[3](https://mlanthology.org/icml/2000/precup2000icml-eligibility/)</sup> 边缘化重要性采样则估计状态边缘比率 \( \rho(s) = d^{\pi}(s) / d^{\pi_{\beta}}(s) \)，其方差不超过逐动作权重乘积的方差，但通常难以精确计算。<sup>[2](https://arxiv.org/pdf/2005.1643)</sup>

[Q-learning](https://www.edgepedia.org/zh/q-learning) 通过其目标也纳入了同一框架：\( r + \gamma \max_{a'} \hat{Q}(s', a') \) 依赖于环境转移，但不依赖于选择动作的策略，因此由早先策略、另一智能体或固定日志收集的转移，都是同一贝尔曼备份（根据奖励和后继价值设定状态价值的更新步骤）的有效样本。<sup>[7](https://d2l.smola.org/chapter_deep-reinforcement-learning/offline-rl.html)</sup> 收敛定理表明，在采用表格（查找表）表示的有限折扣 MDP 中，给定有界奖励、满足 Robbins-Monro 条件 \( \sum_{i} \alpha_{ni}(x,a) = \infty \) 和 \( \sum_{i} [\alpha_{ni}(x,a)]^{2} < \infty \) 的学习率，以及在所有状态中所有动作被反复采样的无穷多幕，Q-learning 以概率 1 收敛到最优动作价值。<sup>[8](https://link.springer.com/article/10.1007/BF00992698)</sup>

## 如何实施

离线工作流程为：在 \( \pi_{\beta} \) 下收集静态数据集 \( \mathcal{D} \)；在没有任何环境交互的情况下训练；仅在完全训练后部署策略。<sup>[2](https://arxiv.org/pdf/2005.1643)</sup> 数据集质量由单策略集中度系数 \( C^{*} = \max_{s,a} d^{\pi^{*}}(s,a) / d^{\pi_{b}}(s,a) \) 概括，即占用密度之比，它刻画了分布偏移并允许部分覆盖。<sup>[5](https://cs.mcgill.ca/~comp579/W26/Lectures/20-BatchRL-2026.pdf)</sup> 一个标准假设是满支撑，即 \( \pi_{e}(a \mid x) > 0 \) 蕴含 \( \pi_{b}(a \mid x) > 0 \)，这通常能保证无偏性，但在实践中往往无法验证。<sup>[9](https://datasets-benchmarks-proceedings.neurips.cc/paper_files/paper/2021/file/a5e00132373a7031000fd987a3c9f87b-Paper-round1.pdf)</sup>

## 起源

该技术笔记将 Q-learning 呈现为一种计算需求有限的增量动态规划方法，并证明了其收敛定理。<sup>[8](https://link.springer.com/article/10.1007/BF00992698)</sup> 基于逐步重要性采样的表格型离策略 TD(\( \lambda \)) 更新在每一步对所有可能动作进行价值备份，并对任何非饥饿行为策略收敛；盖斯特（Geist）和舍雷尔（Scherrer）的综述记录了 TD(\( \lambda \)) 的归属。<sup>[3](https://mlanthology.org/icml/2000/precup2000icml-eligibility/)</sup><sup> • </sup><sup>[10](https://jmlr.org/papers/volume15/geist14a/geist14a.pdf)</sup> 雷米·穆诺斯（Rémi Munos）及其同事在 2016 年的 arXiv 论文中推导了 Retrace(\( \lambda \))，其迹系数为 \( c_{s} = \lambda \min(1, \pi(a_{s} \mid x_{s}) / \mu(a_{s} \mid x_{s})) \)，具有低方差，且对任何行为策略都安全；作为推论，它首次证明了 沃特金斯（Watkins）的 Q(\( \lambda \)) 的收敛性，该问题自 1989 年以来一直悬而未决。<sup>[6](https://proceedings.neurips.cc/paper_files/paper/2016/file/c3992e9a68c5ae12bd18488bc579b30d-Paper.pdf)</sup> 综述文献中的一个警示：TD 学习仅在策略上保证收敛，在容易构造的离策略场景中会发散，正如贝尔德（Baird）在 1995 年所示。<sup>[11](https://jmlr.csail.mit.edu/papers/volume15/dann14a/dann14a.pdf)</sup>

## 变体

评估估计器分为重要性采样、纯基于模型和部分重要性采样三类。<sup>[12](https://people.cs.umass.edu/~pthomas/papers/Thomas2016.pdf)</sup> 江（Jiang）和李（Li）将用于赌博机的双重稳健估计器扩展到序列决策，给出了一个保证无偏且方差可能远低于重要性采样的估计器；它以 2015 年 arXiv 预印本的形式出现，并在 ICML 2016 上发表。<sup>[13](https://doi.org/10.48550/arxiv.1511.03722)</sup><sup> • </sup><sup>[14](https://proceedings.mlr.press/v48/jiang16.html)</sup> 若 \( \pi_{\beta} \) 已知或模型正确，则它是无偏的。<sup>[2](https://arxiv.org/pdf/2005.1643)</sup> 托马斯（Thomas）和布伦斯基尔（Brunskill）的 WDR 估计器将加权重要性采样应用于双重稳健估计器，更好地平衡偏差和方差，他们的 MAGIC 估计器将 WDR 重要性采样估计与基于模型的估计混合以最小化 MSE，通常比现有方法实现低几个数量级的均方误差。<sup>[12](https://people.cs.umass.edu/~pthomas/papers/Thomas2016.pdf)</sup>

离线控制算法约束或惩罚分布外动作。批量约束 Q-learning 将学习到的策略限制在数据集中出现的动作上，通过生成模型 \( G(a \mid s) \approx P_{\mathrm{Data}}(a \mid s) \) 模仿数据集，并从数据集下出现概率较高的动作中选择最佳动作。<sup>[7](https://d2l.smola.org/chapter_deep-reinforcement-learning/offline-rl.html)</sup><sup> • </sup><sup>[5](https://cs.mcgill.ca/~comp579/W26/Lectures/20-BatchRL-2026.pdf)</sup> 保守 Q-learning（CQL）由阿维拉尔·库马尔（Aviral Kumar）及其同事（2020）提出，对 Q 值进行正则化以抑制对分布外动作的高估，在其假设下提供学习策略期望值的下界，而非 Q 值的逐点下界。<sup>[15](https://doi.org/10.48550/arxiv.2006.04779)</sup> 隐式 Q-learning（IQL）由科斯特里科夫（Kostrikov）、奈尔（Nair）和莱文（Levine）（2021）提出，从不在样本外动作上查询 Q 函数，拟合状态条件上期望分位价值函数，并通过优势加权行为克隆提取策略。<sup>[16](https://doi.org/10.48550/arxiv.2110.06169)</sup> TD3+BC 由藤本（Fujimoto）和顾（Gu）（2021）提出，通过在 TD3 策略更新中加入行为克隆项并归一化数据集的状态特征，达到了最先进的离线强化学习性能。<sup>[17](https://proceedings.neurips.cc/paper_files/paper/2021/file/a8166da05c5a094f7dc03724b41886e5-Paper.pdf)</sup>

## 应用

OPE 用于实验昂贵、有风险或不道德的场合，包括医疗保健、推荐系统、教育、对话系统和机器人学。<sup>[1](https://ar5iv.labs.arxiv.org/html/2212.06355)</sup> 在 LLM 后训练中，渐缩离策略 [REINFORCE](https://www.edgepedia.org/zh/reinforce)（TOPR）使用重要性采样的非对称渐缩变体，其离策略 REINFORCE 梯度为 \( \nabla \hat{J}_{\mathrm{OPR}}(\pi) = \frac{\pi(\tau)}{\mu(\tau)} R(\tau) \nabla \log \pi(\tau) \)，即使没有 KL 正则化也能保持稳定的学习动态。<sup>[18](https://proceedings.neurips.cc/paper_files/paper/2025/file/6274d57365d7a6be06e58cad30d1b9da-Paper-Conference.pdf)</sup>

## 局限与替代方案

函数逼近、自举和离策略学习的致命三要素会导致不稳定和发散；任意两者可容忍，但三者不可共存。<sup>[4](http://www.incompleteideas.net/609%20dropbox/slides%20%28pdf%20and%20keynote%29/22-23-offpolicy.pdf)</sup> 长视野导致重要性采样项的指数爆炸，并因行为-评估不匹配而加剧；指数方差增长并非对每个无偏离策略评估估计器都不可避免：边缘化重要性采样在适当假设下可以实现多项式视野依赖；在时变过程中，OPE 仅在两个策略足够相似的近策略设置中可行。<sup>[9](https://datasets-benchmarks-proceedings.neurips.cc/paper_files/paper/2021/file/a5e00132373a7031000fd987a3c9f87b-Paper-round1.pdf)</sup><sup> • </sup><sup>[19](https://pubsonline.informs.org/doi/abs/10.1287/opre.2021.2249)</sup><sup> • </sup><sup>[24](https://papers.neurips.cc/paper_files/paper/2019/hash/4ffb0d2ba92f664c2281970110a2e071-Abstract.html)</sup> 评估与行为策略显著不同的策略会降低有效样本量并增加估计器方差，即使在具有良好特征的线性设置中，OPE 样本复杂度的视野指数下界也成立。<sup>[20](https://papers.nips.cc/paper/2021/file/274a10ffa06e434f2a94df765cac6bf4-Paper.pdf)</sup> 分布偏移是离线强化学习的核心挑战：在一个分布下训练的函数逼近器在另一个分布上被评估。<sup>[2](https://arxiv.org/pdf/2005.1643)</sup> 基于计数的悲观惩罚从支撑较差的状态-动作对的价值中减去 \( \kappa / \sqrt{n(s,a)} \)。<sup>[7](https://d2l.smola.org/chapter_deep-reinforcement-learning/offline-rl.html)</sup>

与替代方案对比：直接方法在模型错误设定下有偏，但方差更低、覆盖要求更弱；而 IS 在行为策略已知时无偏，但当比率很大时不稳定，这是一种偏差-方差权衡；在基准测试中，随着策略差距增大，直接方法估计器（FQE、\( Q^{\pi}(\lambda) \)、IH）比 IPS 方法表现更好。<sup>[1](https://ar5iv.labs.arxiv.org/html/2212.06355)</sup><sup> • </sup><sup>[9](https://datasets-benchmarks-proceedings.neurips.cc/paper_files/paper/2021/file/a5e00132373a7031000fd987a3c9f87b-Paper-round1.pdf)</sup> 2025 年的一项结果解决了一个悖论：使用估计的行为策略进行 IS 比使用真实行为策略的 IS 产生更低的渐近方差，且通常有限样本 MSE 也更低，尽管增加历史长度会以引入偏差为代价降低方差，而这种偏差在有限样本中变得不可忽略。<sup>[21](https://raw.githubusercontent.com/mlresearch/v267/main/assets/zhou25f/zhou25f.pdf)</sup> 一个开放问题是如何调整保守程度，以在过高估计的风险与回避陌生动作的陷阱之间取得平衡。<sup>[22](https://link.springer.com/article/10.1007/s00521-026-11966-8)</sup> 在 LLM 对齐方面，受控实验表明，即使数据覆盖相同，离线算法也不如在线算法，这表明除了覆盖之外，确切的策略上采样顺序也很重要。<sup>[23](https://arxiv.org/html/2405.08448v1)</sup>

## References

1. [A Review of Off-Policy Evaluation in Reinforcement Learning](https://ar5iv.labs.arxiv.org/html/2212.06355)
2. [Offline Reinforcement Learning: Tutorial, Review, and Perspectives on Open Problems (Levine et al.)](https://arxiv.org/pdf/2005.1643)
3. [Eligibility Traces for Off-Policy Policy Evaluation (Precup, Sutton & Singh, ICML 2000)](https://mlanthology.org/icml/2000/precup2000icml-eligibility/)
4. [22 23 offpolicy (incompleteideas.net)](http://www.incompleteideas.net/609%20dropbox/slides%20%28pdf%20and%20keynote%29/22-23-offpolicy.pdf)
5. [Batch / Offline Reinforcement Learning (COMP579 Lecture 20)](https://cs.mcgill.ca/~comp579/W26/Lectures/20-BatchRL-2026.pdf)
6. [Safe and Efficient Off-Policy Reinforcement Learning (Munos et al., NeurIPS 2016)](https://proceedings.neurips.cc/paper_files/paper/2016/file/c3992e9a68c5ae12bd18488bc579b30d-Paper.pdf)
7. [15.6 On-Policy, Off-Policy, and Offline Learning – Dive into Deep Learning](https://d2l.smola.org/chapter_deep-reinforcement-learning/offline-rl.html)
8. [Q-learning (Watkins & Dayan, Machine Learning, 1992)](https://link.springer.com/article/10.1007/BF00992698)
9. [Empirical Study of Off-Policy Policy Evaluation for Reinforcement Learning (COBS benchmark, NeurIPS Datasets and Benchmarks 2021)](https://datasets-benchmarks-proceedings.neurips.cc/paper_files/paper/2021/file/a5e00132373a7031000fd987a3c9f87b-Paper-round1.pdf)
10. [Off-policy Learning With Eligibility Traces: A Survey (Geist & Scherrer, JMLR 2014)](https://jmlr.org/papers/volume15/geist14a/geist14a.pdf)
11. [Policy Evaluation with Temporal Differences: A Survey and Comparison (Dann, Neumann & Peters, JMLR 2014)](https://jmlr.csail.mit.edu/papers/volume15/dann14a/dann14a.pdf)
12. [Data-Efficient Off-Policy Policy Evaluation for Reinforcement Learning (Thomas & Brunskill, ICML 2016; publisher page proceedings.mlr.press/v48/thomasa16.pdf)](https://people.cs.umass.edu/~pthomas/papers/Thomas2016.pdf)
13. [Jiang, Nan, Li, Lihong (2015). Doubly Robust Off-policy Value Evaluation for Reinforcement Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1511.03722)
14. [Doubly Robust Off-policy Value Evaluation for Reinforcement Learning (Jiang & Li, ICML 2016)](https://proceedings.mlr.press/v48/jiang16.html)
15. [Kumar, Aviral and colleagues (2020). Conservative Q-Learning for Offline Reinforcement Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2006.04779)
16. [Kostrikov, Ilya, Nair, Ashvin, Levine, Sergey (2021). Offline Reinforcement Learning with Implicit Q-Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2110.06169)
17. [A Minimalist Approach to Offline Reinforcement Learning (TD3+BC, NeurIPS 2021)](https://proceedings.neurips.cc/paper_files/paper/2021/file/a8166da05c5a094f7dc03724b41886e5-Paper.pdf)
18. [Tapered Off-Policy REINFORCE: Stable and efficient reinforcement learning for LLMs (TOPR, NeurIPS 2025)](https://proceedings.neurips.cc/paper_files/paper/2025/file/6274d57365d7a6be06e58cad30d1b9da-Paper-Conference.pdf)
19. [Efficiently Breaking the Curse of Horizon in Off-Policy Evaluation with Double Reinforcement Learning (Operations Research)](https://pubsonline.informs.org/doi/abs/10.1287/opre.2021.2249)
20. [Offline RL Without Off-Policy Evaluation (Brandfonbrener et al., NeurIPS 2021)](https://papers.nips.cc/paper/2021/file/274a10ffa06e434f2a94df765cac6bf4-Paper.pdf)
21. [Demystifying the Paradox of Importance Sampling with an Estimated History-Dependent Behavior Policy in Off-Policy Evaluation (PMLR v267, 2025)](https://raw.githubusercontent.com/mlresearch/v267/main/assets/zhou25f/zhou25f.pdf)
22. [Distribution shift, generalization and OOD challenge in offline reinforcement learning: a comprehensive survey (Neural Computing and Applications, 2026)](https://link.springer.com/article/10.1007/s00521-026-11966-8)
23. [Understanding the performance gap between online and offline alignment algorithms](https://arxiv.org/html/2405.08448v1)
24. [Towards Optimal Off-Policy Evaluation for Reinforcement Learning with Marginalized Importance Sampling](https://papers.neurips.cc/paper_files/paper/2019/hash/4ffb0d2ba92f664c2281970110a2e071-Abstract.html)

---
*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/off-policy-learning

English original: https://www.edgepedia.org/off-policy-learning
