What weights are, where they live, how they change, and what they cost to run — 8 modules over 4 intensive weeks, for the people who have to size the box and defend the choice.
This file is generated from the course data by scripts/build-notes.mjs. Edit the course data, not this file.
Organisation: Alderbrook Health
Your employer for the next four weeks: a private healthcare group — 4,200 staff, six sites, a clinical research arm, and a newly signed data-residency mandate that says patient-derived text may not leave infrastructure Alderbrook controls. Three AI pilots are already running on a hosted API and must now come home. You are the infrastructure lead on Project Homestead: choose the models, size the hardware, prove the files are safe, and defend the bill. The CFO has a competing quote from a vendor and a copy of a blog post that says you can run "a 70B model on a gaming PC".
Guiding question: What is actually inside the file I am being asked to host — and what is not in there at all?
Outcome: Define weights precisely and separate them from the four things they get confused with (activations, gradients, hyperparameters, and the prompt). Explain what weights DO contain (compressed statistical structure) and what they emphatically do NOT (a fact database, a retrieval index, anything after the cutoff) — and derive hallucination and stale knowledge from that single fact.
Decision lens: Somebody is going to ask you to put "the AI" on a server. What arrives is a directory of large numeric files, a config, and a tokenizer. No database, no rules engine, no facts table — just a few billion decimals that encode how tokens tend to follow other tokens. Every capability and every failure mode of the thing you are hosting falls out of that one sentence. Get it straight now and the other seven modules are arithmetic.
Apply-at-work mission — Baseline: explain the file: Write your current, unassisted explanation of "what is in a model file" in under 150 words — before this course changes it. Seal it. Then inventory the models your organisation actually touches (hosted APIs and any local ones): for each, note the parameter count, the precision, and where the weights physically live. Most people cannot complete that table on day one. The gaps ARE your syllabus, and Module 8 re-measures against this.
Reflection: Which of my mental models of "the AI" turned out to be an interface rather than the model? What did I assume was stored in there that is not?
Day one on Project Homestead. The mandate landed nine days ago; the hosted API contract has seven months to run. Your inbox already contains a vendor quote, an enthusiastic proposal to "fine-tune our own model", and a one-line question from the CFO that nobody has answered: "What exactly are we buying?" Nobody on the project can currently say what is inside a model file.
| Ref | Priority | From | Request |
|---|---|---|---|
| HMS-0001 | P1 | Elaine Ferris | CFO: "What exactly are we buying? Explain it without acronyms." |
| HMS-0002 | P1 | you, to yourself | Inventory: which models do our three pilots actually use? Nobody knows. |
| HMS-0003 | P1 | Yusuf Demir | "Does the model store our patient data inside it?" — board question, needs a real answer |
| HMS-0004 | P2 | Greg Sandoval | Cortexa quote received — 3 pages, no configuration detail |
Two artifacts. First, the sealed baseline: write your current, unassisted explanation of "what is inside a model file" in under 150 words. Do not research it, do not improve it — the value is entirely in its honesty, and Module 8 reopens it. Second, the inventory: list every model your organisation actually touches (hosted APIs, anything local, anything embedded in a product you have bought) and for each record the parameter count, the precision it runs at, where the weights physically live, and who is accountable for it. Mark every cell you cannot fill with a "?" rather than a guess. Most people finish week one with a table that is more question marks than answers — that is the honest starting position and it is the point.
Deliverable: weights/w01-baseline-and-inventory.md — the sealed 150-word explanation (dated), the model inventory table with question marks left visible, and a short note on which gaps worried you most.
Assessment rubric
| Criterion | Weight | What good looks like |
|---|---|---|
| Honest sealed baseline | 25% | A genuine unassisted explanation, written before reading — not a polished summary of the resources. Its errors are the deliverable. |
| Complete inventory attempt | 30% | Every model the organisation touches is listed, including the awkward ones embedded in purchased products. |
| Question marks preserved | 25% | Unknown cells are marked unknown rather than plausibly filled. Guessing here defeats the exercise entirely. |
| Gap reflection | 20% | A clear-eyed note on which unknowns carry real operational or governance risk, and why those specifically. |
Drill 1. Yusuf asks, in a board pre-brief: "If a clinician pastes patient notes into the assistant, does that data become part of the model?"
Task: Write the answer in under 120 words, correct enough for a DPO and plain enough for a board. Then write the follow-up question you would want Yusuf to ask next — the one about the surrounding service rather than the model.
Drill 2. A colleague says: "The model was trained on the whole internet, so it basically has a copy of Wikipedia inside it."
Task: Explain in three sentences why this is wrong, using the size arithmetic. Compare the training corpus size against the checkpoint size, and describe what actually survives that compression.
Drill 3. Dr Hale asks why the assistant confidently invented a guideline reference that does not exist.
Task: Explain the mechanism in two sentences without using the word "hallucination", then name the architectural change that would actually reduce it.
Self-test prompts. Answers and explanations are not published here — take the quiz at https://ragentic.netlify.app/#/courses/llm-weights to check yourself.
1. The most accurate description of "the weights" of an LLM is…
2. Weights differ from ACTIVATIONS in that weights…
3. GRADIENTS exist…
4. A HYPERPARAMETER is…
5. When you send a prompt to a model, the weights…
6. Your DPO asks whether patient data used in a prompt is "stored inside the model". The accurate answer is…
7. Training data CAN influence weights in a way that raises privacy concerns when…
8. The reason a model confidently states things that are false is best explained by…
9. A model's "knowledge cutoff" exists because…
10. Which of these is NOT contained in a model checkpoint?
11. The CFO asks why you cannot simply "look inside and see what it knows about us". The honest answer is…
12. For your self-hosting programme, the practical consequence of "weights are frozen at inference" is…
Guiding question: Where does "7 billion parameters" come from, and can I derive it myself from a config file?
Outcome: Read tensor shapes fluently, understand matrix multiplication as information mixing (and why it dominates the compute bill), and compute a model's parameter count from its config.json to within a fraction of a percent. Then handle the modern complication: mixture-of-experts models where total parameters and active parameters are different numbers — one sets your memory, the other sets your speed.
Decision lens: Vendors quote parameter counts like horsepower, and buyers nod. But the number is derivable: vocabulary × hidden size, plus layers × (attention + MLP), plus a rounding of small vectors. Twenty minutes with a config.json tells you whether "7B" is honest, whether it is really an MoE quoting its active count, and roughly what it will weigh on disk. That arithmetic is the entire basis of every sizing conversation you will have.
Apply-at-work mission — Derive the number yourself: Pick a real open-weights model with a published config. From hidden size, layer count, vocab size, intermediate size and head counts, compute the parameter count by hand (or with the course calculator). Compare to the published figure and account for the difference — tied embeddings, biases, layer norms, expert counts. Then repeat for an MoE model and report BOTH totals: parameters held in memory vs parameters active per token. 🎯 Starts Capstone Milestone 1.
Reflection: Where did my hand-computed number diverge from the published one, and what did chasing that gap teach me about how these models are actually assembled?
Cortexa's quote says "70B-class model" and Anika forwarded a paper about a model quoting "22B active". The CFO has noticed the two numbers and wants to know why a 70B costs more than a 235B. Parameter counting stops being academic this week.
| Ref | Priority | From | Request |
|---|---|---|---|
| HMS-0011 | P1 | this week's milestone | Derive the parameter count from config.json for three candidate models |
| HMS-0012 | P1 | Elaine Ferris | "Why is the 235B model cheaper to run than the 70B?" — CFO, genuinely confused |
| HMS-0013 | P2 | Greg Sandoval | Cortexa spec sheet quotes active parameters in the headline, total in the footnote |
Pick three candidate models for an Alderbrook-style deployment: one small dense model (roughly 7–9B), one larger dense model, and one mixture-of-experts model. For each, fetch the real config.json and derive the parameter count by hand or with the course calculator — embeddings, per-layer attention, per-layer MLP, output head, norms. Compare each derived figure with the published one and account for every discrepancy you find: tied embeddings, bias terms, SwiGLU's third matrix, grouped-query attention shrinking the K and V projections, expert counts. For the MoE model report BOTH numbers and state plainly which one determines the GPU you must buy and which determines how fast it will run. 🎯 Starts Capstone Milestone 1.
Deliverable: weights/w02-parameter-audit.md — three derivation tables, the reconciliation notes for each discrepancy, and a one-paragraph answer to "why is the 235B model cheaper to serve than the 70B?" written for the CFO.
Assessment rubric
| Criterion | Weight | What good looks like |
|---|---|---|
| Derivations are genuinely worked | 30% | Component-by-component arithmetic from the real config, not the published total copied back with steps invented around it. |
| Discrepancies reconciled | 25% | Every gap between derived and published figures is explained by a specific architectural cause and the residual is under about 1%. |
| MoE handled correctly | 25% | Total and active parameters both reported, with memory versus compute consequences stated explicitly and correctly. |
| CFO-ready explanation | 20% | The closing paragraph is accurate and jargon-free — a finance reader could repeat it correctly to somebody else. |
Drill 1. Cortexa's spec sheet headline reads "70B-class capability"; the footnote says "7B active parameters".
Task: Work out what architecture this implies, what you now need to ask for, and what the memory requirement is likely to be relative to the headline. Draft the two-sentence email asking for the missing number.
Drill 2. Elaine: "Explain to me why the bigger model is the cheaper one to run. I assume somebody has made an error."
Task: Write the explanation in under 100 words, no jargon, using an analogy that survives being repeated by her to somebody else.
Drill 3. Your derived parameter count for a candidate model is 8.4% below the published figure.
Task: List the five most likely causes in order of probability and describe the check for each. Then decide at what residual discrepancy you would stop investigating and why.
Self-test prompts. Answers and explanations are not published here — take the quiz at https://ragentic.netlify.app/#/courses/llm-weights to check yourself.
1. A tensor is best described as…
2. In matrix multiplication, an input of shape [batch, 4096] multiplied by a weight of shape [4096, 14336] produces…
3. The embedding table of a model with vocabulary 128,256 and hidden size 4,096 contains…
4. For a dense model, total parameters are dominated by…
5. In a mixture-of-experts model, "total parameters" and "active parameters" differ because…
6. gpt-oss-120b is described as 117B total with 5.1B active. To host it you must budget memory for…
7. The CFO asks why a 235B MoE can be cheaper to serve than a 70B dense model. The correct core of the answer is…
8. Tied embeddings mean…
9. Your derived parameter count is 3% below the published figure. The most likely explanation is…
10. Grouped-query attention reduces parameters and memory by…
11. A vendor quotes "70B-class performance" for their appliance but the footnote says 7B active. This tells you…
12. The most reliable way to learn a model's true size is…
Guiding question: How does text become numbers, and why is the very first weight matrix often the largest single tensor in the model?
Outcome: Trace text → tokens → token IDs → embedding vectors, understand the embedding matrix as a learned lookup table sized vocab × hidden, and explain why tokenisation choices leak into cost, context limits, and non-English performance. Distinguish an embedding MODEL (for RAG) from an LLM's embedding LAYER — a confusion that derails retrieval projects.
Decision lens: The embedding table is where "meaning" first becomes arithmetic: every token in the vocabulary owns a row of learned numbers, and rows that behave alike end up near each other. It is also, in smaller models, the single biggest tensor you will load — 50,000 vocabulary rows is not free. And when your RAG project stalls because someone used the chat model where an embedding model belonged, this is the module that explains why.
Apply-at-work mission — Tokenise your own domain: Run genuinely representative text from your organisation through a tokenizer playground: product names, hostnames, error codes, clinical or financial terms, and non-English content if you have it. Record the token-per-word ratio for each category against plain English prose. Identify the three worst offenders — the strings that shatter into many tokens — and calculate what that inflation does to a 128k context window and a per-token bill.
Reflection: Which of my organisation's everyday strings turned out to be expensive in tokens, and what does that imply for how we should feed this model?
The summarisation pilot is over budget on tokens and nobody knows why. Meanwhile the retrieval project has stalled: someone built the policy library index using the chat model instead of an embedding model, and the results are quietly terrible. Both problems live in this week's material.
| Ref | Priority | From | Request |
|---|---|---|---|
| HMS-0021 | P1 | Elaine Ferris | Token spend 3× forecast on clinical text — investigate before renewal |
| HMS-0022 | P1 | Dr Anika Rao | Policy library retrieval returning nonsense — index built with the wrong model |
| HMS-0023 | P2 | pilot telemetry | Drug names and NHS numbers shattering into many tokens — cost implication? |
Take genuinely representative text from your organisation — at least five categories, such as clinical or technical prose, product and drug names, hostnames and identifiers, error codes and logs, tabular data, and non-English content if you have any. Run each through a tokenizer playground and record tokens-per-word against plain English prose as your control. Identify the three worst offenders and work out why they shatter: unusual casing, digits, punctuation, or simply being absent from a vocabulary built mostly on web English. Then convert the finding into money and capacity: what does that inflation do to the effective size of a 128k context window, and to a per-token bill at your projected volume? Finish with one concrete mitigation you could actually implement.
Deliverable: weights/w03-tokenisation-study.md — the ratio table across categories, the three worst offenders with explanations, the context-window and cost impact, and one implementable mitigation.
Assessment rubric
| Criterion | Weight | What good looks like |
|---|---|---|
| Genuinely representative sample | 25% | Real organisational text across at least five categories, not generic examples — the strings your systems actually process. |
| Measured, not estimated | 25% | Actual token counts from a real tokenizer, with the model or encoding named, and a stated English-prose control for comparison. |
| Explains the why | 25% | The worst offenders are diagnosed to a cause, not just listed — vocabulary coverage, digits, casing, or script. |
| Converted to consequence | 25% | Impact expressed in effective context window and cost at real volume, with one mitigation that could survive contact with your architecture. |
Drill 1. Token spend on clinical summarisation is running at triple the forecast.
Task: Design the investigation: what would you measure first, what three hypotheses would you test, and what evidence would distinguish them? Include at least one hypothesis that is not about tokenisation.
Drill 2. The policy library retrieval index was built with the chat model rather than an embedding model. Results are poor but nothing errored.
Task: Explain to Anika why it silently produced poor results rather than failing, and outline what rebuilding correctly involves — including how you would demonstrate the improvement rather than assert it.
Drill 3. A colleague proposes standardising on one model to "keep token costs predictable across languages".
Task: Test the assumption: what would you measure to establish whether one model is genuinely more efficient on your language mix, and what would make the comparison unfair?
Self-test prompts. Answers and explanations are not published here — take the quiz at https://ragentic.netlify.app/#/courses/llm-weights to check yourself.
1. A token is…
2. The embedding table maps…
3. Two tokens with similar embedding vectors are similar in that they…
4. In GPT-2 small (124,439,808 parameters), the token embedding table of 50,257 × 768 accounts for roughly…
5. Clinical terms, drug names, and hostnames tend to consume more tokens per word because…
6. Your token spend is triple the forecast on clinical text. The most likely cause is…
7. An EMBEDDING MODEL differs from an LLM's embedding LAYER in that the embedding model…
8. Building a retrieval index using a chat model instead of a dedicated embedding model typically produces…
9. Position information matters because…
10. Vocabulary size trades off…
11. The same text tokenised by two different models will…
12. A practical mitigation for token-hungry domain text is…
Guiding question: Which matrices are learned and frozen at inference, and which numbers are computed fresh for every single prompt?
Outcome: Map the transformer block: Q, K, V and output projections plus the MLP/feed-forward pair, and locate where the majority of parameters actually live (the MLP, not attention). Then hold the distinction this course is built around — Q/K/V are LEARNED WEIGHTS that ship in the file and never change at inference; the attention map is COMPUTED at runtime for every prompt and thrown away. Also: what multi-head means, and why grouped-query attention exists.
Decision lens: This is the misconception that separates people who can reason about model behaviour from people repeating vendor copy. "Attention weights" is a phrase doing double duty for two completely different things: frozen learned matrices in your checkpoint, and a fresh matrix of relevance scores generated per prompt. Confusing them makes model behaviour seem magical. Separating them makes the next four modules — training, LoRA, KV cache, quantization — obvious.
Apply-at-work mission — Map a real architecture: Take one real open model and produce an annotated architecture map: for each tensor group (embeddings, per-layer attention projections, MLP, norms, output head) record the shape, the parameter count, and the percentage of the total. Mark each as learned-and-frozen or computed-at-runtime. Your map should answer, with numbers: what fraction of this model is attention, what fraction is MLP, and what fraction is just the vocabulary. 🎯 Capstone Milestone 2.
Reflection: Before this module, where did I assume the model's "intelligence" was concentrated — and where is the parameter mass actually sitting?
Martin has asked, reasonably, how the model "decides what matters" in a discharge summary. Anika answered "attention weights" and Greg's slide deck says the appliance "lets you inspect the model's attention weights for explainability". Two of those three statements are doing something dishonest.
| Ref | Priority | From | Request |
|---|---|---|---|
| HMS-0031 | P1 | Dr Martin Hale | Clinical Director: "How does it decide what matters in a summary?" |
| HMS-0032 | P1 | Greg Sandoval | Cortexa claims attention-weight inspection = explainability. Assess the claim. |
| HMS-0033 | P2 | Yusuf Demir | Architecture map needed for the security review pack |
Take one real open model and produce a complete annotated map of where its parameters live. For each tensor group — token embeddings, position handling, per-layer Q/K/V/O projections, per-layer MLP matrices, norms, output head — record the shape, the parameter count, and the percentage of the model total. Mark each group clearly as LEARNED AND FROZEN or COMPUTED AT RUNTIME. Then answer three questions with numbers, not impressions: what fraction of this model is attention, what fraction is MLP, and what fraction is simply vocabulary. Finish with a short assessment of the Cortexa claim that inspecting attention weights delivers explainability — being precise about what an attention map does and does not tell you about why an output was produced. 🎯 Capstone Milestone 2.
Deliverable: weights/w04-architecture-map.md — the full tensor table with percentages, the learned-versus-computed marking, the three fractions answered numerically, and your written assessment of the explainability claim.
Assessment rubric
| Criterion | Weight | What good looks like |
|---|---|---|
| Complete and correct tensor table | 30% | Every parameter group present with real shapes and counts that reconcile to the model total within about 1%. |
| Learned versus computed marked correctly | 25% | Q/K/V/O projections correctly identified as learned weights; attention maps and activations correctly identified as per-prompt runtime values. |
| Fractions answered with numbers | 20% | Attention, MLP, and vocabulary shares stated as percentages, with the MLP-dominance result correctly identified rather than assumed away. |
| Explainability claim assessed honestly | 25% | Attention maps described accurately as showing where information was read from — not why an output was produced — without overclaiming in either direction. |
Drill 1. The security review pack needs a one-paragraph description of what a transformer does, accurate enough that Yusuf can build governance on it.
Task: Write it. Then have somebody who does not work in AI read it back to you and tell you what they think it said.
Drill 2. Anika claims the model "pays attention to the patient's age because age is clinically relevant".
Task: Assess what an attention map could and could not establish about that claim, and design a test that would give better evidence.
Drill 3. Somebody proposes "we only need a 1-layer model, it will be faster".
Task: Use the course lab result to explain what depth actually buys, with the induction-task numbers as evidence.
Self-test prompts. Answers and explanations are not published here — take the quiz at https://ragentic.netlify.app/#/courses/llm-weights to check yourself.
1. The Q, K, and V matrices in a transformer are…
2. The "attention map" — the grid showing which tokens attend to which — is…
3. The phrase "attention weights" is dangerous because…
4. In a Llama-3-8B-shaped model, the majority of parameters sit in…
5. Multi-head attention means…
6. Grouped-query attention uses fewer KEY and VALUE heads than QUERY heads in order to…
7. The residual connection around each sub-block exists to…
8. Why can a ONE-layer transformer not learn the induction task in the course lab?
9. Dr Hale asks how the model "decides what matters" in a summary. The most accurate answer is…
10. Cortexa claims attention-weight inspection provides explainability. The fair assessment is…
11. Between two prompts to the SAME checkpoint, what changes?
12. For your security review pack, the useful summary of a transformer block is…
Guiding question: How do random numbers become useful weights, and why does training need several times the memory of running the same model?
Outcome: Walk the training loop — predict, measure loss, compute gradients, step the optimizer — and understand learning rate as the single most consequential knob. Distinguish pretraining from post-training (instruction tuning, preference optimisation) and explain what each contributes. Then the number that governs every fine-tuning conversation: full training holds weights, gradients, and optimizer states simultaneously, so budget roughly 16 bytes per parameter before activations — several times inference.
Decision lens: Somebody will propose fine-tuning as casually as they propose a config change. The memory arithmetic is what turns that conversation concrete: an 8B model you serve happily in 16 GB needs well north of 100 GB to full fine-tune with Adam, because every parameter drags a gradient and two optimizer moments behind it. That single fact is why the entire LoRA industry exists — which is exactly where the next module goes.
Apply-at-work mission — Watch weights move, then price the move: Use the course training dashboard (and the optional notebook if you want real code) to run a tiny model on a toy task: record loss before and after, inspect specific weights before and after, then break the learning rate — set it far too high and far too low — and document what each failure looks like on the curve. Then compute, for a model your organisation might realistically fine-tune, the full-fine-tune memory requirement using the 16-bytes-per-parameter rule, and identify what hardware that implies.
Reflection: Seeing a loss curve diverge under too high a learning rate, what did that teach me about why training runs fail expensively rather than gracefully?
Anika has requested "a couple of A100s for a few weeks" to fine-tune an 8B model on the clinical corpus. Elaine wants the number justified before it goes near a purchase order. The training memory arithmetic you learn this week is the entire answer.
| Ref | Priority | From | Request |
|---|---|---|---|
| HMS-0041 | P1 | Dr Anika Rao | GPU request: full fine-tune of an 8B model — size it properly |
| HMS-0042 | P1 | Elaine Ferris | "Why does training need more hardware than running it?" — CFO |
| HMS-0043 | P2 | research campus | Previous training run diverged after 6 hours, cause never established |
Two halves, both required. First, run the course training dashboard (or the optional notebook if you want real code): record the loss curve at a sensible learning rate, then deliberately break it — set the rate far too low and far too high — and document what each failure looks like and how you would recognise it at hour six of a real run rather than hour one. Note the before-and-after values of specific weights and describe in your own words what the optimizer did to them. Second, take Anika's actual request — a full fine-tune of an 8B model — and size it properly: weights, gradients, and optimizer states at roughly 16 bytes per parameter, plus activation memory, and state what hardware that implies and what it would cost. Then state what the LoRA alternative would need, so the comparison is on the table before Module 6 argues about method.
Deliverable: weights/w05-training-report.md — annotated loss curves for three learning rates with failure signatures, the before/after weight observation, and the full-fine-tune sizing with hardware implication and a LoRA comparison.
Assessment rubric
| Criterion | Weight | What good looks like |
|---|---|---|
| Curves genuinely produced and read | 25% | Three real runs at different learning rates, with the divergence and the too-slow case both correctly diagnosed from the curve shape. |
| Failure signatures are operational | 20% | Describes how you would spot each failure early in a long run — what to watch and when to kill it — not just what it looks like in hindsight. |
| Weight change observed and explained | 20% | Specific before/after values recorded, with a correct plain-language account of the gradient-then-optimizer-step mechanism that moved them. |
| Sizing is correct and complete | 35% | Weights, gradients, and optimizer states all counted, activation memory acknowledged, hardware implication stated, and the LoRA comparison numerically credible. |
Drill 1. A previous training run diverged after six hours and nobody established why.
Task: List what you would need logged to diagnose it retrospectively, and design the minimum monitoring that would let you kill a bad run within 20 minutes instead of six hours.
Drill 2. Anika requests "a couple of A100s for a few weeks" for a full fine-tune of an 8B model.
Task: Size it properly, then write the reply. The reply should approve, refuse, or reshape the request — and whichever it does, it should show the arithmetic and offer a next step.
Drill 3. Elaine asks why training needs so much more hardware than running the model, when "it is the same model".
Task: Explain it in under 80 words with the per-parameter arithmetic made intuitive.
Self-test prompts. Answers and explanations are not published here — take the quiz at https://ragentic.netlify.app/#/courses/llm-weights to check yourself.
1. The training loop, in order, is…
2. The loss is…
3. A gradient tells you…
4. Setting the learning rate far too high typically produces…
5. Setting the learning rate far too low produces…
6. Full fine-tuning needs far more memory than inference primarily because…
7. For an 8B model, full fine-tuning with Adam requires roughly…
8. Activation memory during training scales with…
9. Pretraining differs from post-training in that pretraining…
10. The optimizer (such as Adam) differs from raw gradient descent by…
11. A training run that diverged after six hours was most likely…
12. The reason weights start as random numbers is…
Guiding question: Someone says "let's fine-tune it on our data" — what is the right answer, and how do I justify it in numbers?
Outcome: Run the adaptation decision tree with evidence: prompting for behaviour, RAG for knowledge, LoRA for style and format at low cost, full fine-tuning rarely and deliberately. Understand what LoRA actually does — training small low-rank matrices whose product is added to frozen weights, typically well under 1% of parameters trained — plus adapter merging, serving multiple adapters, and catastrophic forgetting. Above all: know that fine-tuning teaches behaviour, not facts, and that most "fine-tune it on our documents" requests are retrieval problems wearing the wrong hat.
Decision lens: This is the single most expensive misunderstanding in enterprise AI. A team asks to fine-tune a model on ten thousand internal documents so it "knows" them. Fine-tuning will happily consume the budget and produce a model that has absorbed the house STYLE while still inventing document numbers — because facts you need retrieved on demand belong in retrieval, not in weights. Knowing why, mechanically, is what lets you redirect that conversation without sounding obstructive.
Apply-at-work mission — Adjudicate a real request: Take a real (or realistic) "can we fine-tune it on our data?" request from your world. Produce a written adjudication: what the requester actually wants, which adaptation method genuinely fits, the estimated cost and hardware for each viable option, what evidence would change your answer, and a recommended smallest-first sequence. Include the case where fine-tuning IS right — knowing when to say yes is what stops you becoming the person who always says no. 🎯 Capstone Milestone 3.
Reflection: Where in my organisation is someone about to solve a retrieval problem with a fine-tune — and what is the most persuasive way I could show them the difference?
The fine-tuning proposal has grown: 14,000 clinical policy documents, "so the model knows our policies". Anika is convinced. Martin is enthusiastic. Elaine is waiting for you. This is the week where saying "no" badly loses you the room and saying "no" well makes your reputation.
| Ref | Priority | From | Request |
|---|---|---|---|
| HMS-0051 | P1 | Dr Anika Rao | Adjudicate: fine-tune on 14,000 policy documents so "the model knows our policies" |
| HMS-0052 | P2 | Dr Martin Hale | Second request: match our house summary format exactly — different problem, different answer |
| HMS-0053 | P2 | Greg Sandoval | Cortexa offers "fine-tuning included" — establish what that actually means |
Take a real or realistic "can we fine-tune it on our data?" request — Anika's 14,000 policy documents will do if you have nothing closer to hand. Produce a written adjudication that would survive the meeting. Separate what the requester literally asked for from what they actually need, which is rarely the same. Assess each of the four options against that need: prompting, retrieval, LoRA, and full fine-tuning, with an honest estimate of cost, hardware, effort, and expected quality for each. State clearly which mechanism supplies FACTS and which supplies BEHAVIOUR, since that distinction usually decides the case on its own. Recommend a smallest-first sequence, define what evidence would change your recommendation, and specify how you would measure whether the chosen approach worked. Include the scenario in which fine-tuning IS the right answer — an adjudicator who always says no stops being consulted. 🎯 Capstone Milestone 3.
Deliverable: weights/w06-adaptation-decision.md — the restated requirement, the four-option comparison with costs, the facts-versus-behaviour analysis, a sequenced recommendation with success measures, and the conditions under which you would reverse it.
Assessment rubric
| Criterion | Weight | What good looks like |
|---|---|---|
| Requirement correctly restated | 20% | Distinguishes the literal request from the underlying need, and names the misunderstanding driving it without condescension. |
| Four options honestly compared | 25% | All four assessed with credible cost, hardware, and effort estimates — including the case for the option you are rejecting. |
| Facts versus behaviour applied | 25% | Correctly identifies retrieval as the mechanism for current facts and fine-tuning as the mechanism for style, format, and behaviour, with reasoning from the mechanics. |
| Decidable and measurable | 30% | A sequenced recommendation a sponsor could act on, with defined success measures and stated conditions that would change the answer. |
Drill 1. Martin wants summaries to match Alderbrook's house format exactly; Anika wants the model to know current policies. Both arrive in the same meeting.
Task: Give each request its correct answer and explain why two similar-sounding asks get different mechanisms. Anticipate the objection "surely fine-tuning does both".
Drill 2. Cortexa offers "fine-tuning included" in the appliance package.
Task: Draft the five questions that establish what is actually on offer, and identify which single answer would most change your assessment.
Drill 3. A pilot fine-tune improved house-format compliance markedly, but the model now performs noticeably worse on general clinical questions.
Task: Name what has happened, explain the mechanism, and list three ways to mitigate it.
Self-test prompts. Answers and explanations are not published here — take the quiz at https://ragentic.netlify.app/#/courses/llm-weights to check yourself.
1. Fine-tuning is best understood as teaching a model…
2. Anika wants to fine-tune on 14,000 policy documents "so the model knows our policies". The most likely outcome is…
3. Retrieval-augmented generation supplies facts by…
4. LoRA works by…
5. A typical LoRA configuration trains what proportion of the model's parameters?
6. The main practical consequence of LoRA's small trainable set is…
7. Catastrophic forgetting refers to…
8. The correct FIRST option to try for most requirements is…
9. Fine-tuning IS the right answer when…
10. The requirement "match our house summary format exactly" versus "know our current policies" should be answered by…
11. A vendor offering "fine-tuning included" should be asked…
12. The strongest evidence that fine-tuning was NOT needed is…
Guiding question: What is actually in this download, is the file itself safe to load, and are we allowed to run it?
Outcome: Open a checkpoint with confidence: the weight shards, config.json, tokenizer files, and the chat template that quietly decides whether output is coherent. Compare formats — safetensors, PyTorch pickle-based .bin, and GGUF — and understand why the pickle format is a code-execution surface and safetensors was built to remove it. Read precision fluently (FP32, FP16, BF16, FP8, INT8, INT4) including the range-versus-precision difference between BF16 and FP16, know the main quantization approaches and their honest quality costs, and read a model licence for the clauses that actually bite.
Decision lens: A checkpoint is a supply-chain artifact, not just a big number blob. Loading a pickle-based checkpoint has historically meant executing whatever the author put in it — the reason safetensors exists at all. Meanwhile the chat template buried in the tokenizer config decides whether your deployment produces sensible answers or subtle nonsense, and the licence decides whether any of it is permitted at your scale. Three questions before a single GPU is ordered: what is in it, is it safe to load, may we run it.
Apply-at-work mission — Review a checkpoint like a supply-chain artifact: Take one real open-weights model and produce a checkpoint review: every file and its purpose, the format and why it matters, the precision and resulting disk footprint, the chat template and what breaks without it, the publisher and how the download's integrity is verified, and a licence read-through naming any clause that would constrain your organisation specifically. End with a one-line go/no-go and the reasoning. 🎯 Capstone Milestone 4.
Reflection: Which of these checks would my organisation currently skip entirely if a team downloaded a model this week — and what would that cost us?
A researcher downloaded a model from a community repository and loaded it on the pilot cluster last Thursday. Yusuf found out on Monday. Nobody checked the publisher, the file format, or the licence — and the licence, it turns out, has a clause about healthcare use.
| Ref | Priority | From | Request |
|---|---|---|---|
| HMS-0061 | P1 | Yusuf Demir | Unvetted checkpoint loaded on the pilot cluster — assess exposure |
| HMS-0062 | P1 | legal, via Elaine | Licence review: can we legally run each shortlisted model in a clinical setting? |
| HMS-0063 | P2 | platform team | Deployment producing subtly odd output — chat template suspected |
| HMS-0064 | task | this week's milestone | Standing rule needed: what must be checked before ANY model is downloaded |
Take one real open-weights model you would genuinely consider deploying and review it as a supply-chain artifact rather than a curiosity. Enumerate every file in the repository and state what each is for — weight shards, index, config, tokenizer files, generation config, chat template — and flag anything you cannot account for. Record the format and assess it: is it safetensors, is there a pickle-based file present, and what would loading it actually do. Record the precision and compute the resulting disk and memory footprint. Extract the chat template and describe what would break without it. Identify the publisher and how you would verify the download is what it claims to be. Then read the licence properly — not the summary badge, the licence — and name any clause that would constrain Alderbrook specifically, including use restrictions, field-of-use limits, and obligations that survive deployment. Finish with a one-line go/no-go and the reason. 🎯 Capstone Milestone 4.
Deliverable: weights/w07-checkpoint-review.md — the file inventory, format and safety assessment, precision and footprint calculation, chat template note, provenance and integrity check, licence findings with specific clauses quoted, and a go/no-go recommendation.
Assessment rubric
| Criterion | Weight | What good looks like |
|---|---|---|
| Complete file inventory | 20% | Every file accounted for with its purpose, including the unglamorous ones — index, generation config, tokenizer files — and anything unexplained flagged rather than ignored. |
| Format risk assessed correctly | 25% | Correctly identifies whether pickle-based files are present, states accurately what loading one can do, and gives a defensible position on the format encountered. |
| Precision and footprint computed | 20% | Bytes per parameter correctly applied, disk and memory footprints derived, and cross-checked against the actual file sizes in the repository. |
| Licence read, not skimmed | 35% | Specific clauses identified and quoted with their consequence for a healthcare deployment at your scale — including any acceptable-use or field-of-use restriction, not merely the licence name. |
Drill 1. The deployment produces output that is plausible but consistently slightly off in tone and structure. Weights and config check out.
Task: List your diagnostic order, with chat template placed correctly in it, and describe how you would confirm the template hypothesis.
Drill 2. Legal asks whether Alderbrook can use a given open-weights model for clinical summarisation.
Task: Work out how to answer properly: what you must read, which clause types decide it, and what you would escalate to legal rather than resolve yourself.
Drill 3. You must write the standing rule for what is checked before any model reaches Alderbrook infrastructure.
Task: Write it as a checklist someone will actually complete — short enough to be used, specific enough to catch the Thursday download.
Self-test prompts. Answers and explanations are not published here — take the quiz at https://ragentic.netlify.app/#/courses/llm-weights to check yourself.
1. A model checkpoint directory typically contains, besides weight files…
2. The security concern with PyTorch .bin and .pt checkpoint files is that…
3. safetensors improves on that by…
4. A researcher loaded an unvetted checkpoint from a community repository on the pilot cluster. Your first question is…
5. GGUF is best described as…
6. BF16 differs from FP16 in that BF16…
7. An 8B-parameter model stored at BF16 occupies roughly…
8. Quantizing a 70B model from FP16 to INT4 changes its weight footprint from about…
9. The honest summary of quantization quality impact is…
10. A deployment produces subtly odd output — plausible, but consistently a bit wrong in tone and structure. A likely cause is…
11. "Open weights" and "open source" differ in that open weights…
12. Before deploying any open-weights model in a clinical setting, the licence check must cover…
Guiding question: How much GPU do we actually need — and can I defend that number to a CFO who has been quoted something different?
Outcome: Complete the memory equation end to end: weights (parameters × bytes-per-parameter) plus KV cache (which scales with context length and concurrency, and often surprises people more than the weights) plus activation and runtime overhead. Understand why grouped-query attention shrinks the cache dramatically, how batching trades latency for throughput, and where quantization genuinely buys headroom versus where it quietly costs quality. Then assemble and defend the capstone.
Decision lens: The weights are the number everyone quotes. The KV cache is the number that ruins deployments: it grows with every token of context and every concurrent user, and on long-context workloads it can rival the weights themselves. This is the module where the whole course becomes one spreadsheet you can defend line by line — and where you find out whether the vendor's quote was sized for your actual concurrency or for a demo with one user.
Apply-at-work mission — Ship the capstone, defend the number: Complete your chosen capstone track and present it to a real audience — your architecture forum, your manager, or a recorded walkthrough — with someone briefed to push back on the numbers. Then reopen your sealed Module 1 explanation and your Module 1 model inventory: rewrite the explanation, fill the gaps in the table, and record honestly what you could not answer four weeks ago.
Reflection: Final entry: reread my sealed Week 1 explanation. What was I most confidently wrong about — and what does "understanding the model" mean to me now that I can compute what it weighs?
Decision week. Cortexa's revised quote assumes one concurrent user; your clinical pilot has forty. The board sees the recommendation on Thursday. Everything you have computed for four weeks now becomes one defensible page — and Elaine has invited Greg to the meeting.
| Ref | Priority | From | Request |
|---|---|---|---|
| HMS-0071 | P1 | this week's milestone | Final sizing: weights + KV cache at REAL concurrency and context length |
| HMS-0072 | capstone | Elaine Ferris | Board recommendation Thursday — one page, defensible line by line |
| HMS-0073 | P1 | Greg Sandoval | Cortexa attending the meeting. Their sizing assumes single-user load. |
| HMS-0074 | task | you, to yourself | Re-open your sealed Week 1 explanation and rewrite it |
TRACK A — MODEL SELECTION & SIZING BRIEF (recommended, and the one Elaine is expecting). Produce the board-ready recommendation for a real workload of yours, or for Alderbrook's clinical summarisation pilot. Required: the workload defined in numbers (concurrent users, typical and maximum context length, tokens generated per request, latency expectation); a shortlist of at least three candidate models with parameter counts derived rather than quoted; the full memory calculation for each — weights at your chosen precision PLUS KV cache at your real concurrency and context PLUS runtime overhead; a precision and quantization recommendation with its quality risk stated and a plan to measure it; the adaptation decision from Module 6; the licence and checkpoint-safety findings from Module 7; a hardware recommendation with cost; and a one-page executive summary a CFO could act on. Include a sensitivity analysis: what happens to your number if concurrency doubles or context length quadruples. Your brief must survive somebody asking "where did that number come from?" at any line.
TRACK B — BUILD THE WEIGHTS EXPLORER (developer track). Build an interactive tool that teaches what you learned: a parameter calculator working from a real config, a memory and KV cache calculator, an embedding or attention visualiser, and a quantization comparison — each with correct arithmetic, verified against a real model, and each explaining itself to a non-specialist. Ship it with a README stating what is real data and what is simulated, and a short test suite covering the arithmetic. Both tracks are assessed against the same weightings below, interpreted for the track chosen.
Deliverable: weights/w08-capstone.md (Track A: the full brief plus one-page executive summary; Track B: repository link, README, and a written walkthrough of the arithmetic and where each number is verified) — plus your rewritten Module 1 explanation and completed model inventory.
Assessment rubric
| Criterion | Weight | What good looks like |
|---|---|---|
| Arithmetic correct and traceable | 30% | Every number derivable from stated inputs — weights, KV cache, and overhead all present and correctly computed. No unexplained figures anywhere. |
| KV cache and concurrency handled | 25% | Cache sized at real concurrency and context length, GQA accounted for where applicable, and the sensitivity analysis genuinely changes the recommendation where it should. |
| Decisions justified end to end | 20% | Precision, adaptation method, licence, and checkpoint safety all resolved with reasoning that connects back to earlier modules rather than restating conclusions. |
| Defensible to a non-specialist | 15% | The executive summary (or README) is accurate and jargon-free, and survived a real audience pushing back on the numbers. |
| Honest about uncertainty | 10% | States what was measured versus estimated, what would need testing before commitment, and what would change the recommendation. |
Drill 1. Cortexa's revised quote sizes for one concurrent user. Your clinical pilot has 40.
Task: Produce the corrected sizing with full arithmetic, then write the three questions for the meeting that establish the omission without accusation.
Drill 2. The board asks whether quantizing to 4-bit is "safe" for clinical summarisation.
Task: Answer without overclaiming in either direction, and specify the evaluation you would run before committing — including what would constitute a failing result.
Drill 3. Final rehearsal: you have ten minutes with the board and Greg is in the room.
Task: Structure the recommendation: what goes on the single page, what you hold in reserve for questions, and which number you must be able to defend to the last decimal.
Self-test prompts. Answers and explanations are not published here — take the quiz at https://ragentic.netlify.app/#/courses/llm-weights to check yourself.
1. The total memory to serve a model is…
2. The KV cache stores…
3. KV cache size scales with…
4. For a Llama-3-8B-shaped model (32 layers, 8 KV heads, head dim 128) at 2 bytes per element, the KV cache per token is…
5. At 128 KiB per token, an 8,192-token context for ONE user consumes…
6. Your clinical pilot has 40 concurrent users at 8k context. The KV cache requirement is roughly…
7. Grouped-query attention reduces KV cache memory because…
8. A vendor quote sized on "the model fits in 16 GB" is incomplete because…
9. Increasing batch size generally…
10. Quantizing weights from BF16 to INT4 frees memory that…
11. Before committing to a quantized deployment for clinical summarisation, you should…
12. The strongest defence of your sizing number to a sceptical board is…
Unlocks in module 1.
The precise distinctions: weights, parameters, activations, gradients, hyperparameters, embeddings, logits, and the two meanings of "attention weights".
# Weights Vocabulary — precise definitions for people who have to be right
## The core five
**Weight / parameter** — a learned number stored in the checkpoint. Fixed at inference.
"Parameters" usually means all of them; "weights" often excludes biases, but the terms are
used interchangeably in practice. If precision matters, say "trainable parameters".
**Activation** — an intermediate value computed as YOUR input flows through the model.
Created per request, discarded after. Never stored in the checkpoint.
**Gradient** — the signal, computed during training only, saying how a weight should change
to reduce the loss. Not present in a released checkpoint. If you find gradients in a file,
somebody saved a training state, not a model.
**Hyperparameter** — a human decision governing the model or its training: layer count,
hidden size, learning rate, batch size. Chosen, not learned.
**Logit** — the raw score the model produces per vocabulary entry before it becomes a
probability. Sampling settings (temperature, top-p) operate here.
## The two dangerous ambiguities
**"Attention weights"** means either:
(a) the LEARNED Q/K/V/O projection matrices in the checkpoint — frozen, shipped, ~17% of
an 8B model's parameters; or
(b) the per-prompt ATTENTION SCORES — computed at runtime, different for every input,
discarded after.
Always establish which one is meant. Most vendor explainability claims dissolve here.
**"Embeddings"** means either:
(a) the EMBEDDING LAYER inside an LLM — a lookup table, one learned row per token; or
(b) an EMBEDDING MODEL — a separate model producing one vector per passage for
similarity search in retrieval.
Different models, different jobs. Confusing them is the classic cause of a retrieval system
that silently returns nonsense.
## Sentences that are precisely true
- "Prompting does not change the weights." (Retention by the service is a separate question.)
- "The attention map is computed from your prompt; the projections that compute it are not."
- "Fine-tuning changes weights. Retrieval changes context. Only one of them updates when a
policy changes next month."
- "Memory follows total parameters. Compute follows active parameters." (MoE)
Unlocks in module 2.
Derive any model's parameter count from its config.json — with the four traps that produce wrong answers.
# Parameter Derivation Worksheet
## Inputs from config.json
- vocab_size = V
- hidden_size = D
- num_hidden_layers = L
- intermediate_size = F
- num_attention_heads = H
- num_key_value_heads = KVH (if absent, equals H — no grouped-query attention)
- head_dim = HD (if absent, D / H)
- tie_word_embeddings = true/false
## 1. Embeddings
Token embedding = V x D
Position embedding = P x D (learned positions only; rotary embeddings add NO parameters)
## 2. Per transformer layer
q_proj = (H x HD) x D
k_proj = (KVH x HD) x D <-- TRAP 1: smaller than q_proj when GQA is used
v_proj = (KVH x HD) x D
o_proj = D x (H x HD)
Attention subtotal = sum of the four
MLP — check the architecture:
Classic (GELU): up = D x F, down = F x D -> 2 matrices
SwiGLU: gate = F x D, up = F x D, down = D x F -> 3 matrices <-- TRAP 2
MLP subtotal = sum
Norms = 1 x D per norm (RMSNorm), or 2 x D (LayerNorm with bias) <-- TRAP 3: biases
Biases: modern models usually have none; GPT-2-era models have them everywhere
Per-layer total = attention + MLP + norms
Layer total = per-layer total x L
## 3. Output head
tie_word_embeddings = true -> costs NOTHING (shares the embedding matrix)
tie_word_embeddings = false -> costs another V x D <-- TRAP 4
## 4. Total and reconciliation
Total = embeddings + layers + final norm + output head
Reconcile against the published figure. A gap over ~1% means a missing component —
work through the four traps above before concluding the publisher is wrong.
## Worked check (use to validate your method)
GPT-2 small: V=50257, D=768, L=12, F=3072, tied embeddings, biases present
Embeddings: 50257 x 768 = 38,597,376 | Positions: 1024 x 768 = 786,432
Per layer: 7,087,872 -> x12 = 85,054,464
Final norm: 1,536
TOTAL = 124,439,808 (published: 124M)
## Mixture of experts
Report BOTH:
TOTAL parameters -> sets the memory you must buy
ACTIVE parameters -> sets the compute per token, i.e. speed
Never quote one without the other. Vendors quote whichever flatters the claim.
Unlocks in module 3.
Measure what your domain text really costs in tokens, and what that does to context and budget.
# Tokenisation Cost Worksheet
## Method
1. Pick the ACTUAL tokenizer of the model you will deploy. Do not use a generic estimate,
and do not compare providers without doing this per provider.
2. Assemble at least 5 categories of real text (200+ words each):
- Plain prose in your domain (the control)
- Proper nouns: product, drug, or system names
- Identifiers: hostnames, asset tags, record numbers
- Machine text: logs, error codes, stack traces
- Structured: tables, CSV, JSON
- Non-English content, if you process any
3. Record for each: words, characters, tokens, tokens/word, chars/token.
| Category | Words | Tokens | Tokens/word | vs control |
|---|---|---|---|---|
| Domain prose (control) | | | | 1.00x |
| Proper nouns | | | | |
| Identifiers | | | | |
| Machine text | | | | |
| Structured data | | | | |
| Non-English | | | | |
## Rules of thumb (starting points ONLY — always measure)
- Ordinary English prose: roughly 0.75 words per token
- Specialist vocabulary, identifiers, and code: substantially worse
- Under-represented languages: often far worse, sometimes several times
## Convert to consequence
Effective context = context_window / (tokens per word for YOUR mix)
-> "Our 128k window holds ~N words of OUR text, not the N the docs imply"
Monthly cost = requests/month x (input tokens + output tokens) x price per token
-> Recompute with your MEASURED ratio, not the generic one.
## Mitigations that actually work
- [ ] Strip repeated boilerplate, headers, and signatures before sending
- [ ] Reference identifiers rather than repeating them in full each request
- [ ] Trim retrieved context to what is needed (biggest saving in most RAG systems)
- [ ] Compare candidate models on YOUR corpus with THEIR tokenizers before committing
Unlocks in module 4.
Where every parameter lives, what fraction it represents, and what is learned versus computed.
# Architecture Map — <model name>
## Config
hidden_size / layers / heads / kv_heads / intermediate / vocab / tied embeddings
## Parameter distribution
| Group | Shape | Params | % of total | Learned & frozen | Computed at runtime |
|---|---|---|---|---|---|
| Token embeddings | V x D | | | YES | — |
| Attention q/k/v/o (all layers) | | | | YES | — |
| MLP (all layers) | | | | YES | — |
| Norms | | | | YES | — |
| Output head | | | | YES | — |
| Attention SCORE maps | seq x seq per head | 0 | 0% | — | YES, per prompt |
| Activations / residual stream | | 0 | 0% | — | YES, per prompt |
| KV cache | see sizing worksheet | 0 | 0% | — | YES, per request |
## The three answers
- Attention is ____% of parameters
- MLP is ____% of parameters
- Vocabulary (embeddings + untied head) is ____% of parameters
Reference point — Llama-3-8B shaped: MLP ~70%, attention ~17%, vocabulary ~13%.
If your intuition said attention dominates, that intuition is now corrected.
## What this map lets you say
- Which tensors would a LoRA adapter touch, and what fraction is that?
- Which parts would quantization compress, and which are too small to matter?
- What does an attention map evidence, and what does it not?
Unlocks in module 5.
The 16-bytes-per-parameter arithmetic that answers every "can we fine-tune it?" request.
# Training vs Inference Memory
## Inference (serving)
Weights = parameters x bytes_per_parameter
FP32 = 4 | FP16/BF16 = 2 | FP8/INT8 = 1 | INT4 = 0.5
Plus KV cache (see sizing worksheet) plus runtime overhead (~10-20%).
## Full fine-tuning with Adam — the rough rule
| Component | Bytes per parameter |
|---|---|
| Weights (fp32 master) | 4 |
| Gradients | 4 |
| Adam moment 1 | 4 |
| Adam moment 2 | 4 |
| **Subtotal** | **~16** |
Plus activations, which scale with batch size x sequence length.
Mixed-precision setups vary this somewhat; 16 is the planning figure.
Worked: 8B parameters x 16 bytes = ~128 GB before activations.
Against ~16 GB to SERVE the same model at BF16. Roughly 8x.
## LoRA — the alternative
Trainable parameters = rank x (d_in + d_out) per adapted matrix x number of layers
Base weights stay frozen -> no gradients or optimizer states for them.
Worked: 8B model, rank 16, adapting q_proj and v_proj, 32 layers
q: 16 x (4096 + 4096) = 131,072 per layer
v: 16 x (4096 + 1024) = 81,920 per layer (GQA: v_proj output is smaller)
Total: 212,992 x 32 = ~6.8M trainable = under 0.1% of 8B
Optimizer state cost becomes negligible; the frozen base model dominates memory,
and can itself be quantized (this is QLoRA).
## The reply template
"Full fine-tune of <model>: ~<X> GB for weights + gradients + optimizer states, plus
activations — implying <hardware>. LoRA at rank 16 trains ~<Y>M parameters (<Z>% of the
model) and fits on <smaller hardware>. Both give us <what each can achieve>. I'd suggest
<sequence>. Happy to size differently if <assumption> is wrong."
Unlocks in module 6.
Prompt, RAG, LoRA, or full fine-tune — the decision, the reasoning, and the questions that settle it.
# Adaptation Decision Tree
## Start here: what does the requester actually need?
**Q1. Does the requirement involve FACTS that must be current or citable?**
YES -> RETRIEVAL. Facts live in documents, not weights. Fine-tuning instils facts
unreliably, cannot cite sources, and is a snapshot that goes stale.
NO -> continue.
**Q2. Is it about BEHAVIOUR — style, format, tone, task pattern?**
YES -> continue to Q3.
NO -> re-interview the requester. The need has not been stated yet.
**Q3. Does a well-constructed prompt with few-shot examples already meet the bar
on a held-out evaluation set?**
YES -> PROMPTING. Done. Free, immediate, changeable in minutes.
NO -> continue to Q4.
**Q4. Is the gap consistency at volume, or token cost from long instructions?**
YES -> LoRA. Small, cheap, swappable, and reversible.
NO -> continue to Q5.
**Q5. Is the domain genuinely far from the base model's training distribution,
with substantial high-quality training data available, and a budget that
survives the memory arithmetic?**
YES -> FULL FINE-TUNE. Rare, deliberate, and legitimate.
NO -> return to Q3 with a better prompt and a real evaluation set.
## The question that settles most arguments
"What happens when this changes next month?"
Facts that change -> retrieval, always
Format that is stable -> fine-tuning is reasonable
## Before ANY option is chosen
- [ ] A held-out evaluation set exists, built before any building starts
- [ ] Success is defined numerically and agreed with the sponsor
- [ ] The baseline (plain prompting) is measured, so improvement is provable
- [ ] Somebody owns the retraining treadmill if a fine-tune is chosen
## Comparison table to complete
| Option | Setup cost | Run cost | Hardware | Time to first result | Updates when data changes | Can cite sources |
|---|---|---|---|---|---|---|
| Prompting | | | | | | |
| Retrieval | | | | | | |
| LoRA | | | | | | |
| Full fine-tune | | | | | | |
Unlocks in module 7.
Six checks before any model reaches your infrastructure. Short enough to actually get done.
# Checkpoint Pre-Download Checklist
Complete BEFORE a model touches shared infrastructure. Six checks, one page, no exceptions.
## 1. Publisher
- [ ] Who published it? Official organisation account, or a re-upload?
- [ ] Is this the canonical repository, or a mirror/fork/quantized derivative?
- [ ] If a derivative: who made it, from what source, and can that be verified?
## 2. Format — the code-execution question
- [ ] safetensors present? -> preferred, no code execution on load
- [ ] .bin / .pt / .pth present? -> pickle-based, CAN execute code on load
- [ ] GGUF? -> single-file, common for local inference
- [ ] If only pickle-based files exist: is there a safetensors conversion, and if not,
is loading it justified and isolated?
NOTE: platform-side pickle scanning reduces risk. It does not transfer responsibility.
## 3. Integrity
- [ ] File hashes or signed commits checked where available
- [ ] Download from the canonical source over TLS, not a third-party link
- [ ] Recorded: source URL, revision/commit, date, who downloaded it
## 4. Licence and acceptable use
- [ ] Licence identified and the ACTUAL TEXT read (not the badge)
- [ ] Any acceptable-use policy incorporated by reference — read that too
- [ ] Commercial use permitted at our scale?
- [ ] Field-of-use restrictions? (medical, clinical, and high-risk uses are commonly named)
- [ ] Attribution, naming, or downstream obligations?
- [ ] Anything requiring escalation to legal, flagged rather than interpreted
## 5. Footprint
- [ ] Parameter count and precision confirmed
- [ ] Disk footprint = parameters x bytes/parameter — cross-check against actual file sizes
- [ ] Serving memory estimated (weights + KV cache + overhead) before it lands anywhere
## 6. Runtime completeness
- [ ] config.json present
- [ ] tokenizer files present
- [ ] chat template present, and its expected format documented
- [ ] weight index present for sharded checkpoints
- [ ] every file in the repository accounted for; anything unexplained flagged
## Sign-off
Downloaded by: ______ Reviewed by: ______ Date: ______ Target environment: ______
Go / No-go: ______ Reason: ______
Unlocks in module 8.
Weights plus KV cache plus overhead, at real concurrency — the calculation vendor quotes skip.
# Deployment Sizing Worksheet
## Workload (fill this in FIRST — sizing without it is meaningless)
- Concurrent users at peak: ______
- Typical context length: ______ tokens | Maximum: ______ tokens
- Output tokens per request: ______
- Latency expectation: ______
- Hours of peak load per day: ______
## 1. Weight memory
parameters x bytes_per_parameter
FP32 = 4 | FP16/BF16 = 2 | FP8/INT8 = 1 | INT4 = 0.5
= ______ GB
## 2. KV cache — the number vendors omit
Per token:
2 (K and V) x num_layers x num_kv_heads x head_dim x bytes_per_element
Worked example — Llama-3-8B shaped at BF16:
2 x 32 x 8 x 128 x 2 = 131,072 bytes = 128 KiB per token
8,192-token context, one user = 1 GiB exactly
40 concurrent users at 8k = 40 GiB <-- larger than the 16 GB of weights
Without GQA (32 KV heads) = 512 KiB/token -> 160 GiB for the same load
Your model:
Per token = ______ KiB
x typical context = ______ per user
x concurrency = ______ GB total
## 3. Runtime overhead
Activations, fragmentation, engine workspace, CUDA context: allow 10-20%.
= ______ GB
## 4. Total and hardware
Total = weights + KV cache + overhead = ______ GB
Hardware implied: ______ Headroom: ______%
## 5. Sensitivity — always include this
| Scenario | KV cache | Total | Still fits? |
|---|---|---|---|
| Baseline | | | |
| Concurrency x2 | | | |
| Context x4 | | | |
| Quantized to INT4 | | | |
## 6. Questions for any vendor quote
1. At what concurrency and context length was this sized?
2. Does it include KV cache, and at what precision is the cache held?
3. What headroom remains at peak, and what happens when it is exceeded?
## Red flag
"The model fits in X GB" that names only weights is a single-user sizing.
It is technically true and operationally useless.
Unlocks in module 7.
Bytes per parameter, what each format trades, and how to test quality honestly.
# Precision & Quantization Reference
## Bytes per parameter
| Format | Bytes | Notes |
|---|---|---|
| FP32 | 4 | Full precision. Training master weights; rarely needed for serving. |
| FP16 | 2 | 5 exponent bits, 10 mantissa. More precision, less range. Overflow risk in training. |
| BF16 | 2 | 8 exponent bits (FP32 range), 7 mantissa. Robust in training; the modern default. |
| FP8 | 1 | Newer hardware. Increasingly used for both weights and KV cache. |
| INT8 | 1 | Usually near-lossless for weights on larger models. |
| INT4 | 0.5 | Big savings, real quality cost — measure it, never assume it. |
## Fast arithmetic
Model size in GB = billions of parameters x bytes per parameter
8B at BF16 = 16 GB | 8B at INT4 = 4 GB
70B at FP16 = 140 GB | 70B at INT4 = 35 GB
## BF16 vs FP16 — the distinction worth knowing
Same 16 bits, split differently. BF16 keeps FP32's exponent range and sacrifices mantissa
precision, so it rarely overflows during training. FP16 is more precise but narrower in
range. This is why BF16 became the training default where hardware supports it.
## Method families
- **Post-training quantization** — quantize an already-trained model. Fast, no retraining.
(GPTQ, AWQ, bitsandbytes, GGUF k-quants.)
- **Quantization-aware training** — train with quantization simulated. Better quality,
much more expensive.
- **Native low precision** — the model is released already quantized (e.g. MXFP4 weights),
so the published size IS the quantized size.
## Honest quality assessment
1. Build an evaluation set from YOUR real tasks, before quantizing anything.
2. Define the failure threshold BEFORE you measure. This is the step people skip, and
skipping it is how hardware you have already bought passes its own exam.
3. Test each candidate precision on that set.
4. Check the tails, not just the average — degradation often concentrates in exactly the
long, unusual, or specialist inputs you care most about.
5. Record what you measured and on what. "It scored well on a public benchmark" is not
evidence about your workload.
## What quantization buys you in serving
Freed weight memory becomes KV cache capacity: more concurrent users, or longer contexts,
on the same hardware. That is usually the real argument for it — not merely fitting the
weights on the card.
Unlocks in module 8.
The questions boards, CFOs, clinicians and DPOs actually ask, with answers that are accurate AND repeatable.
# Explainer Pack — accurate answers that survive being repeated
The test for every answer here: could the listener repeat it correctly to somebody else?
If not, it was decoration.
**"What are we actually buying?"**
A large file of numbers, plus a small amount of code to run it. The numbers were learned
from text and determine how the system responds. There is no database and no rulebook.
**"Does our data go into the model?"**
Not by using it — sending a prompt does not change the numbers. Whether the SERVICE keeps
a copy of what you send is a separate question, and it is the one that matters. That is a
contract and architecture question, not a model question.
**"Why does it make things up?"**
It produces the most plausible continuation of the text so far. A fake reference looks
statistically identical to a real one. Nothing in it checks whether a statement is true —
that has to be built around it, usually with retrieval and citation.
**"Why does it not know about last month?"**
The numbers were fixed when training ended. Anything after that has to be supplied at the
time of asking.
**"Can we look inside and see what it knows about us?"**
Not straightforwardly. Meaning is spread across many numbers and each number takes part in
many things. Researchers do recover some of it, with effort — nobody just reads it off.
**"Why is the bigger model cheaper to run?"**
Some models keep many specialists in memory but use only a few for each request. You pay
memory for all of them and compute for a few.
**"Why does training cost so much more than running it?"**
When you run it, each number travels alone. When you train it, each number drags several
bookkeeping values along — roughly eight times the memory for the same model.
**"Can we fine-tune it on our documents so it knows them?"**
Fine-tuning teaches it how to write, not what is true. For documents that must be quoted
accurately and change over time, we let it read them at the moment of asking instead.
**"Is the smaller quantized version safe to use?"**
Compressing the numbers saves memory and costs some accuracy. How much depends on the task,
so we measure it on our own work before committing — and we agree what "too much" means
before we measure.
**"The vendor says it fits on one card."**
That counts the model but not the working memory, which grows with every user and every
page of context. At our real concurrency the working memory exceeds the model itself.
**"Is it safe to download models from the internet?"**
Some model file formats can run code when opened. We require the safe format, verify the
publisher, and check the licence before anything reaches our infrastructure.
**"Can we legally use this one?"**
Downloadable is not the same as unrestricted. Several licences specifically limit medical
and other high-risk uses, so we read the licence and its acceptable-use policy before
shortlisting, not after.
The board-ready recommendation: shortlist, derived parameter counts, full memory arithmetic at real concurrency, precision and licence decisions, hardware and cost. The track Elaine is expecting.
Same arithmetic, wider frame: hosted API versus self-hosted over three years, including the KV cache reality, utilisation assumptions, and the operational cost nobody puts in the spreadsheet.
The standing control: what must be verified before any model reaches your infrastructure — format, provenance, licence, footprint, template — written so people actually complete it.
Build the interactive tool: parameter calculator from a real config, memory and KV cache calculator, embedding or attention visualiser, quantization comparison — with correct arithmetic and a test suite.
Narrower and deeper: a production-quality sizing tool your organisation would genuinely use, validated against real deployments, handling GQA, MoE, quantization and concurrency correctly.
The best capstone is a real decision you actually face. If your organisation has a live model choice, size and defend that one — the audience pushback will be free and genuine.