定性故障陈列室:文本退化死循环与事实性幻觉
Agent 辅助工程分析
前置要求
第 52 日采样策略与第 53 日评估流程规范。
学习目标
归纳自回归文本生成的三大典型定性故障:复读机式死循环、极端熵值乱码、以及语法流利的事实性幻觉。
操作指引
剖析三大案例:(1) 贪心死循环:'The president said that the president said that...'; (2) 极高温度 (T=3.0) 产生的无序字符乱码;(3) 自信的幻觉:语法无瑕疵但完全捏造虚假历史事实。
自主演练与记录
1. 导致贪心解码陷入无限死循环的数学反馈回路是什么?
2. 为什么将采样温度调高到 2.0 以上会破坏语法结构与可读性?
3. 为什么 50M 参数以下的小模型绝不能作为事实知识库使用?
在贪心解码下,短语一旦被生成便成为新的自回归输入,自我强化该短语后续的概率,形成正反馈吸引子。
贪心死循环源于自回归的正反馈回路:模型以自身生成内容为输入,重复短语使得该短语后续的转移概率进一步增大。过高温度使所有词元的采样概率趋向均匀,破坏了基本的语法转移规律。小模型缺乏足够的参数容量存储事实知识,仅能模拟浅层的统计语感。
能准确归纳生成故障的数学机理,指认小模型的参数容量天花板。
权威源资源与权利证明
The Curious Case of Neural Text Degeneration
对应章节 / 时间戳: Section 5.3 Repetition and Appendix B Example Generations
验证版本与日期: ICLR 2020 / arXiv:1904.09751v2 (Verified: 2026-10-30)
Primary source introducing Nucleus (Top-p) sampling and analyzing the failure of greedy decoding (loops, repetition).
Softmax probabilities, cumulative probability distributions from Days 25-27 and 41-42.
Top-p truncation algorithms and worked probability cutoffs are completely explained in the lesson.
对比候选资源与选型分析 (2)
Introduces top-k sampling; Holtzman et al. dynamic nucleus threshold is compared directly against top-k.
Practical library guide; Holtzman provides the foundational mathematical reasoning.
nanoGPT: sample.py autoregressive generation script
对应章节 / 时间戳: sample.py: temperature and top_k settings passed to model.generate (model.py: GPT.generate)
验证版本与日期: Git master (Verified: 2026-10-30)
Compact historical code reference for the named implementation functions; CS336 spring2025 provides the lead component exercises. Do not infer top-p, atomic persistence or cloud budget enforcement from nanoGPT.
PyTorch inference, torch.multinomial, and Day 48 decoder-only forward pass.
The generation loop is implemented in runnable local scripts.
对比候选资源与选型分析 (2)
C++ implementation with high performance; nanoGPT is readable Python matched to our curriculum.
Encoder-decoder model; nanoGPT decoder-only autoregressive loop is the direct fit for modern LLMs.