54 / 90

Day 54: Failure Gallery: Degenerative Loops, Hallucination, and Capstone Mastery

Examine degeneration failure modes (loops, gibberish, hallucination), contrast small models with true knowledge stores, and complete the comprehensive Generation & Evaluation exam.

Models, Pretraining & LoRA 480 active minutes (8 hours focused study)
01 120 min

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?

Independent Mastery Criterion

Accurately categorizes degenerative loops and explains the parameter capacity limit.

Authoritative Source Resources & Provenance

linking arXiv non-exclusive license / Open Access

The Curious Case of Neural Text Degeneration

Author: Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, Yejin Choi | Original Source Link ↗

Relevant Section / Range: Section 5.3 Repetition and Appendix B Example Generations

Verified Version & Date: ICLR 2020 / arXiv:1904.09751v2 (Verified: 2026-10-30)

Selection Rationale:

Primary source introducing Nucleus (Top-p) sampling and analyzing the failure of greedy decoding (loops, repetition).

Source Prerequisites:

Softmax probabilities, cumulative probability distributions from Days 25-27 and 41-42.

Safe Fallback (Offline Resilience):

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.

Hugging Face Generation Strategies Guide ↗ compared_alternative [Apache 2.0]

Practical library guide; Holtzman provides the foundational mathematical reasoning.

linking MIT

nanoGPT: sample.py autoregressive generation script

Author: Andrej Karpathy | Original Source Link ↗

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)

Selection Rationale:

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.

Source Prerequisites:

PyTorch inference, torch.multinomial, and Day 48 decoder-only forward pass.

Safe Fallback (Offline Resilience):

The generation loop is implemented in runnable local scripts.

Compared Candidate Sources & Selection Analysis (2)
llama.cpp sampling implementation ↗ compared_alternative [MIT]

C++ implementation with high performance; nanoGPT is readable Python matched to our curriculum.

PyTorch text generation tutorial ↗ compared_alternative [Modified BSD]

Encoder-decoder model; nanoGPT decoder-only autoregressive loop is the direct fit for modern LLMs.

02 120 min

Small Model Limitations vs True Knowledge Acquisition

Agent-Assisted Engineering Check

Prerequisites

Activity 54-01.

Learning Objective

Establish an honest boundary between what a small toy model learns (syntax, phonotactics, local collocations) vs what requires massive scaling (reasoning, world facts).

Instructions

Demonstrate that training a 10M parameter model on Shakespeare learns English archaic vocabulary and iambic pentameter rhythm, but cannot solve basic arithmetic or answer modern factual questions. Reject claims of 'AGI' or emergent knowledge in toy curriculum models.

Practice & Prediction Log

1. What linguistic properties does a 10M character-level or small BPE model successfully capture?
2. If a small model outputs '2 + 2 = 5', is this a bug or expected capacity limitation?
3. Formulate the attribution clause required when showcasing student model generations.

Independent Mastery Criterion

Articulates model capacity boundaries without anthropomorphic exaggerations.

Authoritative Source Resources & Provenance

linking arXiv non-exclusive license / Open Access

The Curious Case of Neural Text Degeneration

Author: Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, Yejin Choi | Original Source Link ↗

Relevant Section / Range: N/A

Verified Version & Date: ICLR 2020 / arXiv:1904.09751v2 (Verified: 2026-10-30)

Selection Rationale:

Primary source introducing Nucleus (Top-p) sampling and analyzing the failure of greedy decoding (loops, repetition).

Source Prerequisites:

Softmax probabilities, cumulative probability distributions from Days 25-27 and 41-42.

Safe Fallback (Offline Resilience):

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.

Hugging Face Generation Strategies Guide ↗ compared_alternative [Apache 2.0]

Practical library guide; Holtzman provides the foundational mathematical reasoning.

linking MIT

nanoGPT: model.py architecture implementation

Author: Andrej Karpathy | Original Source Link ↗

Relevant Section / Range: N/A

Verified Version & Date: Git master (Verified: 2026-10-30)

Selection Rationale:

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.

Source Prerequisites:

Python, PyTorch, and Day 43-45 attention fundamentals.

Safe Fallback (Offline Resilience):

Local models and classes in the curriculum mirror nanoGPT semantics directly.

Compared Candidate Sources & Selection Analysis (2)
GPT-2 TensorFlow source (OpenAI) ↗ compared_alternative [Modified MIT License]

Original legacy TensorFlow 1.x code; nanoGPT provides clean modern PyTorch equivalent.

Llama 2 / 3 PyTorch source (Meta) ↗ compared_alternative [Llama 2 Community License]

Includes advanced production features (RoPE, GQA), but nanoGPT's simplicity is ideal for the core Days 46-48 assembly.

03 120 min

Ablation Studies: Model Size, Context Length, and Sampling Parameters

Agent-Assisted Engineering Check

Prerequisites

Activities 54-01 and 54-02.

Learning Objective

