Repository navigation
Module 23
Level: Advanced
Status: Introductory technical chapter with supporting lessons and learning resources
This module is a self-contained learning unit within the larger Deep Learning curriculum. Its purpose is to build understanding from motivation and prerequisites through mathematical reasoning, implementation and critical evaluation.
Large language models learn statistical structure in token sequences, commonly through next-token prediction at scale. Their behaviour depends on tokenization, architecture, data, optimization and inference choices. Multimodal systems extend representation and generation across text, images, audio or video.
Trace the pipeline from tokenization and embeddings through pretraining, instruction tuning and inference. Study decoding, context windows, evaluation and parameter-efficient adaptation. For multimodal systems, identify how modalities are encoded, aligned and fused.
By the end of this module, a reader should be able to define its central objects, explain the motivation behind its main methods, interpret the governing equations, work through a small example, and identify assumptions and limitations. The goal is understanding the mechanism—not memorizing a list of terms.
- Explain next-token prediction and causal masking.
- Compare Transformer language-model families.
- Describe image-text representation alignment.
Modules 01–10 provide the core mathematical and training foundations; Modules 13–15 explain attention and Transformer internals.
Useful background
Where these ideas are used next
- Module-23-Lesson-Map
- Module-23-Important-Lessons
- Module-23-Numericals-and-Exercises
- Module-23-Implementation-Roadmap
- Module-23-Research-Extensions
- Module-23-large-language-models-multimodal-deep-learning
- Module-23-Lesson-01
- Module-23-Lesson-02
- Module-23-Lesson-03
- Module-23-Lesson-04
- Module-23-Lesson-05
- Module-23-Lesson-06
- Module-23-Lesson-07
- Module-23-Lesson-08
- Module-23-Lesson-09
- Module-23-Lesson-10
- Module-23-Lesson-11
- Module-23-Lesson-12
- Study the lessons in prerequisite order.
- Write a notation sheet and derive central equations.
- Solve at least one hand-worked example per major mechanism.
- Implement core operations where appropriate.
- Verify outputs and gradients.
- Complete conceptual and coding exercises.
- Record limitations and research extensions.
- Conceptual understanding
- Mathematical derivations
- Worked numerical examples
- NumPy implementation (where applicable)
- PyTorch implementation (where applicable)
- Tests and numerical verification
- Experiments and interpretation
- Revision and self-assessment
LLMs and multimodal learning are separated into distinct units so that language modelling, pretraining, adaptation, inference and cross-modal alignment can be studied and evaluated independently.
- Module-23A-LLM-Foundations-and-Tokenization
- Module-23B-LLM-Pretraining-and-Scaling
- Module-23C-LLM-Finetuning-Alignment-and-PEFT
- Module-23D-LLM-Inference-Decoding-and-Evaluation
- Module-23E-Multimodal-Deep-Learning
Large language models are sequence models trained to represent and generate text. Autoregressive models optimize next-token prediction; masked-language models reconstruct masked tokens. Modern LLM workflows include tokenization, pretraining, supervised fine-tuning, preference alignment, decoding, evaluation and deployment. Multimodal models extend token-like representations to images, audio, video or other modalities.
Autoregressive factorization: $$ p(x_1,\ldots,x_T)=\prod_{t=1}^{T}p(x_t\mid x_{<t}). $$
Next-token negative log-likelihood: $$ L(\theta)=-\sum_{t=1}^{T}\log p_\theta(x_t\mid x_{<t}). $$
Perplexity: $$ \operatorname{PPL}=\exp\left( -\frac1T\sum_{t=1}^{T}\log p_\theta(x_t\mid x_{<t}) \right). $$
A tokenizer maps text to token IDs. The embedding layer maps IDs to vectors. Transformer blocks contextualize them. A language-model head produces logits over the vocabulary; softmax converts logits to a next-token distribution. Decoding chooses or samples a token and appends it to the context.
flowchart TD
A[Text / multimodal input] --> B[Tokenizer or modality encoder]
B --> C[Token / patch embeddings]
C --> D[Transformer backbone]
D --> E[Logits or modality head]
E --> F[Decode / generate]
F --> G[Output and evaluation]
Build a tiny character-level language model before using a pretrained model. Inspect tokenization, context length, logits, teacher-forced loss and autoregressive generation. Record decoding settings such as temperature, top-k and top-p.
Parameter count alone does not define capability. Perplexity is tokenizer- and dataset-dependent. A plausible answer can be factually wrong. Prompting, fine-tuning and retrieval solve different problems. Multimodal inputs require alignment and modality-specific preprocessing.
Study scaling laws, data quality, instruction tuning, preference optimization, retrieval augmentation, quantization, speculative decoding, KV caching, evaluation contamination and multimodal alignment.
- Reproduce the smallest mathematical example by hand.
- Implement the central operation using NumPy.
- Implement the same operation using PyTorch.
- Compare outputs and gradients with numerical tolerances.
- Change one assumption or hyperparameter and document what changes.
- Record environment, random seed, data split, compute budget and limitations.
- Explain the motivation and assumptions without notes.
- Derive the principal equations and define every symbol.
- Complete at least one worked numerical example.
- Trace tensor shapes through the computation.
- Implement and test the central mechanism.
- Explain at least two failure modes.
- Read one primary paper and summarize its contribution and limitations.
Content status: This page now contains a technical chapter and a practical learning specification. The linked lesson pages provide focused subtopic treatment; experiments are not claimed complete until their result logs are added.
🏠 Home · 🗺️ Curriculum · 🧭 Learning paths · ❓ Question bank · 📖 Glossary · 📚 References · ✏️ Contributing
🏠 Home · 🗺️ Curriculum · 🧭 Learning paths
❓ Question bank · 📖 Glossary · 📚 References
Jump to module:
01 02 03 04 05 06 07 08 09 10 11 12
13 14 15 16 17 18 19 20 21 22 23 24