Repository navigation
Add the language models chapter (week 7) - #25
Conversation
A character-level lecture on the opening of Coriolanus, from Karpathy's tiny Shakespeare text: the chain rule gives the probability of a string, a bigram model with add-one smoothing counts pairs, perplexity scores the models on held-out text, a GRU trained with teacher forcing beats the bigram model, and sampling at three temperatures trades real words for variety. Each conclusion the prose draws is guarded by an assert, and the page takes about 15 seconds of CPU training. Adds the page to the site config and the week 7 calendar cell, and cites Jurafsky and Martin, Hinton et al. on temperature, and Karpathy's char-rnn data and blog post. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019xfc9mZMigPGwaFDxGrYrf
…thread-yay5qq-language-models
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Split add-one smoothing into its own definition and example, after the exercise on unseen pairs that motivates it, so the bigram model is defined by its counting estimate alone. Add exercises before teacher forcing (what the targets are) and temperature (dividing the logits), add tools/get-shakespeare.py to rebuild the data copy and say in the prose that it is a copy, and move the model code under its own heading. Score the drawn words without the prompt, assert the claims about word shares and the bigram average, take the temperatures in the table from the code, say "distinct characters", fix two pronouns, use the shared probability and vector macros, give the perplexity's other forms and the n-gram and token terms, cite Jurafsky and Martin and Hinton et al. by section, and put each reading beside the content it supports. The SLP3 entry is now @misc, since the draft has no DOI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019xfc9mZMigPGwaFDxGrYrf
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Write the perplexity formula with the average and log macros, move the two reading callouts into subfiles of their own, and break the lines the review found holding two clauses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019xfc9mZMigPGwaFDxGrYrf
|
Responses to the review of cd6dc00, fixed in 4eeb249:
Posted by Claude Code (AI agent) --- not written by a human. Generated by Claude Code |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Cross-model review before merge. I ran gpt-oss:120b on Ollama cloud twice over this PR's changes since its previous cross-model review (
Posted by Claude Code (AI agent) --- not written by a human. Generated by Claude Code |
…-yay5qq-language-models
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019xfc9mZMigPGwaFDxGrYrf
|
I addressed the review of cca2e5a in 6c288ff. In The temperature asserts stay, for the reason in the previous reply. The SLP3 section numbers were checked against the PDF. Posted by Claude Code (AI agent) --- not written by a human. Generated by Claude Code |
|
Claude finished review — View run I fetched PR 25 live just now. It is open, not a draft and not merged, and its head is still Review of Morrison-Lab/dds PR 25 at 6c288ffThe only commit since the last round ( The last posted verdict was Ready for merge, at VerdictReady for merge. The new commit is a formatting-only line break and adds no findings. Structured Review Data (JSON){
"schema_version": "1.1",
"reviewer": "claude",
"commit_sha": "6c288ff9345b49c4a85cd222157fa85c180bdf5d",
"verdict": "CLEAN",
"findings": [],
"detailed_assessment": "The only change in range is a clause-level line break in _perplexity_def.qmd that renders identically and adds no math or code.",
"holistic_assessment": "The change is a scoped follow-up to the earlier line-break findings, with no integration, regression or graded-content risk; Python chunks were not executed here."
}Stopping Point: Clean stopping point reached --- session done; UMS executed; no follow-up items pending Reviewed commit: 6c288ff |
2026-10-30 16:35 UTC |
Important
Stacked on #24 (recurrent networks), which is stacked on #23. Merge #23, then #24, then this one, each with a merge commit, retargeting each to
mainas its base merges.Adds
chapters/language-models.qmd, the week 7 Monday lecture on language modeling (plan module M5). It works on the opening of Coriolanus, the first 100,000 characters of Karpathy's tiny Shakespeare text. The local copy ischapters/data/shakespeare.txt, andtools/get-shakespeare.pyrebuilds it. The text is public domain; char-rnn is MIT-licensed.What the page does
"the"#def-language-modelqs followed byu#def-bigram-model(counting estimate)#def-add-one-smoothing#def-perplexity#def-teacher-forcing#def-temperature_quarto-website.yml: the render list, navbar and sidebar.chapters/calendar.qmd: the week 7 Monday cell.references.bib: Jurafsky and Martin, SLP3 draft of Aug 19, 2026, sections 3.1.2, 3.3 and 3.6.1, each checked against the PDF; Hinton et al. 2015, section 2, eq. 1, checked; Karpathy's char-rnn repository and blog post.Graded material
I searched dlg's
exercises/,Homework/andQuizzes/for perplexity, bigram, smoothing, temperature, teacher forcing, language model, Shakespeare and char-rnn, and found nothing.Homework 3 (Brian's Lab 5, an LSTM language model) is not written yet.
This page contains a complete character-level recurrent language model: training with teacher forcing, perplexity, and sampling with temperature. Swapping
nn.GRUfornn.LSTMwould answer an LSTM character model on this text, so Homework 3 needs to differ in data, token level or what it asks for. I have flagged this to Ezra.Checks
check_example_after_def.py --fail,check_list_markers.pyandtyposlocally; all clean on the chapter's files.\Prf,\condPr,\hPrand\vzmacros.\expfis defined inlatex-macros/macros.qmd, line 432.@sol-gru-lmcomes before the exercise that cites it.check-doisfails onlecun1998gradient, which IEEE answers with status 202 (see Add the convolutional networks chapter (week 5) #23). The SLP3 entry is now@misc, so the checker no longer asks it for a DOI.🤖 Generated with Claude Code
https://claude.ai/code/session_019xfc9mZMigPGwaFDxGrYrf