Liquid AI 发布了 Antidoom,这是一种开源方法,旨在解决推理模型中的一种常见故障模式。这种故障模式就是“末日循环”。在末日循环中,模型会生成一段文本,然后反复重复这段文本。输出会一直持续,直到上下文窗口耗尽。小型推理模型更容易出现这种情况,尤其是在进行长链思考和解决难题时。
在 LFM2.5-2.6B 的早期检查点上,针对困难数学和编程提示词的补全结果中,有 10.2% 产生了重复循环。经过 Antidoom 训练后,这一比例降至 1.4%。评估分数全面改善,这完全归功于循环现象的减少。
摘要
- Antidoom 通过仅重新训练循环开始的第一个 token 来减少末日循环。
- FTPO 将概率分布在多个连贯的替代方案上,而不是只替换一个。
- LFM2.5-2.6B 的循环率从 10.2% 降至 1.4%;Qwen3.5-4B 的循环率从 22.9% 降至 1%。
- 该流程只需数小时即可运行,且整个技术栈均为开源。
什么是 Antidoom?
Antidoom 是一种针对性修复,而非广泛的采样策略变更。它会找到开始循环的确切 token,然后训练模型在该单一位置上偏好连贯的替代方案。其余的概率分布基本保持不变。
该方法改编自 Antislop。它基于代表单个补全 token 的“选择/拒绝”对进行训练。训练算法是最终 token 偏好优化(FTPO),与 DPO 类似。
该训练并未教给模型任何关于数学或编程的新知识。它只是清除了阻碍模型输出其本已能够给出的答案的循环现象。
末日循环剖析
Liquid AI 团队将末日循环归因于三种机制共同作用:
机制一:过度训练的 token 加上不确定性。某些 token 在一般情况下被选中的可能性更高。业界常见的例子包括“delve”和“testament”。Liquid AI 团队指出,这可以追溯到训练集中的合成数据。在推理轨迹中,高先验概率的延续词通常包括诸如“Wait”或“Alternatively”之类的话语标记。这些 token 本身并无坏处。它们可以标记有用的策略转变、验证步骤或分支。但当模型不确定或陷入困境时,它们反而会成为有吸引力的备选延续词。
对于早期的 LFM2.5-2.6B 检查点,最常见的循环起始 token 如下所示。
| Token | 循环起始占比 |
|---|---|
| the | 11.39% |
| So | 4.51% |
| Alternatively | 3.22% |
| Wait | 2.56% |
| But | 2.46% |
机制二:先前的上下文强化了循环。每一次重复都会将该跨度内的每个 token 推向更高的概率。段等人(Duan et al.)在其关于循环推理的研究中探讨了这一现象。他们将其与一种“V 形”注意力模式联系起来。他们发现,语义重复先于文本重复出现。
机制三:贪婪采样。推理模型通常以低温度运行,以生成稳定且可复现的推理轨迹。在温度为 0 时,始终会选择概率最高的 token。此时,一个局部强化的循环便无法退出。Liquid AI 报告称,即使在温度为 0.67 时,也会出现显著的循环现象。更低的温度会加剧这一问题。
Antidoom 如何定位故障
Antidoom 在低温度下,针对一组旨在诱发循环的提示词混合集生成补全内容。该混合集以 LiquidAI/antidoom-mix-v1.0 数据集的形式提供。当一个片段至少重复四次,且长度超过 60 个字符时,即判定为循环。
该方法随后定位到第一次重复的第一个 token。在该位置上,它获取基础模型 top-k 对数概率的备选 token。它会过滤掉短 token 或非字母数字的噪声。它最多保留 20 个合理的替代 token 作为选定 token。
每条训练数据是一个由提示词前缀、一个被拒绝的 token 以及一个或多个选定 token 组成的三元组。在训练之前,会对选定 token 和被拒绝 token 的分布进行正则化处理。否则,像 Wait、So 和 the 这样的少数“罪魁祸首”会占据主导地位,而过度抑制则会降低推理能力。
检测规则本身在代码中很容易表述。下面的代码片段是说明性的。
# A loop = a unit repeating >=4 times, spanning >=60 characters.
# Returns the index of the first token of the first repeat (the target), else None.
def find_loop(text, min_repeats=4, min_chars=60):
n = len(text)
for span in range(1, n // min_repeats + 1):
start = 0
while start + span * min_repeats <= n:
unit = text[start:start + span]
repeats = 1
pos = start + span
while text[pos:pos + span] == unit:
repeats += 1
pos += span
if repeats >= min_repeats and span * repeats >= min_chars:
return start + span # first token of the first repeat
start += 1
return None 每个检测到的循环随后会变成一条训练数据。其结构是一个简单的三元组。
# One FTPO training row, per the post's [prefix, rejected, chosen] format.
row = {
"prompt": prefix_up_to_the_loop, # text before the first repeat
"rejected": " Wait", # the single token that started the loop
"chosen": [" So", " Since", " The", " Therefore"], # up to 20 alternatives
} 最终 token 偏好优化(FTPO)
FTPO 是一种与 DPO 类似的偏好优化算法。一个训练样本包含一个提示词、一个选定的续写内容和一个被拒绝的续写内容。它的设计目的是改变少数几个 token,同时尽可能减少对模型其他部分的影响。
FTPO 与 DPO 在四个方面有所不同:
- 最终 token 训练:它只训练生成过程中处于中间位置的序列的末尾 token。
- 每个样本选取多个被选 token:它将概率分散到一组备选 token 上,从而避免用一个过拟合的 token 简单替换另一个。
- 在 logit 空间中采用类似 KL 散度的损失函数:它省略了 softmax 操作,直接在 logit 层面计算与参考分布的差异,避免对无关 token 产生压力。
- 两部分正则化:被选和被拒的 logit 可以更自由地移动,而词汇表中其余部分则受到严格约束。
在 Antidoom 实现中,模型使用 LoRA 训练一个 epoch。128 到 256 的高 LoRA 秩取得了最佳效果。训练覆盖所有注意力层和 MLP 层的投影,以及 lm_head。学习率大约在 4e-6 到 2e-5 之间。
训练采用基于 chosen_win 的早停策略,chosen_win 指的是被选 token 击败被拒 token 的样本比例。当 chosen_win 达到 0.35 时停止训练,可将 doom 循环率从 20-30% 降至 1-2%。训练时间过长往往会导致模型性能下降。
对于早期的 LFM2.5-2.6B 检查点,训练集的生成在 8 块 MI325 GPU 上耗时约一小时。随后在单块 MI325 GPU 上训练约需一到两小时。收集到 2 万对样本后即停止生成。
Antidoom 与常规修复方法的对比
| 方法 | 改变的内容 | 成本概况 | 报告的缺点 |
|---|---|---|---|
| repetition_penalty(重复惩罚) | 重新加权输出分布 | 推理时,成本低廉 | 权宜之计;可能降低性能 |
| 强化学习 | 通过奖励调整策略 | 需要校准奖励,在线 rollout 成本高昂 | 设置和计算开销大 |
| DPO(最终 token) | 每个样本一个被选 token | 离线训练 | 粗粒度的 beta 参数;仅更新单个 token |
| Antidoom(FTPO) | 首个循环 token → 多个被选 token | 约 1 小时生成(8 块 MI325)+ 1-2 小时训练(1 块 MI325) | 可能暴露新的循环;可能需要额外轮次 |
结果
训练后,早期 LFM2.5-2.6B 检查点的 doom 循环率从 10.2% 降至 1.4%。评估分数全面改善,这完全归因于循环现象的减少。
Liquid AI 团队还在 Qwen3.5-4B 上运行了该流程,该模型在推理过程中已知会出现循环。在贪婪采样下,其 doom 循环率从 22.9% 降至 1%。评估分数显著提升。
评估分数随温度升高而呈反向变化,与“死循环率”相关。训练后,两个模型在温度接近 1.0 时均出现性能下降。这是预期中的现象,因为更高温度的采样可能会倾向于选择概率较低的 token。一旦消除了循环,在测试的模型中,接近贪婪采样的方式取得了最高分数。
Liquid AI 团队指出了常见做法中的一个相关问题。认为较高温度有助于推理的观点,可能与“死循环”效应混为一谈。在他们的测试中,一旦循环消失,接近贪婪采样的方式表现最佳。
多轮处理可能有所帮助。第一轮会拒绝导致循环的 token,并重新加权以偏向其他选项。这可能会暴露出新的失败点,而第二轮则针对这些新问题进行处理。
交互式说明
用例与示例
- 端侧推理模型:像 LFM2.5 系列这样小于 1GB 的推理模型,在处理复杂提示词时可能会在推理中途陷入停滞。Antidoom 技术能够恢复因循环而损失的准确性。
- 小型编码智能体:一个 4B 参数的编码模型可能会在困难的调试追踪中陷入循环,并耗尽上下文窗口。消除循环能让它达到原本已知的修复方案。
- 智能体流水线成本控制:循环会消耗 token 直至上下文窗口耗尽。消除循环可减少长时间智能体运行中的 token 浪费和延迟。
- 训练后修复。团队在发布经过微调的推理检查点时,可以运行 Antidoom 作为清理步骤,整个过程只需几小时。
优势与挑战
优势:
- 精准:它只编辑第一个循环 token,而基本保持其余概率分布不变。
- 快速:整个流水线只需几小时即可运行完毕。
- 可量化:LFM2.5-2.6B 的循环率从 10.2% 降至 1.4%;Qwen3.5-4B 的循环率从 22.9% 降至 1%。
- 开源:生成、检测以及 FTPO 训练器均已开源发布。
- 恢复而非教授:它恢复的是模型原本就能生成的答案。
挑战:
- 它可能会暴露出新的失败点,因此有时需要多轮处理。
- 过度训练会降低模型性能,因此需要在 chosen_win 指标上提前停止。
- 已报告的结果覆盖了 LFM 检查点和 Qwen3.5-4B,两者均为小型推理模型。
- 训练后,在温度接近 1.0 时性能可能会下降。
- 每个模型都需要其自身生成的循环数据集。
Liquid AI has released Antidoom, an open-source method that targets a common failure mode in reasoning models. That failure mode is the doom loop. In a doom loop, a model emits a span. It then repeats that span again and again. The output continues until the context window is exhausted. Small reasoning models are more prone to this, especially on long thinking traces and hard problems.
On an early checkpoint of LFM2.5-2.6B, 10.2% of completions on hard math and coding prompts produced repetitive loops. After Antidoom training, that rate fell to 1.4%. Eval scores improved across the board, attributable entirely to the reduced looping.
TL;DR
- Antidoom reduces doom loops by retraining only the first loop-start token.
- FTPO spreads probability across multiple coherent alternatives, not one replacement.
- LFM2.5-2.6B looping fell 10.2% to 1.4%; Qwen3.5-4B fell 22.9% to 1%.
- The pipeline runs in a few hours, and the full stack is open source.
What is Antidoom?
Antidoom is a targeted fix, not a broad sampling change. It finds the exact token that begins a loop. It then trains the model to prefer coherent alternatives at that single position. The rest of the distribution stays largely untouched.
The method adapts Antislop. It trains on chosen/rejected pairs that represent a single completion token. The training algorithm is Final Token Preference Optimization (FTPO), which is similar to DPO.
The training teaches the model nothing new about math or code. It clears the looping that blocked answers the model could already produce.
Anatomy of a Doom Loop
Liquid AI team attributes doom loops to three mechanisms working together:
Mechanism 1: overtrained tokens plus uncertainty. Some tokens are more likely to be selected in general. Well-known examples in the wild include ‘delve’ and ‘testament.’ Liquid AI team notes this can trace back to synthetic data in the training set. In reasoning traces, high-prior continuations often include discourse markers such as ‘Wait’ or ‘Alternatively.’ These tokens are not inherently bad. They can mark a useful change of strategy, a verification step, or a branch. When the model is uncertain or stuck, they instead become attractive fallback continuations.
For an early LFM2.5-2.6B checkpoint, the most common loop-starting tokens were the following.
| Token | Share of loop starts |
|---|---|
the | 11.39% |
So | 4.51% |
Alternatively | 3.22% |
Wait | 2.56% |
But | 2.46% |
Mechanism 2: prior context reinforces the loop. Each repetition pushes every token in the span toward probability that Duan et al. study this in their work on circular reasoning. They link it to a “V-shaped” attention pattern. They find that semantic repetition precedes textual repetition.
Mechanism 3: greedy sampling. Reasoning models usually run at low temperature for stable, reproducible traces. At temperature 0, the most likely token is always selected. A locally reinforced loop then has no exit. Liquid AI reports significant looping even at temp=0.67. Lower temperatures exacerbate the problem.
How Antidoom Locates the Failure
Antidoom generates completions on a prompt mix designed to elicit looping, at low temperature. That mix ships as the LiquidAI/antidoom-mix-v1.0 dataset. A loop is detected when a section repeats at least four times, over at least 60 characters.
The method then targets the first token of the first repeat. At that position, it takes the base model’s top-k log-prob alternatives. It filters short or non-alphanumeric noise. It keeps up to 20 plausible substitutes as chosen tokens.
Each training row is a tuple of prompt prefix, one rejected token, and one or more chosen tokens. The chosen and rejected distributions are regularised before training. Otherwise a few culprits like Wait, So, and the would dominate and over-suppression would degrade reasoning.
The detection rule itself is simple to state in code. The snippet below is illustrative.
# A loop = a unit repeating >=4 times, spanning >=60 characters.
# Returns the index of the first token of the first repeat (the target), else None.
def find_loop(text, min_repeats=4, min_chars=60):
n = len(text)
for span in range(1, n // min_repeats + 1):
start = 0
while start + span * min_repeats <= n:
unit = text[start:start + span]
repeats = 1
pos = start + span
while text[pos:pos + span] == unit:
repeats += 1
pos += span
if repeats >= min_repeats and span * repeats >= min_chars:
return start + span # first token of the first repeat
start += 1
return None Each detected loop then becomes one training row. The structure is a simple tuple.
# One FTPO training row, per the post's [prefix, rejected, chosen] format.
row = {
"prompt": prefix_up_to_the_loop, # text before the first repeat
"rejected": " Wait", # the single token that started the loop
"chosen": [" So", " Since", " The", " Therefore"], # up to 20 alternatives
} Final Token Preference Optimization (FTPO)
FTPO is a preference-optimization algorithm similar to DPO. A training sample has a prompt, a chosen continuation, and a rejected continuation. It is built to change a handful of tokens, with minimal disturbance to the model otherwise.
FTPO differs from DPO in four ways:
- Final token training: It trains only the trailing token of a sequence that is midway through generation.
- Multiple chosen tokens per sample: It spreads probability across a group of alternatives, so one overtrained token is not simply replaced by another.
- KL-like loss in logit space: It omits the softmax and computes divergence from reference in logits, avoiding pressure on unrelated tokens.
- Two-part regularization: Chosen and rejected logits move more freely, while the remaining vocab stays tightly constrained.
In the Antidoom implementation, the model trains for one epoch with LoRA. High LoRA ranks of 128-256 gave the best results. Training covers all attention and MLP projections, plus lm_head. Learning rates land around 4e-6 to 2e-5.
Training uses early stopping on chosen_win, the share of samples where chosen tokens beat rejected. Stopping at chosen_win=0.35 cut doom-loop rates from 20-30% down to 1-2%. Training longer tended to degrade the model.
For the early LFM2.5-2.6B checkpoint, training-set generation took about one hour on 8x MI325 GPUs. Training then took about one to two hours on a single MI325 GPU. Generation stops after collecting 20k pairs.
How Antidoom Compares to the Usual Fixes
| Approach | What it changes | Cost profile | Reported drawback |
|---|---|---|---|
repetition_penalty | Reweights the output distribution | Inference-time, cheap | Band-aid; can degrade performance |
| Reinforcement learning | Policy via rewards | Calibrated rewards, costly online rollouts | Setup and compute overhead |
| DPO (final-token) | One chosen token per sample | Offline training | Coarse beta; updates a single token |
| Antidoom (FTPO) | First loop token → many chosen tokens | ~1h gen (8x MI325) + 1-2h train (1x MI325) | Can expose new loops; may need extra rounds |
Results
After training, the doom-looping rate on the early LFM2.5-2.6B checkpoint dropped from 10.2% to 1.4%. Eval scores improved across the board, attributable entirely to the reduction in looping.
Liquid AI team also ran the pipeline on Qwen3.5-4B, which is known to loop during reasoning. Its doom-looping rate dropped from 22.9% to 1% under greedy sampling. Eval scores increased markedly.
The eval score changed inversely with the doom-loop rate as temperature rose. After training, both models showed a performance drop near temp=1.0. This is expected, since higher-temperature sampling can favor less-preferred tokens. Once looping is removed, near-greedy sampling gave the strongest scores in the models tested.
Liquid AI team flags a related point about common practice. The belief that higher temperatures aid reasoning may be conflated with the effect of doom-looping. In their tests, once loops are gone, near-greedy sampling performs best.
Multiple rounds can help. The first round rejects loop-causing tokens and reweights toward alternatives. That can expose new failure points, which a second round then targets.
Interactive Explainer
Use Cases with Examples
- On-device reasoning models: Sub-1GB reasoning models like the LFM2.5 family can stall mid-proof on hard prompts. Antidoom recovers the accuracy those loops were costing.
- Small coding agents: A 4B coding model can loop on a hard debugging trace and burn its context window. Removing the loop lets it reach the fix it already knew.
- Agent pipeline cost control: Loops consume tokens until context exhaustion. Cutting them reduces wasted tokens and latency across long agent runs.
- Post-training repair. Teams shipping fine-tuned reasoning checkpoints can run Antidoom as a cleanup pass in a few hours.
Strengths and Challenges
Strengths:
- Targeted: it edits the first loop token and leaves the rest of the distribution largely intact.
- Fast: the whole pipeline runs in a few hours.
- Measured: LFM2.5-2.6B fell 10.2% to 1.4%; Qwen3.5-4B fell 22.9% to 1%.
- Open source: generation, detection, and the FTPO trainer are all released.
- Recovers, not teaches: it restores answers the model could already produce.
Challenges:
- It can expose new failure points, so multiple rounds are sometimes needed.
- Over-training degrades the model, so early stopping on
chosen_winis required. - Reported results cover LFM checkpoints and Qwen3.5-4B, both small reasoning models.
- Performance can drop near temp=1.0 after training.
- Each model needs its own generated looping dataset.