42 / 90

Day 42: Loss, Training Discipline, and Weekly Consolidation

Turn softmax probabilities into the cross-entropy loss, observe a disciplined training loop with fixed splits and seeds, confront overfitting and numerical-instability counterexamples honestly, then close the week with an independent retrieval assessment. Review time is counted inside the 480-minute ledger.

Models & Training 480 active minutes (8 hours focused study)
01 120 min

Cross-Entropy Loss: From Probabilities to a Scalar Surprisal

Agent-Assisted Engineering Check

Prerequisites

Day 41 forward pass and softmax; natural logarithms.

Learning Objective

Define the negative log-likelihood loss, compute it for a worked distribution, and interpret it against the uniform baseline.

Instructions

Required work: for target index t the loss is L = -ln p_t. Yesterday's forward pass produced p = [0.229291, 0.209107, 0.306433, 0.255169] for context ('a','b') whose true next symbol is 'c' (index 3). Compute L, then compare it with the uniform baseline ln(4) = 1.386294. Decide whether this model is better than chance. Optional work: express L in bits by switching to log2.

Practice & Prediction Log

1. L = -ln(0.255169) = ?
2. For logits z = [1.0, 0.5, -0.5] over 3 classes with target index 0, compute the softmax probabilities and the NLL.
3. What does perplexity exp(L) mean in this example?

Independent Mastery Criterion

Both losses computed to 4+ decimals, the uniform-baseline comparison stated, and perplexity interpreted as an effective vocabulary size.

Authoritative Source Resources & Provenance

linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

makemore: Character-level language models on names.txt

Author: Andrej Karpathy | Original Source Link ↗

Relevant Section / Range: Loss computation segment: negative log-likelihood over the minibatch

Verified Version & Date: Repository state verified 2026-10-30; lecture published 2022

Selection Rationale:

Standard beginner walkthrough of the Bengio-style MLP language model; the MIT-licensed reference implementation pairs with a stepwise derivation that matches the Days 40-42 worked numbers exactly.

Source Prerequisites:

Python basics, matrix multiplication, and the Day 37-39 tokenization and n-gram context

Safe Fallback (Offline Resilience):

All forward-pass arithmetic, shapes, parameter counts, and loss values are reproduced as original hand-worked examples in the lesson text; no video, subtitle, or transcript is required.

Compared Candidate Sources & Selection Analysis (3)
Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

linking JMLR open access (author-retained copyright)

A Neural Probabilistic Language Model

Author: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | Original Source Link ↗

Relevant Section / Range: Section 2 (training criterion: maximizing the log-likelihood, equivalently minimizing NLL)

Verified Version & Date: JMLR Volume 3 (2003); verified 2026-10-30

Selection Rationale:

The original paper introducing jointly learned word feature vectors and the neural probabilistic language model; grounds the curriculum's embedding and MLP derivations in the primary literature.

Source Prerequisites:

Probability basics and linear algebra

Safe Fallback (Offline Resilience):

Every worked derivation in the lessons is self-contained and offline-complete; the paper is further reading only.

Compared Candidate Sources & Selection Analysis (3)
Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

Selected jointly: Makemore reproduces this architecture at character scale with MIT-licensed code; the paper supplies the original formalism and the n-gram comparison framing.

Strong textbook coverage of n-grams through neural LMs; kept as secondary reading because the primary derivation follows the original paper's notation.

Foundational for embedding geometry but trains on context-prediction objectives rather than the full next-token probabilistic model studied this week; revisited in later representation blocks.

02 120 min

Training Loop Observation: Loss, Gradient, Update with Fixed Splits

Independent Mastery Check

Prerequisites

Complete the previous activity; use the listed recovery link if blocked.

Learning Objective

Describe one training step (forward -> loss -> backward -> update) and the role of fixed train/dev/test splits and seeds; predict the direction of loss movement without being promised any threshold.

Instructions

Required work: recall the gradient step from Days 34-36. One iteration draws a minibatch of (context, target) pairs, runs the forward pass, averages the NLL, backpropagates, and updates every parameter by p <- p - lr * dL/dp. Record a predicted loss-curve shape, then describe what a fixed 80/10/10 train/dev/test split and a fixed seed guarantee for comparisons. Optional work: predict what a learning rate that is too large does to the curve.

Practice & Prediction Log

1. List the four stages of one training step in order.
2. If dev loss rises while train loss keeps falling, what does that signal?
3. Why do a fixed seed and split make two model variants honestly comparable?

Independent Mastery Criterion

The learner orders the four stages, names overfitting as the dev-rises explanation, and states that fixed seeds/splits give comparability - without inventing loss guarantees.

