束搜索 · 每步第一,不一定整段第一Beam Search · The Best Next Step May Lose the Whole Route
retain top beam sequences → expand together → compare full-sequence
scores
束搜索(Beam
Search)同时保留若干高分序列分支,逐步扩展后选择整体得分较高者。它具体说明“每步最优”和“整段较优”并不相同。Beam search retains several high-scoring sequence branches, expands
them together, and selects a strong full sequence. A locally best
token need not produce the best overall path.
01 · 岔路口别太早封路01 · Do not close every side road too early
导航每个路口都只选眼前最快的方向,最后一定能走到总路程最短的路线吗?If navigation always chooses the fastest-looking turn, is the full
trip guaranteed to be shortest?
Ψ4
02切换 beam 1 / 2 / 4,比较保留树与计算量Compare Retained Trees and Compute at Beam 1 / 2 / 4
高阶 · 路径联合分数expert · joint path score
状态 AMetric A
—
—
状态 BMetric B
—
—
状态 CMetric C
—
—
所有概率、得分与输出均为固定种子的教学模拟,不代表真实模型。拖回主变量即可复核结论。All probabilities, scores, 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
Beam Search
BRANCH
候选分支Candidate branches
每一步扩展当前保留的所有序列。Expands every sequence currently retained at each step.
BEAM
保留宽度Retention width
beam 决定每层最多留下几条路径。Beam sets the maximum number of paths kept per layer.
SCORE
联合得分Joint score
比较整段 token 概率组合,不只看一步。Compares scores across the complete token sequence, not one
step.
COST
计算代价Compute cost
宽度越大,同步扩展和内存开销越高。A wider beam requires more expansions and memory.
04最小机制:主交互能逐项验证Minimal Mechanism: Verify Each Link in the Interaction
MECHANISM
kept_step = top_beam(partial_sequence_score)
主交互固定同一棵玩具树;beam
只改变每层保留数量,计算量条因此同步增长。The toy tree stays fixed. Beam changes only retained paths per
layer, so the compute bar rises with it.
扩展Expand每条路径接候选add candidates to each path
排序Rank按部分序列得分by partial-sequence score
截留Retain只留 beam 条keep only beam paths
05把 beam 退到
1,局部赢家提前封死另一条路Reduce Beam to 1 and Prune the Better Full Route
主动制造失败Create a failure
边界实验Boundary experiment
宽度 1
每层只留一条路,等同局部贪心。紫色路径开头不是第一,却有更高整句得分。Width 1 retains a single path at every layer, equivalent to local
greediness. The violet route starts behind but ends with a
higher full-sequence score.
尚未执行。先在主交互中观察正常机制。Not run yet. Observe the normal mechanism in the main interaction
first.
✗ beam 越宽,输出一定越好。A wider beam always produces better output.→ ✓ 它可能提高搜索得分,也会增加成本并偏爱通用句。It may raise search score, but costs more and can favor generic
phrasing.
✗ beam 2 就会保留所有可能。Beam 2 preserves every possibility.→ ✓ 每层仍会剪枝,只是比 beam 1
多留一条。Pruning still happens at every layer; it merely keeps one more
path.
✗ 最终得分等于最后一个 token 的得分。Final score is the last token score.→ ✓ 它来自整段序列的联合或累计得分。It comes from a joint or accumulated score across the
sequence.
06 · 一句话带走06 · One line to keep
束搜索用 beam
同时保留多条部分序列,能避开局部最优陷阱,但宽度越大,扩展计算量也越高。Beam search retains multiple partial sequences to escape local
optima, but wider beams require more expansion work.