State 状态
我现在在哪?例如:Agent 当前在家。
把 Agent 看成一个会在世界里行动、观察结果、积累经验并追求长期收益的决策者。A visual introduction to agents that act, observe, learn from outcomes, and optimize long-term reward.
MDP 就像定义一个游戏世界。以后无论使用什么强化学习算法,都要先知道:世界里有哪些状态、能做什么动作、世界如何变化、目标是什么,以及未来有多重要。An MDP defines the world an agent lives in: what it can observe, do, how the world changes, what counts as success, and how much the future matters.
我现在在哪?例如:Agent 当前在家。
我现在做什么?例如:开车、搜索或调用工具。
做完以后去哪?世界从当前状态进入下一个状态。
做完以后立刻得到什么?它告诉 Agent 目标方向。
未来有多重要?γ 越大,越愿意等待长期收益。
| 符号 | 意思 | 类比游戏 | 放进 GPT Agent |
|---|---|---|---|
| S | 状态:我现在在哪? | 地图上的房间 | 当前对话、已有信息、工具结果 |
| A | 动作:我现在做什么? | 可以按哪些按钮 | 回复、搜索、调用工具、运行代码 |
| δ | 转移:做完以后去哪? | 按完按钮去哪 | 对话和环境进入新的状态 |
| r | 奖励:立刻得到什么? | 按完按钮得几分 | 是否帮助完成任务 |
| γ | 折扣:未来有多重要? | 未来的钱今天算多少 | 为最终目标重视后续收益的程度 |
Agent 每次动作都会让对话与外部环境进入新的状态。一个“好动作”不只是当前回复好看,而是更接近最终完成任务。Each agent action changes the conversation and environment. A good action is one that moves the task toward completion, not merely one that looks good right now.
定义世界
学会行动
先预测后决策
在内部模拟未来
例子:MuZero · Dreamer · V-JEPA · Cosmos · Genie
策略规定“每个状态应该做什么”。价值函数则问:按照这个策略,从现在开始一路走下去,最后总共能赚多少钱?A policy says what to do in each state. The value function asks how much the journey is worth from now, if we keep following that policy.
规定怎么走。
按照这条走法,最终值多少钱。
所有走法里最高的价值。
实现最高价值的那条走法。
一个状态值多少钱?不只取决于现在拿了多少奖励,还取决于它把你带到了什么未来。记住这句话,就抓住了 Bellman 方程的核心。What is a state worth? Not only the reward you get now, but also the future it leads to. That is the heart of the Bellman equation.
Bellman 期望方程:策略已定,按固定策略继续。
Bellman 最优方程:策略未定,把所有动作算一遍,取价值最大的动作:max
假设 Agent 现在在家,选择动作后会得到不同的即时奖励,并到达不同的未来状态。点击动作,观察 Q 值如何把“现在”和“未来”合在一起。The agent is at home. Each action gives an immediate reward and leads to a different future state. Click an action to see how Q-values combine now and later.
Q 当前处于状态 S,现在选择动作 a,之后采取最优行为时的总价值。它回答的是:“我现在先做这个动作,值多少钱?”Q is the total value of choosing action a in state S, assuming optimal behavior afterwards. It asks: “How valuable is this action right now?”
| 状态 | a1 | a2 | 每行最大值 |
|---|---|---|---|
| S1 | 4.98 | 5.69 | 5.69 → 选择 a2 |
| S2 | 10.98 | 10.69 | 10.98 → 选择 a1 |
Q-learning 不需要事先知道最优策略,而是与环境互动,逐渐估计 Q*(S,a)。方括号里的部分叫误差:新的目标价值与旧 Q 值之间差多少,就修正多少。Q-learning does not need the optimal policy in advance. It interacts with the environment and gradually estimates Q*(S,a). The bracket is the temporal-difference error: update by the gap between the target and the old estimate.
Q-learning 不需要等到整个任务结束,而是利用当前对下一状态的估计来更新当前状态。它不等最终答案,先用自己目前学到的知识,继续教自己。Q-learning does not wait until the whole task ends. It uses the current estimate of the next state to update the current state—learning from its own current knowledge.
选择当前 Q 值最大的动作。优点是能利用已知信息;问题是早期 Q 值不准时,可能过早坚持错误动作。Choose the action with the highest current Q-value. It uses known information, but early estimates may be wrong.
尝试当前看起来不太好的动作,发现更好的路线。如果永远选最大值,可能一直选 a1,永远不试 a2。Try actions that look worse to discover better routes. Always choosing the maximum may keep selecting a1 and never try a2.
以 1−ε 的概率选择当前最优动作;以 ε 的概率随机探索。Choose the current best action with probability 1−ε; explore randomly with probability ε.
所有可能的动作都必须有机会被尝试。不能永远只选择当前最优动作,否则没有机会修正错误的 Q 值。Every state-action pair must have a chance to be tried. Always selecting the current best action prevents wrong estimates from being corrected.
8 题 · 中英文 · 即时反馈
覆盖 Q value、Q 表、更新公式、Bootstrap、探索/利用和收敛条件。Covers Q values, Q-tables, the update rule, bootstrap, exploration, exploitation, and convergence.
Q 函数:衡量“在状态 s 采取动作 a”有多好。它比 Value 多回答一个问题:现在到底选哪个动作?
后续会遇到的算法,本质上都在反复应用 Bellman 的思想: