Dinesh/ Blog
machine learning

Deep Learning and LLMs: an inspectable learning laboratory

A broad deep-learning and LLM progression with a verified NumPy spine, advanced framework and systems lessons, source evidence and explicit execution boundaries.

13 min readChecking device speech…
Lesson preparation & details

Level: beginner

By the end, you should be able to

  • Derive and test core neural computations
  • Navigate all 80 deep-learning topics and the classical ML branch
  • Distinguish source-backed concepts, executed CPU examples and unexecuted GPU experiments

Bring with you

Sources checked: . A source check does not change the publication or update date.

Editorial review: · What review means

In this article · 25 sections

This course takes one question seriously: can you explain and test the computation you are claiming to understand? It begins with a matrix product and develops the full80-session arc: neural models, vision, sequence learning, transformers, tokenization/data, pretraining systems, adaptation/alignment, efficient serving, multimodal models, agents and a reproducibility capstone. A small trained transformer and evidence pipeline are accessible checkpoints, not the ceiling of the course. The emphasis is depth and reproducibility, not a calendar, a parameter-count trophy or a guaranteed cloud budget.

What you can build and how to scale it

  • A scalar reverse-mode differentiation engine and a 17-parameter XOR network.
  • A cross-correlation operator with verified input and kernel gradients.
  • A recurrent-state calculation and a causal attention implementation.
  • A complete 688-parameter NumPy decoder, including all parameter gradients.
  • A deterministic byte-level BPE tokenizer, a bounded training run and a bigram comparison.
  • A low-rank adaptation experiment, an incremental K/V cache and a local retrieval baseline.
  • A capstone report with explicit task limits, reproducible tests and a weighted rubric.

The bounded decoder is a tiny transformer, not an assistant. The larger route retains the original100M pretraining, SFT/LoRA/DPO, quantization, streaming HTTPS and publishable report goals as optional staged experiments. Choose authorized local data and compute, prove each small contract first, and publish only measurements you actually make; no100M training, dataset size, endpoint or quality score is conferred by completing the reading. The retrieval lab is an executable lexical/evidence baseline, not a secretly mocked neural RAG demo. You will learn where a separately evaluated pretrained generator belongs without being told that an unrun API call proves anything.

Bring these prerequisites

You should be comfortable with Python functions, loops, dictionaries and basic classes, and with algebraic substitution and sums. You do not need prior PyTorch, a GPU, a cloud account or a paid API. The executable reference uses Python and NumPy only. The small programs were tested on CPU; use their assertions to check your own environment rather than trust a screenshot.

The preserved NumPy lab fences are independently runnable unless they explicitly import tiny_transformer.py; save that module beside those scripts. Broader framework lessons contain dependent snippets or experiment designs and may require separate datasets or GPUs. They are not automatically run by the local CPU checks. Never run cloud/download/serving commands merely because they appear in a lesson.

The progression

The progression
Figure text equivalent — labels and relationships
  • Node “Arrays, derivatives and probability” (square).
  • Node “Optimization and a single neuron” (square).
  • Node “Complete neural network and generalization” (square).
  • Node “Convolution and sequence state” (square).
  • Node “Attention and a complete transformer” (square).
  • Node “Tokenizer, data and measured training” (square).
  • Node “Adaptation and cache-correct inference” (square).
  • Node “Evidence retrieval and capstone” (square).
  • “Arrays, derivatives and probability” leads to “Optimization and a single neuron”. Line: normal; ends: arrow point.
  • “Optimization and a single neuron” leads to “Complete neural network and generalization”. Line: normal; ends: arrow point.
  • “Complete neural network and generalization” leads to “Convolution and sequence state”. Line: normal; ends: arrow point.
  • “Convolution and sequence state” leads to “Attention and a complete transformer”. Line: normal; ends: arrow point.
  • “Attention and a complete transformer” leads to “Tokenizer, data and measured training”. Line: normal; ends: arrow point.
  • “Tokenizer, data and measured training” leads to “Adaptation and cache-correct inference”. Line: normal; ends: arrow point.
  • “Adaptation and cache-correct inference” leads to “Evidence retrieval and capstone”. Line: normal; ends: arrow point.
LessonWhat you will test
Arrays, shapes, and the first linear modelCompute a matrix product by hand
Derivatives are local measurements; backprop is bookkeepingDerive gradients through a reused intermediate
Probability, cross-entropy, and stable logitsCalculate softmax and negative log likelihood
Optimization: steps, momentum, AdamW, and honest experimentsCompute stable and unstable gradient-descent steps
One neuron: logistic regression, stable loss, and its boundaryDerive stable binary cross-entropy from logits
A complete neural network: learn XOR and audit every gradientDerive a batched two-layer backward pass
Generalization is an experiment, not a low training lossDesign leakage-resistant training and validation splits
Convolution: shared local weights, shapes, and backward accumulationCalculate convolution output shape and parameter count
Sequence state and backpropagation through timeCompute recurrent states and temporal derivatives
Attention is a weighted sum with a precise maskCalculate scaled dot-product attention by hand
A tiny transformer you can differentiate and trainTrace the full decoder shape contract
Byte-pair encoding: learn merges, preserve bytes, test round tripsTrain adjacent-pair merges with deterministic ties
Training data: provenance, deduplication, and boundary-safe batchesRecord corpus provenance and preprocessing choices
Train, evaluate, checkpoint: a complete tiny-language-model experimentExecute all-parameter finite differences
Adaptation with LoRA: low-rank updates and masked supervisionCalculate LoRA parameter savings and gradients
Serving starts with cache correctness and a resource budgetProve incremental logits match full-prefix logits
RAG as a testable evidence pipeline, not a truth switchImplement deterministic retrieval and recall evaluation
Capstone: a reproducible model-and-evidence laboratoryDeliver a reproducible trained artifact with evidence

The table above is the tested NumPy spine. It is not the whole curriculum: the full 80-topic progression continues below, including framework, distributed, alignment, serving and multimodal study. Original URL numbers remain stable. Use the explicit links below for the full route. Automatic previous/next navigation may follow a different sequence; use this numbered list for the full course order.

A study loop with a falsifiable exit test

  1. Predict: calculate the tiny numeric example before running it. Write the shape beside every array.
  2. Execute: run the code and keep the assertions. A printed number without a checked expectation is weak evidence.
  3. Perturb: change a batch size, repeated token, target or mask. Predict which invariants should remain true.
  4. Explain: answer the exercises without looking. Use the answer sketches to diagnose a gap, not to count a page as read.
  5. Record: note what was measured, the environment and what remains untested. A failed experiment is useful if its claim is honest.

For example, if a finite difference disagrees with backpropagation, do not immediately lower the learning rate. The learning rate does not appear in the derivative of the current loss. First inspect the objective, reduction, shapes, mutation order and nonsmooth points.

How sources and verification work

The NumPy documentation defines broadcasting behavior; PyTorch's autograd notes explain reverse-mode mechanics; Attention Is All You Need defines scaled attention and the original transformer architecture. We cite such sources at the claims they support. Our numerical examples are separately executed; a paper citation does not prove a copied implementation is correct.

Read each example’s stated test boundary rather than treating it as certification of every hardware path or security property. Each lab identifies important omissions: no ImageNet score from a convolution example, no natural-language competence from a five-symbol model, no production throughput from a cache equality test.

The advanced progression explicitly includes distributed training, resource planning, PPO/DPO, quantization, multimodal learning, agents, MoE and long-context methods. These are valid conceptual lessons with source-backed contracts. GPU, framework and deployment recipes have separate unexecuted boundaries; a conceptual lesson is not bad content merely because no accelerator experiment was run.

Your destination

The capstone is a replayable experiment with baselines, gradient checks, split evidence, cache parity and failure analysis. It is acceptable for a baseline to win. It is not acceptable to invent results, tune on the test set without disclosure, or call a local toy “production-ready.”