Authoritative Source Resources & Provenance

linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

makemore: Character-level language models on names.txt

Author: Andrej Karpathy | Original Source Link ↗

Relevant Section / Range: Training loop segment: minibatch SGD, learning-rate schedule, train/dev split discipline

Verified Version & Date: Repository state verified 2026-10-30; lecture published 2022

Selection Rationale:

Standard beginner walkthrough of the Bengio-style MLP language model; the MIT-licensed reference implementation pairs with a stepwise derivation that matches the Days 40-42 worked numbers exactly.

Source Prerequisites:

Python basics, matrix multiplication, and the Day 37-39 tokenization and n-gram context

Safe Fallback (Offline Resilience):

All forward-pass arithmetic, shapes, parameter counts, and loss values are reproduced as original hand-worked examples in the lesson text; no video, subtitle, or transcript is required.

Compared Candidate Sources & Selection Analysis (3)
Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

linking JMLR open access (author-retained copyright)

A Neural Probabilistic Language Model

Author: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | Original Source Link ↗

Relevant Section / Range: Sections 3-4 (parameter optimization and experimental methodology)

Verified Version & Date: JMLR Volume 3 (2003); verified 2026-10-30

Selection Rationale:

The original paper introducing jointly learned word feature vectors and the neural probabilistic language model; grounds the curriculum's embedding and MLP derivations in the primary literature.

Source Prerequisites:

Probability basics and linear algebra

Safe Fallback (Offline Resilience):

Every worked derivation in the lessons is self-contained and offline-complete; the paper is further reading only.

Compared Candidate Sources & Selection Analysis (3)
Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

Selected jointly: Makemore reproduces this architecture at character scale with MIT-licensed code; the paper supplies the original formalism and the n-gram comparison framing.

Strong textbook coverage of n-grams through neural LMs; kept as secondary reading because the primary derivation follows the original paper's notation.

Foundational for embedding geometry but trains on context-prediction objectives rather than the full next-token probabilistic model studied this week; revisited in later representation blocks.

03 120 min

Counterexamples: Overfitting, Numerical Instability, and the Bigram Baseline

Agent-Assisted Engineering Check

Prerequisites

Complete the previous activity; use the listed recovery link if blocked.

Learning Objective

Produce honest counterexamples: memorization on tiny data, exp overflow in softmax, and a simple counting baseline that can beat the untrained network.

Instructions

Required work: three counterexamples. (1) Memorization: on a 4-symbol toy corpus the model can drive train NLL toward 0 while dev NLL stays near ln(4) = 1.386294. (2) Instability: logits [1000,999,998] - unshifted exp overflows float64, while the shifted softmax is [0.665241, 0.244728, 0.090031]. (3) Baseline: if 'b' is followed by 'c' in 3 of 4 occurrences in the corpus, a bigram gives p(c|b) = 0.75. Optional work: describe one situation where even a trained MLP loses to the bigram.

Practice & Prediction Log

1. Reproduce the shifted-softmax distribution for logits [1000,999,998].
2. Compute the bigram NLL for p(c|b) = 0.75 and for an unseen pair with p = 0.25.
3. Write one honest sentence comparing the untrained MLP with the bigram baseline.

Independent Mastery Criterion

All three counterexamples reproduced with correct numbers, plus an honest comparison sentence covering both memorization limits and the conditions for a real advantage.

Authoritative Source Resources & Provenance

linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

makemore: Character-level language models on names.txt

Author: Andrej Karpathy | Original Source Link ↗

Relevant Section / Range: Overfitting and split evaluation segments; comparison with the bigram counting baseline

Verified Version & Date: Repository state verified 2026-10-30; lecture published 2022

Selection Rationale:

Standard beginner walkthrough of the Bengio-style MLP language model; the MIT-licensed reference implementation pairs with a stepwise derivation that matches the Days 40-42 worked numbers exactly.

Source Prerequisites:

Python basics, matrix multiplication, and the Day 37-39 tokenization and n-gram context

Safe Fallback (Offline Resilience):

All forward-pass arithmetic, shapes, parameter counts, and loss values are reproduced as original hand-worked examples in the lesson text; no video, subtitle, or transcript is required.

Compared Candidate Sources & Selection Analysis (3)
Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

linking JMLR open access (author-retained copyright)

A Neural Probabilistic Language Model

Author: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | Original Source Link ↗

Relevant Section / Range: Section 4 (comparison with n-gram baselines and generalization discussion)

Verified Version & Date: JMLR Volume 3 (2003); verified 2026-10-30

Selection Rationale:

