Track T39
Language Models, Retrieval & Adaptation
Tokens, embeddings, transformers, retrieval, decoding and honest language evaluation.
Unit 1Tokens and counts
- 1Tokens: how a language model reads textWords, subword pieces, characters or bytes. See what a tokenizer decides before any model runs, why its vocabulary is fixed, and how byte and character models such as ByT5 and CANINE skip the vocabulary altogether.
- 2N-gram language models: counting what comes nextPredict each word from the few words before it, using counts. See why unseen pairs need smoothing, what Kneser–Ney adds over add-one, and fit both on the same held-out rows in CodeSplash.
- 3Perplexity, honestly: what a language model score can and can't sayTurn next-token probabilities into cross-entropy and perplexity, put an interval on it, and catch the two traps that make a perplexity look better than it is, unknown words and a different tokenizer. Then score text with a pretrained GPT-2.
- 4From counts to vectors: the neural probabilistic language modelBengio's neural language model replaced count tables with learned word vectors and a small network. See how it predicts, why shared vectors generalize to unseen sequences, and what its full softmax costs.
Unit 2Word vectors
- 5Word2vec and GloVe: vectors from the company words keepCBOW and skip-gram learn word vectors by predicting neighbors with a few sampled noise words; GloVe fits log co-occurrence counts. Train all three on the same text and see why their neighbor lists disagree.
- 6Subword vectors and document vectors: fastText and Doc2VecfastText builds a word's vector from its character n-grams, so unseen and misspelled words still get one. Doc2Vec learns a vector per document. See what each buys you and where each misleads.
Unit 3Contextual encoders
- 7Context changes meaning: ELMo and ULMFiTA static word vector gives "bank" one meaning. ELMo mixes the layers of a bidirectional language model into vectors that depend on the sentence; ULMFiT showed how to fine-tune a pretrained language model without wrecking it.
- 8BERT, RoBERTa and XLNet: reading text in both directionsBERT learns by filling in hidden tokens from both sides; RoBERTa showed the recipe mattered as much as the model; XLNet predicted tokens in shuffled orders. Use a pretrained encoder with a linear head in CodeSplash.
- 9Smaller, faster, sharper encoders: ALBERT, ELECTRA, DeBERTa and DistilBERTFour ways to get more from an encoder. ALBERT shares parameters, ELECTRA learns from every token, DeBERTa separates content from position, DistilBERT copies a bigger teacher. Run two of them frozen in CodeSplash.
- 10Sentence embeddings: SBERT, SimCSE, E5 and BGE-M3One vector per text, so that similar texts land close together. See how SBERT pools a fine-tuned encoder, how SimCSE trains with dropout as the only augmentation, why E5 needs prefixes, and what BGE-M3 adds.
Unit 4Encoder–decoder and multilingual models
- 11Encoder–decoder models: from seq2seq to BART, T5, PEGASUS and MASSAn encoder reads the source, a decoder writes the target. Follow the line from LSTM seq2seq and attention to the denoising objectives of BART, T5, PEGASUS and MASS, and see what each pretraining task teaches.
- 12One model, many languages: mBART, mT5, XLM and XLM-RMultilingual models share one vocabulary and one set of weights across languages. See how training data is balanced between languages, how parallel text helps, and why one accuracy number hides the languages that do worst.
Unit 5Decoder-only language models
- 13Decoder-only language models: GPT, and what a model card disclosesGPT-style models predict the next token with a causal mask and scale up. See what that objective gives you, how much of GPT-4, Phi and OLMo is actually disclosed, and how CodeSplash uses such models through its AI layer, not as methods.
- 14Open-weight model families: Llama, Mistral, Qwen, Gemma and BLOOMThe open-weight families share one recipe and differ in a few attention tricks that shrink memory and in their licenses. Learn grouped-query attention, sliding windows, local and global layers and ALiBi, and what each license lets you do.
- 15Mixture of experts, latent attention and trained reasoning: Mixtral, DeepSeek and GRPOMixtral routes each token to two of eight experts; DeepSeek compresses keys and values into a small latent; DeepSeek-R1 learned long reasoning from rewards with GRPO. See what each saves, what it costs and what it doesn't prove.
Unit 6Long context and retrieval
- 16Long contexts: Transformer-XL, Longformer, BigBird and ReformerFull attention compares every token with every other, so cost grows with the square of the length. Four designs cut that cost with memory, windows, global and random links, or hashing. Read their attention masks and know what each gives up.
- 17Finding passages: BM25, dense retrieval, SPLADE and ContrieverRetrieval by shared words or by meaning. Run BM25 and dense search side by side, see how DPR, SPLADE and Contriever are trained, and fuse rankings with reciprocal rank fusion, while watching for ties and filler results.
- 18Late interaction: ColBERT's MaxSim as a rerankerColBERT keeps one vector per token and matches each query token to its best document token. Compute MaxSim by hand, rerank BM25's candidates with it in CodeSplash, and see what reranking fixes and what it can't.
- 19Scoring a retriever: recall@k, MRR and nDCGJudge rankings with relevance labels per query. Compute nDCG by hand, read recall@k, MRR and MAP with intervals over queries, and compare two systems on the same queries, minding unjudged items, gains and cutoffs.
- 20Lab: pooled retrieval against token-level MaxSimThe language chapter's second lab (LNG-B). Averaging a document's token vectors dilutes the few that match a query; late interaction keeps every token. Compare both with recall at 1.
- 21Retrieval-augmented models: RAG, REALM, RETRO, FiD, Atlas, kNN-LM and moreLet a language model read retrieved text instead of relying on memory. Compare the ways the research models combine passages with generation, and see how CodeSplash's Ask documents uses the idea and how to evaluate each part separately.
Unit 7Adapting language models
- 22From text predictor to assistant: instruction and preference tuningA pretrained model continues text; an assistant follows instructions and prefers helpful, harmless answers. Survey the steps that get there, FLAN and T0, RLHF, Constitutional AI, DPO and ORPO, and what each optimizes.
- 23Adapting with few parameters: LoRA, QLoRA, adapters, prefixes and soft promptsInstead of updating every weight, train a small add-on. Compute a LoRA update, see what QLoRA quantizes, place adapters, prefixes and soft prompts in the network, and run LoRA on a text encoder in CodeSplash.
Unit 8Prompting, reasoning and decoding
- 24Prompting and reasoning: chain of thought, self-consistency, Tree of Thoughts and ReActShow intermediate steps, sample and vote, search over partial solutions, or interleave reasoning with tool calls. See what each costs and fixes, and where Label with AI votes and Agent mode use them.
- 25Decoding: beam search, nucleus sampling and speculative decodingThe same model writes very different text depending on how tokens are chosen. Compare greedy and beam search with length penalties, nucleus sampling, and speculative decoding, which speeds generation up without changing what is generated.
- 26Diffusion for text: masked diffusion language models such as LLaDAInstead of writing left to right, start from a fully masked answer and unmask it over several steps. See how masked diffusion trains, why its loss is reweighted by the mask rate, and what it trades against autoregressive generation.
Unit 9Evaluating language systems
- 27Overlap metrics for generated text: BLEU, chrF and ROUGEScore generated text by how much it shares with reference texts. Compute BLEU, chrF and ROUGE from their parts, compare two systems on the same rows with a paired interval, and see what overlap can't measure.
- 28Counting errors: word and character error rates, and SI-SDR for signalsWhen there is one right output, count how far a system is from it. Align a transcript to its reference and count substitutions, deletions and insertions, then meet SI-SDR, the same idea for a separated audio signal.
- 29Learned metrics: BERTScore, MAUVE and COMETMetrics built on pretrained models credit paraphrases that overlap misses. BERTScore matches token embeddings, MAUVE compares distributions of text, COMET learns from human ratings; each inherits its model's limits.
- 30Pass@k for code, and judges for open-ended answersWhen outputs can be run, count how often one of k tries passes, with the unbiased estimator. When they can't, ask a judge, then check the judge for position and length bias, compare it with people, and rank systems from paired verdicts.
- 31Was the test in the training data? Contamination and memorizationA benchmark score means skill only if the test wasn't in the training data. Learn the checks, from searching open training data to time splits and Min-K% Prob, run Min-K% in CodeSplash, and keep your own evaluations clean.
- 32Workflow: train a tiny character language model, then adapt itWalk through the reference's complete workflow, a small recurrent character model trained and then adapted to a new domain two ways. Every choice is visible, from the split contract to the retention check and the parameter audit.
- 33Lab: train and score a smoothed bigram modelThe language chapter's first lab (LNG-A). Count bigrams, smooth them so unseen pairs keep some probability, choose the smoothing on validation sentences and score the test sentences once.