AI and ML FoundationsVol. 14A · Part XIV
0 / 0

Shelves / AI and ML Foundations

Software Engineering · Volume 14A

AI and ML Foundations

Part XIV of the Software Engineering roadmap, written out as a textbook that starts from zero. The opening chapter assumes you have never trained a model, and trains one from scratch in twenty lines of NumPy. From there: the map of AI, Python for AI, linear algebra, calculus, probability and statistics, classical machine learning, evaluation, data, deep learning, PyTorch, neural architectures, Transformers, tokenization, large language models, decoding and the foundation-model lifecycle. Every chapter opens with a plain-language Start here section and a six-level How deep to go ladder, and ends with a lab of real, measured experiments (learners compared on synthetic data, vectorisation and float precision, SVD finding hidden factors, learning rates that diverge and gradients that vanish, peeking in A/B tests, cross-validated models on real medical data, metrics that lie and leakage that flatters, label noise and training–serving skew, an MLP from scratch, CNNs under translation, attention from scratch, BPE tokenizers trained on this book, and a tiny GPT trained, sampled, scaled and fine-tuned with LoRA on a laptop CPU) and a revision sheet with a quiz. A final chapter of eight projects ends with a language model you trained and evaluated yourself.

18 chapters◷ ~6 h to read ✓ 467 topics? 18 quizzes

Two ways to read this book

New to the subjectStart with the opening Start Here chapter and read chapters in order. In each chapter, read the Start here section, run its examples, answer Check yourself before opening the answers, and take the quiz. Read the deeper sections once the Start here quiz is easy; leave the hardest parts for a second pass. Build the projects in the final chapter as you go.
Experienced engineerSkip the opening chapter. In each chapter, read the Revision sheet at the end first and take its quiz; skim Start here; then use How deep to go to pick the internals sections and lab experiments that fill your gaps. Tick a topic only when you could teach it.

Every chapter has the same shape: Start here (first principles, plain language, small verified examples) → How deep to go (what each mastery level needs) → full-depth sections → Lab (experiments with real measured output) → Revision sheet (key ideas, numbers to remember, pitfalls, glossary, quiz).

How to use this book

  1. Read one topic at a time. Each topic heading has a Done tick. Tick it only when you can explain the idea aloud without looking, which is roughly mastery level L2–L3 below.
  2. Run the code. Every comparison block has tabs for each language; type the example out in at least two of them.
  3. Take the chapter quiz at the end. A score of 80% or more counts as passed. Wrong answers show the explanation, so re-read that topic and untick it if needed.
  4. Revisit after a delay. The roadmap's loop applies: recall, explain, implement without notes, break it, measure it.

Mastery levels

L1 RecognitionDefine it and identify it.
L2 WorkingUse it correctly in code or config.
L3 InternalsExplain why it works.
L4 DebuggingDiagnose failures and performance problems.
L5 DesignChoose among competing approaches.
L6 ProductionOperate it under scale, failure, security and cost.

Languages used throughout

Python · NumPy · pandaslinear algebra · calculusprobability · statisticsscikit-learn · XGBoostPyTorchTransformers · attentiontokenizers · decoding

Status as of October 2026: PyTorch is on the 2.14 line (September 2026); pandas 3.0 (January 2026) made copy-on-write and a dedicated string dtype the default; NumPy 2.x is current. Part XIV is split into two books because it is the longest part of the roadmap: this one (chapters 143–158) covers foundations and how models work; Volume 14B (chapters 159–180) covers building, evaluating, securing and operating AI systems. Run the code: every derivation here is checked numerically somewhere in the chapter.

Contents

  1. SC·00Start Here: Your First ModelFor programmers who have never trained a model: what it means for a program to learn from data, one small model trained from scratch in twenty lines…5 min
  2. SC·143AI FoundationsThe map of the field before the details: what "intelligence" means for machines, AI versus machine learning versus deep learning, learning as…18 min
  3. SC·144Python for AIPython as the AI workbench and why it won: the language features that matter for ML code, type hints for data and model code, virtual environments…24 min
  4. SC·145Linear AlgebraThe language models are written in: vectors as data and as directions, vector spaces, dot products and what they measure, norms (L1, L2, L∞) and…24 min
  5. SC·146CalculusThe mathematics of learning by adjustment: limits and derivatives as rates of change, rules of differentiation, partial derivatives and gradients as…24 min
  6. SC·147Probability and StatisticsThe language of uncertainty that every model speaks: sample spaces and random variables, discrete and continuous distributions (Bernoulli, binomial…25 min
  7. SC·148Classical Machine LearningThe algorithms that still win on tabular data and the ideas every deep model inherits: the supervised learning setup and train/validation/test…30 min
  8. SC·149ML EvaluationHow to know whether a model is any good, and good for what: the confusion matrix and the four outcomes, accuracy and why it lies on imbalanced data…20 min
  9. SC·150Data Engineering for AIModels are only as good as their data: the data-centric view of ML, ingestion from databases, events, files and the web, data cleaning (types, units…21 min
  10. SC·151Deep LearningNeural networks from the neuron up: the perceptron and its learning rule, why XOR needs hidden layers, multi-layer perceptrons as compositions of…19 min
  11. SC·152PyTorchThe dominant deep learning framework from the inside out: tensors (dtype, device, shape, strides, views), autograd and the dynamic computational…26 min
  12. SC·153Neural ArchitecturesHow a network's wiring encodes assumptions about data: inductive bias, convolutional networks (convolution as weight sharing, kernels, stride…19 min
  13. SC·154TransformersThe architecture behind modern AI, derived piece by piece: token embeddings, attention as a differentiable soft dictionary lookup, scaled dot-product…24 min
  14. SC·155TokenizationHow text becomes the integers a model actually sees, and why it shapes cost, context and behaviour: tokens and vocabularies, the trade-off between…18 min
  15. SC·156Large Language ModelsWhat an LLM is and how it produces text, end to end: the pipeline from text to tokens, embeddings, Transformer, logits, probabilities and decoding…18 min
  16. SC·157LLM DecodingTurning next-token distributions into text: greedy decoding and its repetition loops, sampling with temperature, top-k, top-p (nucleus) and min-p…17 min
  17. SC·158The Foundation-Model LifecycleHow a foundation model goes from raw data to a deployed product, and how engineers adapt one to a task: pre-training (data mixtures, compute budgets…16 min
  18. SC·159AI and ML Foundations ProjectsEight build-it-yourself projects that take you from a line fitted by hand to a small language model you trained, adapted and evaluated yourself: a…6 min