Understanding How AI Language Models Work
Understand what a language model really does, from tokens and attention to alignment, well enough to explain it and judge it.
This course is for members
$9 unlocks every course in the library, this one included, plus a credit to build a topic of your own and at least 10 new courses every month.
What you will learn about Understanding How AI Language Models Work
The 7-day sprint
- A Language Model Is a Probability Machine. A language model assigns probabilities to sequences of words, and it generates text by repeatedly predicting the next piece and feeding its own output back in.
- Tokens, Not Words. Models do not read letters or words; they read tokens, subword pieces produced by an algorithm like byte pair encoding, and that choice explains many of their odd failures.
- Embeddings and Attention. Each token becomes a vector, and attention lets every position pull in information from other positions by matching a query against keys and then mixing the corresponding values.
- The Transformer Block, Stacked. A transformer is a stack of identical blocks, each combining multi-head self-attention with a position-wise feed-forward layer, plus an explicit injection of position information.
- Pretraining, Scale, and In-Context Learning. Pretraining on enormous text with next-token prediction, at large enough scale, produces a model that can be steered by examples in the prompt alone, with no gradient updates.
- Alignment After Pretraining. A pretrained model predicts plausible text, not helpful text, so a second training phase using human demonstrations and human preference rankings teaches it to follow intent.
- Evaluating and Governing What You Built On. Judging a language model means knowing what its scores can and cannot prove, and using a published risk framework instead of your own intuition about what could go wrong.
The 80/20: the 6 concepts that matter most
- Autoregressive next-token prediction
- Tokens and subword vocabularies
- Attention with queries, keys and values
- Scale, pretraining, and in-context learning
- Alignment through human feedback
- Confabulation and the limits of evaluation
The core idea, explained like you are 5
A language model is a next-piece predictor: it turns everything written so far into a probability for every possible next piece of text, picks one, adds it to the text, and repeats.
Then the quiz and the ladder
10 questions that correct you when you are wrong, and beginner, intermediate, advanced levels, each with a practical exercise.
Created Sep 13, 2026. No mistakes have been reported by learners.
Written from these sources
- [1706.03762] Attention Is All You Need, arxiv.org. day 4 transformer architecture and BLEU figures.
- Attention is all you need | Proceedings of the 31st International Conference on Neural Information Processing Systems, dl.acm.org. day 4 canonical citation and 41.0 BLEU version.
- Attention Is All You Need Ashish Vaswani∗ Google Brain avaswani@google.com, papers.neurips.cc. day 3 and 4 ablations, positional encoding, layer counts.
- BERT vs GPT for financial engineering, arxiv.org. day 1 autoregressive generation description.
- MTLHealth: A Deep Learning System for Detecting Disturbing Content in Student Essays, arxiv.org. day 3 and 4 attention definition and recurrence motivation.
- A$^2$FM: An Adaptive Agent Foundation Model for Tool-Aware Hybrid Reasoning, arxiv.org. day 4 correction of encoder layer count.
- Speech and Language Processing (3rd ed. draft), web.stanford.edu. DPO in chapter 9, Unicode, version discipline.
- Speech and Language Processing. Daniel Jurafsky & James H. Martin., web.stanford.edu. day 3 query key value origin in memory networks.
- Stanford CS 224N | Natural Language Processing with Deep Learning, web.stanford.edu. course scope framing for sprint structure.
- CS224n: Natural Language Processing with Deep Learning 1, web.stanford.edu. day 1 formal language model definition.
- Natural Language Processing with Deep Learning CS224N/Ling284, web.stanford.edu. day 1 cloze examples and perplexity.
- [2005.14165] Language Models are Few-Shot Learners, arxiv.org. day 5 GPT-3 scale, capabilities, and limits.
- Language Models are Few-Shot Learners, papers.nips.cc. day 5 definition of in-context learning.
- Language Models are Few-Shot Learners Tom B. Brown∗ Benjamin Mann∗ Nick Ryder∗, arxiv.org. day 7 contamination and benchmark caution.
- Language Models are Few-Shot Learners Tom B. Brown∗ Benjamin Mann∗ Nick Ryder∗, proceedings.neurips.cc. day 5 inference energy cost figure.
- Review — GPT-3: Language Models are Few-Shot Learners | by Sik-Ho Tsang | Medium, sh-tsang.medium.com. day 4 GPT-3 sparse attention and compute.
- GPT-3 explained — Language Models Are Few-Shot Learners, intuitivepapers.ai. day 5 and pareto scaling law framing.
- Subword Regularization: Improving Neural Network Translation Models with Multiple Subword Candidates, arxiv.org. day 2 BPE algorithm and vocabulary tradeoff.
- Entropy-Driven Pre-Tokenization for Byte-Pair Encoding, arxiv.org. day 2 BPE origin, greedy merge, coverage guarantee.
- Exploring Benefits of Transfer Learning in Neural Machine Translation, arxiv.org. day 2 out-of-vocabulary problem and merge mechanics.
- Medical Concept Normalization in a Low-Resource Setting, arxiv.org. day 2 merge count as hyperparameter.
- Byte Pair Encoding (BPE): From Data Compression to GPT-2 Tokenization | by Daksh Rathi | Medium, medium.com. day 2 byte-level BPE note.
- [2203.02155] Training language models to follow instructions with human feedback, arxiv.org. day 6 alignment thesis and InstructGPT results.
- Training language models to follow instructions with human feedback, proceedings.neurips.cc. day 6 three-stage RLHF, alignment tax, failure modes.
- Aligning language models to follow instructions | OpenAI, openai.com. day 6 plain-language alignment framing.
- InstructionCP: A fast approach to transfer Large Language Models into target language, arxiv.org. day 6 DPO and PPO component naming.
- AI Risk Management Framework | NIST, nist.gov. day 7 AI RMF and 600-1 release details.
- NIST AI Public Working Groups, airc.nist.gov. day 7 working group size, 13 risks, 400 actions.
- NIST Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile - Digital Government Hub, digitalgovernmenthub.org. day 7 confabulation term and four functions.
- NIST Artificial Intelligence Risk Management Framework | AI Trust and Safety User Guide, the-ai-alliance.github.io. day 7 cross-sectoral profile definition.
- NIST releases its Generative Artificial Intelligence Profile: Key points | DLA Piper, dlapiper.com. day 7 profile as sector-agnostic companion.
- NIST AI Risk Management Framework: Agentic Profile – Lab Space, labs.cloudsecurityalliance.org. day 7 agentic risk boundary and RMF 1.0 date.
- 20250527 Crosswalk NIST 600 1 IMDA AI Verify, airc.nist.gov. day 7 risk covering benefits and harms.