Read the book in English · 한국어판 · 한국어 README · Download the serving guide (EPUB)
A free textbook on training, serving, and evaluating foundation models. Browse the labs and teaching materials for worked examples, CPU notebooks, and printable worksheets.
Try the 24 GiB KV-cache calculator. In this example, nine prompts take 22.5 GiB. If each request generates another 2,048 tokens, how many full-length caches can the pool hold at once?
Why did length bucketing cut padding from 18 positions to 6 while peak KV stayed at 990 KiB? Follow six prompts through three CPU batches and reproduce the measurements.
| Your question | Start here | What you can do |
|---|---|---|
| The weights fit. Why does serving run out of memory? | KV cache management | Compare the recorded SmolLM2 run, from 990 to 1,350 KiB with the same batch in the calculator. Run the CPU notebook or size a queue of mixed requests (XLSX). |
| What does an attention weight actually do? | Self-attention mathematics | Calculate the weights by hand with the two-page worksheet and solution, then try the FlashAttention example where averaging the tiles gives 6 instead of 8. |
| Does BERT score a word it left untouched? | A five-token example | Calculate both losses. Then change a padding value in cross-attention and predict which outputs move. |
| How many context positions does one image use? | Visual token budget | Change image size and count, then check which number the model reads when the total is missing and the two items swap places. |
| My RAG answer is wrong. Where did the evidence go? | Trace one answer | Trace six failures by chunk ID, then change how many candidates reach the reranker. |
| Why can the same word select different MoE experts? | Top-k router lab | Change the preceding words, then trace six routed tokens across two CPU processes. |
| Which newly released models should I evaluate? | Model comparison and sources | Compare 45 profiles, see why two Astra settings both score 62 but take different times, and run a Python example of whole-request pricing. |
| Does a higher evaluation score justify a release? | Experimental design and uncertainty | Find why five validation cases produced six predictions, then test a release decision with paired outcomes. |
| Can I train a model, break it, and resume it exactly? | Tiny decoder lab | Inspect four errors in a single held-out sequence before running the same experiment on a CPU. |
Both editions have 108 published lessons across 20 chapters. The last four chapters include evaluation (7 lessons), safety (4), interpretability (4), and state-space models and other emerging architectures (7). Each lesson ends with reasoning questions and references. The learning paths help you check prerequisites and choose a route.
Expect Python, linear algebra, and probability. Examples identify their simplifications; teaching simulations are not benchmark results. Time-sensitive comparisons identify their source and snapshot date. A provider's claim is kept separate from independently measured evidence.
The comparison records provider access as of 2026-11-24 and benchmark scores, costs and minutes per task as of 2026-11-25. Check GLM-5.4’s release status, find the context limit of the Ling-3.2-air checkpoint, inspect the evaluation for GPT-6.2 Sol, or read how GLM-5.4 reuses its layers. Measure how adding one token reduced the backing storage for a small CPU model’s KV cache by 4,608 bytes.
Can an attention mask leak a future token? Change the fifth value in a seven-token sequence and see whether the fourth output moves. This CPU example uses PyTorch and fixed inputs. Run the mask test · Python source
A customer asks in Korean whether they can replace a battery. The top search result tells them to open the back cover, a procedure written for a different model. Read the retrieval experiment, inspect the scores for all eight queries, or run BM25 and multilingual E5 on CPU.
Give a decoder four symbols, then cover its earlier tokens. Can it still copy the sequence? Run the English notebook on Binder without signing in, or compare the saved test losses with and without earlier tokens. The notebook generates its own data and runs on CPU. The lab guide includes local and Colab instructions. Download the November notebooks for offline work.
Two candidates gain 15 percentage points on the target task. Run the target improvement case and the retention regression case. Which would you release? You can also run the same script from a checkout with Python 3.10+.
python public/labs/paired_release.py --scenario gain
python public/labs/paired_release.py --scenario regressionThen try uncertain and missing. The evaluation guide explains why a target improvement can still produce Review or Block. This lab uses Python 3.10+ and the standard library. The decoder and release examples generate synthetic data so you can reproduce each result.
- For a syllabus or paper, use the book citation or GitHub’s Cite this repository for APA or BibTeX. Each chapter’s Cite this chapter (RIS) download records its language, revision date and exact manuscript. When reporting an experiment, also record the code revision and runtime you used.
- Bookmark the project with a GitHub star if it is useful. Share a specific lesson with someone facing the same engineering problem.
- Subscribe to the full text of selected articles or follow chapter updates in English or 한국어.
- Report a correction: include the page, the claim or behavior, and a source or reproducible example.
- Contribute: technical corrections, clearer examples, Korean phrasing, and accessible interactions are welcome.
Seongeun So maintains this independent textbook. Gemini helped translate the first Korean edition from English. Codex wrote and ran the Whisper sample-rate experiment and adapted the results into the short article. Original translation note
When revising a lesson, contributors edit the English first, then update the Korean in the same change, including its formulas, code and worked examples. The review log records what was checked for each lesson. Editing guidelines · Lesson review log
Data For Science featured the book in the September 23, 2026 edition of Data Science Briefing, issue 337.
- Framework: Astro 6
- Content: MDX
- Styling: Vanilla CSS (Book-like theme)
- Fonts: Locally installed fonts for text and code, with CJK fallbacks. Math uses KaTeX fonts served with the book.
To run this project locally, you need Node.js v22.12.0 or higher.
If you are using nvm, you can switch to Node 22:
source ~/.nvm/nvm.sh
nvm use 22If you don't have Node 22 installed via nvm:
nvm install 22Install dependencies:
npm ciStart the development server:
npm run devThe site will be available at http://localhost:4321.
To build the static site:
npm run buildThe output will be in the dist/ directory.
To preview the production build locally, use:
npm run previewIf you use serve, run serve dist instead of serve -s dist. This project is a static multi-page Astro site, not a single-page app. The -s option forces all routes back to the root index.html, which breaks page navigation and locale switching.
For local development and normal local builds, the site uses the root path /.
Repository:
https://github.com/sungeuns/foundation-model-engineering
For GitHub Pages repo hosting under:
https://sungeuns.github.io/foundation-model-engineering/
build with:
SITE_BASE=/foundation-model-engineering/ npm run buildThat sets Astro's base only for the deployment build, so local npm run dev routing stays normal while GitHub Pages still gets the correct subpath links.
This project is licensed under the MIT License. The two SmolLM2 KV cache measurement notebooks include their Apache 2.0 license and original source in each file. For more information regarding the project's status as a personal, non-affiliated open-source resource, please see the DISCLAIMER file.