Design an ablation experiment matrix comparing generation coherence across varying context lengths (T=32 vs 128) and temperatures (T=0.2, 0.8, 1.5).

Instructions

Construct an evaluation matrix testing 6 combinations of (T_context, Temperature). Record qualitative coherence scores (1 to 5) and repetition rates.

Practice & Prediction Log

1. Why does a model with context window T=32 produce incoherent long-form essays?
2. What combination of temperature and Top-p is empirically considered balanced for open-ended creative generation?
3. Describe an automated metric for measuring vocabulary repetition in generated text.

Independent Mastery Criterion

Designs controlled ablation experiments and defines objective repetition metrics.

Authoritative Source Resources & Provenance

linking arXiv.org perpetual non-exclusive license / Open Access

Attention Is All You Need

Author: Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, Illia Polosukhin | Original Source Link ↗

Relevant Section / Range: Section 6.2 Model Variations (Table 3)

Verified Version & Date: arXiv:1706.03762v7 (Verified: 2026-10-30)

Selection Rationale:

Foundational primary literature defining the Transformer architecture, multi-head attention, and scaled dot-product attention.

Source Prerequisites:

Matrix multiplication and basic neural network concepts from Days 22-24 and 34-36.

Safe Fallback (Offline Resilience):

All mathematical formulas and structural definitions are self-contained in the lesson text.

Compared Candidate Sources & Selection Analysis (2)
Illustrated Transformer (Jay Alammar) ↗ compared_alternative [CC BY-NC-SA 4.0]

High-level visual intuition, but Vaswani et al. provides the primary mathematical specifications needed for implementation.

Annotated Transformer (Harvard NLP) ↗ compared_selected_for_day46_48 [MIT]

Co-primary: PyTorch line-by-line implementation alongside the paper equations.

linking arXiv non-exclusive license / Open Access

The Curious Case of Neural Text Degeneration

Author: Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, Yejin Choi | Original Source Link ↗

Relevant Section / Range: Section 3.1 Nucleus Sampling (with Section 2.1 Text Generation Decoding Strategies)

Verified Version & Date: ICLR 2020 / arXiv:1904.09751v2 (Verified: 2026-10-30)

Selection Rationale:

Primary source introducing Nucleus (Top-p) sampling and analyzing the failure of greedy decoding (loops, repetition).

Source Prerequisites:

Softmax probabilities, cumulative probability distributions from Days 25-27 and 41-42.

Safe Fallback (Offline Resilience):

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.

Hugging Face Generation Strategies Guide ↗ compared_alternative [Apache 2.0]

Practical library guide; Holtzman provides the foundational mathematical reasoning.

04 120 min

Comprehensive Generation and Evaluation Mastery Exam

Independent Mastery Check

Prerequisites

Complete activities 54-01 through 54-03.

Learning Objective

Pass the comprehensive capstone exam covering the entire Generation, Overfitting, and Evaluation track (Days 52-54).

Instructions

Answer four multi-part questions covering sampling formulation, perplexity calculation, leakage prevention, and model limitations.

Practice & Prediction Log

1. Write the Top-p cumulative probability threshold equation.
2. Convert validation loss 1.7918 nats to exact perplexity.
3. List the 3 golden rules of data split hygiene.
4. Explain why low training loss does not guarantee coherent generation.

Independent Mastery Criterion

Flawless answers demonstrating end-to-end mastery of generation and evaluation.

Authoritative Source Resources & Provenance

linking MIT

nanoGPT: sample.py autoregressive generation script

Author: Andrej Karpathy | Original Source Link ↗

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)

Selection Rationale:

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.

Source Prerequisites:

PyTorch inference, torch.multinomial, and Day 48 decoder-only forward pass.

Safe Fallback (Offline Resilience):

The generation loop is implemented in runnable local scripts.

Compared Candidate Sources & Selection Analysis (2)
llama.cpp sampling implementation ↗ compared_alternative [MIT]

C++ implementation with high performance; nanoGPT is readable Python matched to our curriculum.

PyTorch text generation tutorial ↗ compared_alternative [Modified BSD]

Encoder-decoder model; nanoGPT decoder-only autoregressive loop is the direct fit for modern LLMs.

linking arXiv non-exclusive license / Open Access

The Curious Case of Neural Text Degeneration

Author: Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, Yejin Choi | Original Source Link ↗

Relevant Section / Range: Section 3.1 Nucleus Sampling (with Section 2.1 Text Generation Decoding Strategies)

Verified Version & Date: ICLR 2020 / arXiv:1904.09751v2 (Verified: 2026-10-30)

Selection Rationale:

Primary source introducing Nucleus (Top-p) sampling and analyzing the failure of greedy decoding (loops, repetition).

Source Prerequisites:

Softmax probabilities, cumulative probability distributions from Days 25-27 and 41-42.

Safe Fallback (Offline Resilience):

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.

Hugging Face Generation Strategies Guide ↗ compared_alternative [Apache 2.0]

Practical library guide; Holtzman provides the foundational mathematical reasoning.