最大输出长度(Maximum Output Length)是在生成 token
达到设定上限时强制停止的外部边界。它与上下文窗口、EOS
是三种不同机制。
Maximum Output Length is an external boundary that forces generation to
stop after a set number of output tokens. It differs from the context
window and EOS.
01 · 广播被定时器切断
01 · A broadcast cut by a timer
一句话停在逗号后,是作者自然写完,还是计时器突然拔了插头?
If a sentence stops after a comma, did the writer finish—or did a
timer pull the plug?
…|✂
02
拖长度上限,区分硬截断与自然 EOS
Move the Limit and Distinguish Hard Cut from Natural EOS
两种停止标记
Two stop labels
状态 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
Maximum Output Length
PART 01
输出计数
Output counter
只计算本次新生成的
token,不等同于输入上下文长度。
It counts newly generated tokens, not the input context
length.
PART 02
长度上限
Length limit
应用在生成循环外部,到格数就强制停止。
It is applied outside the generation loop and forces a stop at
the cap.
PART 03
EOS
EOS
模型在候选中选择结束
token,属于自然停止机制。
The model selects an end token from candidates, producing a
natural stop.
PART 04
停止标记
Stop label
系统必须区分“被截断”与“自然结束”,下游才能正确处理。
Systems must distinguish “truncated” from “natural EOS”
so downstream logic can act correctly.
04
最小机制:谁先到,就由谁触发停止
Minimal Mechanism: Whichever Arrives First Stops Generation
Maximum Output Length
stop = EOS selected ∨ generated_count ≥ max_tokens
本页把自然 EOS 固定在第 6 格;长度上限若小于
6,就明确标记被截断。
This page fixes natural EOS at slot 6. Any limit below 6 is
explicitly labeled truncated.
生成一格
Generate a slot
计数加 1
counter increments
比较两边界
Compare boundaries
EOS 或上限先到
EOS or limit arrives first
写停止原因
Record reason
自然结束或被截断
natural or truncated
05
边界实验:在 EOS 前把生成带剪断
Boundary Test: Cut the Strip Before EOS
主动制造失败
Create a failure
短,不代表完整
Short does not mean complete
把最大输出长度设为 3,而自然 EOS 在第 6
格。生成带被外部剪刀切断,必须显示“被截断”。
Set maximum output length to 3 while natural EOS sits at slot 6.
The external scissors cut the strip and must label it
truncated.
尚未执行。先在主交互中观察正常机制。
Not run yet. Observe the normal mechanism in the main interaction
first.
✗
达到最大长度就是自然说完。
Reaching max length means a natural finish.
→ ✓
这是外部强制停止,可能截在半句。
It is an external forced stop and may cut mid-sentence.
✗
最大输出长度等于上下文窗口。
Maximum output length equals context window.
→ ✓
一个限制新输出,一个限制一次计算可接收范围。
One caps new output; the other caps what one computation can
receive.
✗
只要提高上限,回答就一定更好。
A higher cap always improves answers.
→ ✓
更长只提供空间,也会增加成本和跑偏机会。
More room also increases cost and room to drift.
06 · 一句话带走
06 · One line to keep
最大输出长度是外部强制边界;拖到 EOS
之前会显示“被截断”,让它与自然选择结束 token
明确分开。
Maximum output length is an external hard boundary. Move it before
EOS to see “truncated,” clearly separated from selecting the
end token naturally.