The original paper introducing jointly learned word feature vectors and the neural probabilistic language model; grounds the curriculum's embedding and MLP derivations in the primary literature.

Source Prerequisites:

Probability basics and linear algebra

Safe Fallback (Offline Resilience):

Every worked derivation in the lessons is self-contained and offline-complete; the paper is further reading only.

Compared Candidate Sources & Selection Analysis (3)
Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

Selected jointly: Makemore reproduces this architecture at character scale with MIT-licensed code; the paper supplies the original formalism and the n-gram comparison framing.

Strong textbook coverage of n-grams through neural LMs; kept as secondary reading because the primary derivation follows the original paper's notation.

Foundational for embedding geometry but trains on context-prediction objectives rather than the full next-token probabilistic model studied this week; revisited in later representation blocks.

04 120 min

Weekly Consolidation: Independent Retrieval and End-to-End Assessment

Independent Mastery Check

Prerequisites

Activities 42-01 through 42-03; review of Days 40-41 as needed.

Learning Objective

Retrieve the entire Days 40-42 pipeline unaided, recompute the loss for a held-out context, and record recovery links for every missed idea.

Instructions

Required work: closed book. Sketch the pipeline index -> C rows -> concat -> W1/b1 -> tanh -> W2/b2 -> softmax -> NLL with every shape. Then compute the loss for context ('b','a') with true next symbol 'a' (index 1) using Day 41's probabilities. Complete the knowledge check. For anything missed, record which of Day 40, Day 41, or recovery link Day 35 you will revisit. Optional work: re-derive the uniform baseline for V=27.

Practice & Prediction Log

1. Loss for p = [0.290410, 0.237875, 0.220627, 0.251087] with target index 1.
2. From memory, rebuild the tiny model's parameter ledger (total 39).
3. State the two conditions that make a neural language model honestly better than a bigram.

Objective Knowledge Check: Loss, Training & Honest Comparison

Answer the following diagnostic questions to verify your understanding. Select your declared assistance condition before submitting.

Declared Assistance Condition

Note: AI-free work is an honest declared condition, not claimed surveillance.

1.

A model with NLL below ln(4) = 1.386294 on a 4-symbol task is, on average:

2.

Train NLL near 0 with dev NLL near 1.39 on a V=4 task most likely indicates:

3.

Why do we fix the random seed and the train/dev/test split before comparing two models?

Attempt History & Evidence

    Independent Mastery Criterion

    Unaided loss 1.436009 with the ledger rebuilt, the pipeline sketched with correct shapes, honest better-than-baseline conditions stated, and recovery links named for any gap.

    Authoritative Source Resources & Provenance

    linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

    makemore: Character-level language models on names.txt

    Author: Andrej Karpathy | Original Source Link ↗

    Relevant Section / Range: Complete makemore MLP lecture: embedding lookup through loss evaluation

    Verified Version & Date: Repository state verified 2026-10-30; lecture published 2022

    Selection Rationale:

    Standard beginner walkthrough of the Bengio-style MLP language model; the MIT-licensed reference implementation pairs with a stepwise derivation that matches the Days 40-42 worked numbers exactly.

    Source Prerequisites:

    Python basics, matrix multiplication, and the Day 37-39 tokenization and n-gram context

    Safe Fallback (Offline Resilience):

    All forward-pass arithmetic, shapes, parameter counts, and loss values are reproduced as original hand-worked examples in the lesson text; no video, subtitle, or transcript is required.

    Compared Candidate Sources & Selection Analysis (3)
    Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

    The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

    Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

    Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

    3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

    Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

    linking JMLR open access (author-retained copyright)

    A Neural Probabilistic Language Model

    Author: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | Original Source Link ↗

    Relevant Section / Range: Sections 1-4 (complete model and evaluation overview)

    Verified Version & Date: JMLR Volume 3 (2003); verified 2026-10-30

    Selection Rationale:

    The original paper introducing jointly learned word feature vectors and the neural probabilistic language model; grounds the curriculum's embedding and MLP derivations in the primary literature.

    Source Prerequisites:

    Probability basics and linear algebra

    Safe Fallback (Offline Resilience):

    Every worked derivation in the lessons is self-contained and offline-complete; the paper is further reading only.

    Compared Candidate Sources & Selection Analysis (3)
    Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

    Selected jointly: Makemore reproduces this architecture at character scale with MIT-licensed code; the paper supplies the original formalism and the n-gram comparison framing.

    Strong textbook coverage of n-grams through neural LMs; kept as secondary reading because the primary derivation follows the original paper's notation.

    Foundational for embedding geometry but trains on context-prediction objectives rather than the full next-token probabilistic model studied this week; revisited in later representation blocks.