First checkpoint: for XX of shape (4,3)(4,3) and WW of shape (3,2)(3,2), what shape is XWXW? Answer: (4,2)(4,2); the shared feature dimension is summed out. If you can explain that and are willing to keep asking equally concrete questions, start with the arrays lesson.

The 12 modules at a glance

Math for deep learning — sessions 001–006

Arrays, geometry, broadcasting, differentiation, information and optimization. Exit: derive shapes, gradients and stable losses.

Neural networks from scratch — sessions 007–013

Neurons, activations, MLPs, backpropagation, MNIST design, scalar autograd and vectorization. Exit: gradient-check a model before training.

PyTorch fluency — sessions 014–019

Tensors/autograd, registered modules, datasets/loaders, training loops, mixed precision and debugging. Exit: explain state and execution mode independently of a framework demo.

Regularization and optimization — sessions 020–024

Dropout, normalization, initialization, schedules, clipping and accumulation. Exit: distinguish changes to the objective, estimator and numerical procedure.

Vision — sessions 025–030

Cross-correlation, CNN architectures, CIFAR experiment design, transfer, augmentation and ViT. Exit: compute shapes and test label-preserving assumptions.

Embeddings and sequences — sessions 031–035

Word2vec, RNNs, LSTM/GRU, seq2seq and additive attention. Exit: trace recurrent derivatives and the encoder-decoder information path.

Transformers — sessions 036–043

Attention derivation, heads, positions, blocks, nanoGPT-style construction, text training, KV cache and RoPE/FlashAttention. Exit: distinguish exact algebra, shape correctness and kernel performance.

Tokenization, data and scaling — sessions 044–049

BPE, SentencePiece, dataset provenance, scaling fits, domain mixtures and deduplication. Exit: freeze preprocessing and prevent leakage before optimizing a model.

Pretraining systems — sessions 050–057

Architecture choices, DDP/FSDP, resource planning, a 100M experiment design, evaluation, checkpointing, diagnosis and scale accounting. Exit: make a budget and recovery contract without inventing throughput.

Adaptation and alignment — sessions 058–065

SFT, instruction data, LoRA, QLoRA, reward models, PPO, DPO and evaluation. Exit: derive losses and separate parameter efficiency from improved behavior.

Efficient inference and serving — sessions 066–073

KV memory, quantization, pruning/distillation, speculation, batching, serving-engine internals, streaming APIs and latency. Exit: prove state correctness and specify a benchmark boundary.

Multimodal, agents and capstone — sessions 074–080

CLIP/LLaVA, tool controllers, RAG, MoE, context extension, red-teaming and a broad reproducibility capstone. Exit: connect mechanisms to evidence and authorized execution.

Advanced study and execution contract

Use Python/linear algebra prerequisites for the early modules; framework lessons then build on the same derivatives and state contracts. Execution is lesson-specific: the NumPy spine and selected NumPy/PyTorch examples include bounded CPU checks. Those checks do not imply TensorFlow, distributed collectives, rented GPUs, pretrained models, paid APIs, clinical use or deployment were run. Treat source-supported theory, pseudocode, dependent snippets and independently executed programs as distinct evidence categories.

No fixed duration, spend, accuracy or model capability is promised. Select a small experiment with a falsifiable acceptance condition, then estimate costs from current quotes and measured throughput. Larger capstones are optional staged work, not achievements conferred by reading a page. Preserve your failed cases as well as successes.

Classical ML and applied LLM branches

The separate classical ML sequence starts with the ML mental model, proceeds through linear/logistic models, regularization, trees, ensembles, evaluation and validation, and joins neural-network and LLM foundations. The applied LLM map connects retrieval, prompting, agents and evaluation. The Kimi architecture study is a pinned-source advanced case study, not a substitute for this progression.

FAQ

Do I need a GPU? Not for the verified NumPy spine. Some framework exercises can be reduced to CPU shape tests; full dataset or distributed experiments require separate resources and permission. Reading a conceptual GPU lesson does not require renting hardware.

