定性故障陳列室:文本退化死循環與事實性幻覺
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.