S4-06 · 基础 S4-06 · Foundation

贪心解码 · 每一步都走眼前最粗的枝 Greedy Decoding · Take the Thickest Branch at Every Step

argmax now → append → argmax again ≠ best full sequence

贪心解码(Greedy Decoding)每一步都选择当前概率最高的 token。它简单、确定,但局部最高不保证整句话的联合概率最高。 Greedy Decoding picks the highest-probability token at every step. It is simple and deterministic, but a local maximum does not guarantee the best full sequence.

01 · 走迷宫时只选眼前最宽的路 01 · Always taking the widest-looking corridor

每个路口都走最宽的通道,为什么最后可能绕到一条更差的终点? If you take the widest corridor at every junction, why can you still end at a worse destination?

02 沿最粗枝走两步,再看整体概率 Follow the Thickest Branch for Two Steps, Then Compare

局部 ≠ 整体 Local ≠ global
状态 A Metric A
状态 B Metric B
状态 C Metric C

概率与输出均为固定种子的教学模拟,不代表真实模型。拖回主变量即可复核结论。 Probabilities and outputs are fixed-seed teaching simulations, not real model output. Move the main variable back to verify the conclusion.

03 把变化拆成 4 个零件 Break the Change into Four Parts

Greedy Decoding
PART 01

候选分布 Candidate distribution

每一步都有一组下一 token 概率,线越粗表示当前概率越高。 Each step has a next-token distribution; thicker lines mean higher current probability.

PART 02

局部 argmax Local argmax

贪心只看当前一层,立刻选择概率最大的分支。 Greedy looks only at the current layer and immediately chooses its maximum.

PART 03

追加上下文 Append to context

选中的 token 加入前缀,下一步分布由这条路径决定。 The chosen token joins the prefix and determines the next distribution.

PART 04

联合概率 Joint probability

整条路径要乘每一步概率;另一条首枝较细的句子可能整体更高。 A full path multiplies step probabilities; a thinner first branch may win overall.

04 最小机制:局部最大化不等于路径乘积最大 Minimal Mechanism: Local Maxima Do Not Maximize the Path Product

Greedy Decoding
greedy: tn = argmax p(t | prefix)
示例中 0.6×0.3 = 0.18,小于另一条 0.4×0.8 = 0.32。 In the example, 0.6×0.3 = 0.18, below the alternative 0.4×0.8 = 0.32.
每步取最大 Take each maximum 走当前最粗枝 follow the thickest branch
立即追加 Append immediately 其他分支被丢弃 other branches are discarded
计算整句 Score full path 局部赢家可能落后 local winner may lose

05 边界实验:隐藏整句联合概率 Boundary Test: Hide Full-Sequence Probability

主动制造失败 Create a failure

只报每一步,误称整句最优 Report each step and falsely claim global optimality

运行贪心但遮住两条路径的概率乘积。只看到第一步 0.60 时,很容易把局部选择误报成整句最好。 Run greedy while hiding both path products. Seeing only 0.60 at step one makes it easy to misreport a local choice as the best sequence.

尚未执行。先在主交互中观察正常机制。 Not run yet. Observe the normal mechanism in the main interaction first.
每步最高,所以整句概率也最高。 Highest at each step means highest full-sequence probability. → ✓ 被丢弃分支后续可能拥有更高条件概率。 A discarded branch may have much stronger later probabilities.
贪心等于低温采样。 Greedy is the same as low-temperature sampling. → ✓ 贪心不抽样;它直接取 argmax。 Greedy does not sample; it directly takes argmax.
确定性输出就一定更准确。 Deterministic output must be more accurate. → ✓ 稳定只说明可重复,不保证内容质量。 Stability means repeatability, not guaranteed quality.
06 · 一句话带走 06 · One line to keep

贪心解码每步走当前最粗枝;展开两步就能检验:局部最高的 0.18 路径可能输给整体 0.32 的另一句。 Greedy decoding takes the thickest current branch. Expand two steps to verify that its 0.18 path can lose to another sequence at 0.32.