How long does it take? Use exit criteria rather than a promised calendar. Spaced recall and changing one assumption in an example are more informative than time spent with a tab open.

Which examples can I run? Start with the tested CPU programs. Each lesson distinguishes runnable examples from pseudocode and references that need additional libraries, data or hardware. A successful syntax check does not mean a training run or deployment was performed.

Module deliverables and branch choices

Each module pairs a mechanism with a concrete artifact. These are study goals, not guaranteed benchmark scores or a fixed160-hour/cloud-price contract.

ModuleArtifact and honest exit criterion
M01 math001–006Shape traces, derivative checks and stable-probability calculations; explain why each operation is valid.
M02 NumPy007–013Neuron/MLP, handwritten-digit experiment design, a scalar autograd engine and vectorization comparison; check gradients before accuracy.
M03 PyTorch014–019The same model with registered parameters, loaders, logging and checkpoints; distinguish train/eval mode, gradients and mixed-precision paths.
M04 optimization020–024A configurable loop with regularization, normalization, initialization, schedules and accumulation; record one-factor comparisons.
M05 vision025–030Convolution derivatives, CNN/CIFAR training, transfer/augmentation and ViT; use a fixed validation protocol rather than a promised92% score.
M06 sequence031–035Word vectors, recurrent cells, gated memory and an attention seq2seq translation recipe; evaluate sequence outputs instead of assuming fluency.
M07 Transformer036–043A complete decoder, text-training procedure, cache equality and RoPE/tiled-softmax controls; a10M character model is optional and coherent text is an outcome to measure.
M08 data044–049Byte tokenizer, SentencePiece concepts, provenance, scaling budgets, mixing and dedup; a1B-token dataset is a possible scale target, not required or downloaded here.
M09 pretraining050–057Architecture/configuration, distributed and resource plans, a100M local-file training recipe, evaluation, recovery and scale accounting; bound cost from measured throughput.
M10 alignment058–065SFT, instruction curation, adapters/quantization, reward models, PPO/DPO and red-teaming; assess each objective and failure case, not only chat format.
M11 serving066–073Cache budgets, compression, speculation, batching, engines, streaming API and latency tests; HTTPS/endpoint operation needs separate authorization and integration evidence.
M12 integration074–080Vision-language, tools, RAG, MoE, long context, safety and a capstone report; include provenance, baselines, negative results and reproducible limits.

Pacing, recovery and next steps

A suggested study session is pre-read → hand calculation → code/assertions → perturbation → recall. Twenty minutes of reading,90 minutes of practice and10 minutes of recall were the original pacing example, not a universal completion time. One or two sessions a week can work; adjust to the exit tests and your resources. After a break, reconstruct the last worked example and one failure case before advancing. A4/5 recall score can be a personal cue, not proof of mastery.

Can I skip ahead? Follow prerequisites and return when an equation or state contract is unclear. What if calculus is rusty? Start with the derivative/chain-rule lesson and supplementary calculus practice; advanced expectations and continuous distributions may involve integrals even though many early labs do not. Which framework? The course emphasizes NumPy and PyTorch; that is a teaching choice, not a claim about every lab's framework. What comes next? Reimplement a bounded paper mechanism, contribute a test or documented fix to an open project, or design a domain application with a measured baseline.

Colophon and optional resources

The original course draws inspiration from Karpathy's Zero to Hero,3Blue1Brown's linear-algebra/neural-network series,Umar Jamil's implementation walkthroughs,Sebastian Raschka's from-scratch LLM book,StatQuest,Yannic Kilcher,Stanford CS224N/CS231N and Hugging Face tooling. Use them as complementary explanations; optional links may change, and these examples do not reproduce their full courses. The written80-session map remains self-contained as navigation even if you skip the videos.

Pause / Recall / Apply

Can you explain it without the page?

Close the example. Reconstruct the core idea, then change one assumption. Mark complete when you’re ready; you can always undo it.

Stored in this browser only. No account, no sync. Clearing browser data removes your record.