Qualitative Failure Gallery: Degenerative Loops and Hallucinations
Agent-Assisted Engineering Check
Prerequisites
Day 52 Sampling Strategies and Day 53 Evaluation Protocols.
Learning Objective
Catalog the three primary qualitative failure modes of autoregressive generation: repetitive loops, entropy explosion (gibberish), and factual hallucination.
Instructions
Produce and analyze: (1) Greedy loop: 'The president said that the president said that...'; (2) High temperature (T=3.0): incoherent character garbage; (3) Confident hallucination: model emits grammatically fluent but completely fabricated historical claims.
Practice & Prediction Log
1. What mathematical mechanism drives a greedy decoder into an infinite repetitive loop?
2. Why does increasing temperature beyond 2.0 destroy syntax and grammatical structure?
3. Why cannot small language models (e.g. <50M parameters) be trusted as factual databases?
In greedy decoding, once a common phrase repeats, its autoregressive self-reinforcement score increases monotonically.
Greedy loops occur because language models score their own outputs as new context; repeating phrases increases the transition probability of the repeat, creating a positive feedback attractor. Extreme temperature flattens logits so improbable syntax transitions are chosen frequently. Small models lack parameter capacity to store factual knowledge and merely simulate surface statistical fluency.
Accurately categorizes degenerative loops and explains the parameter capacity limit.
Authoritative Source Resources & Provenance
The Curious Case of Neural Text Degeneration
Relevant Section / Range: Section 5.3 Repetition and Appendix B Example Generations
Verified Version & Date: 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.
Compared Candidate Sources & Selection Analysis (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
Relevant Section / Range: sample.py: temperature and top_k settings passed to model.generate (model.py: GPT.generate)
Verified Version & Date: 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.
Compared Candidate Sources & Selection Analysis (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.