Files
myWiki/concepts/token-level-policy-gradient.md

50 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "Token 级策略梯度 (Token-Level Policy Gradient)"
created: 2026-06-18
updated: 2026-06-18
type: concept
tags: [rl, grpo, training, optimization]
sources:
- gan-thinking-based-non-thinking-2026
---
# Token 级策略梯度 (Token-Level Policy Gradient)
Token 级策略梯度是 GRPOShao et al., 2024中使用的优化方法在**每个 token 级别**而非序列级别计算重要性权重和优势估计Gan et al., 2026
## GRPO 的 Token 级损失
TNT 使用以下损失函数:
```
J(θ) = E[ (1/Σ|y^k|) × Σ_k Σ_t min(r_{i,t}(θ) × Â_{i,t}, clip(r_{i,t}(θ), 1-ε, 1+ε) × Â_{i,t}) ]
```
其中:
- `r_{i,t}(θ)`token 级重要性权重(新旧 token 概率比)
- `Â_{i,t}`token 级优势,由 TNT 的奖励函数估计
- 总损失按所有采样轨迹的 token 总数归一化
## 与序列级策略梯度的区别
| | 序列级 | Token 级 |
|---|---|---|
| 粒度 | 整个序列一个奖励 | 每个 token 独立优势 |
| 信用分配 | 粗粒度 | 细粒度 |
| 适合场景 | 简单 RLHF | 复杂推理(需细粒度信号) |
## 在 TNT 中的角色
TNT 的奖励函数为每个 token 提供优势信号:
- 思考模式 token+1正确或 0错误
- 非思考无 hacking token+2正确或 -1错误
- 非思考有 hacking token-2所有 token
Token 级梯度让模型能**在 token 级**学习何时产生/抑制 reward hacking 行为。
## 参考
- [[grpo|GRPO]]
- [[reinforcement-learning|强化学习]]
- [[reward-hacking|Reward Hacking]]
- [[gan-thinking-based-non-thinking-2026|TNT 论文]]