AdaptiveKLController¶
- 类 torchrl.data.AdaptiveKLController(*, init_kl_coef: float, target: float, horizon: int, model: nn.Module | None = None)[源代码]¶
Adaptive KL Controller,如 Ziegler 等人在“Fine-Tuning Language Models from Human Preferences”中所述。
- 关键词参数:
init_kl_coef (
float
) – 系数的起始值。target (
float
) – 目标 KL 值。当观测到的 KL 值较小时,系数减小,从而减轻训练目标中的 KL 惩罚,并允许模型进一步偏离参考模型。当观测到的 KL 值大于目标值时,KL 系数增加,从而将模型拉回参考模型。horizon (int) – 控制系数更新力度的缩放因子。
model (nn.Module, optional) – 需要被控制的封装模型。必须具有属性
"kl_coef"
。如果提供,"kl_coef"
将会原地更新。
参考: 第 2.2 节 https://arxiv.org/pdf/1909.08593.pdf#page=2 来源: https://github.com/openai/lm-human-preferences/blob/master/lm_human_preferences/train_policy.py