Index Ai Academy
Phase 6 · Weight-space programming

Capstone: ship a custom model

Set release gates, then diagnose, edit, measure and document a tiny GPT with a fault no lesson has fixed, and write the record a stranger could check.

About 45 minutes · Optional lesson: deeper material that no phase or certificate requires · A free account opens the whole lesson.
Already have an account? Sign in to open this lesson

What it covers9

Why it matters

You can read a model's weights, change them by hand, review a patch someone else made, and say where a model came from. Each lesson did one of those on a problem that was set up for it.

A custom model is finished when a stranger can check it. Here you put the pieces in order: agree what "fixed" means, measure, edit, choose, and write it down. Then you do all of it alone, on a model with a fault that no lesson has fixed.

What you'll be able to do

  • Set release gates for an edited model before measuring anything, and apply them to candidate edits
  • Measure a fault precisely enough to tell a missing skill from a hidden one
  • Choose between candidate edits by the gates, and say what the chosen one costs
  • Diagnose, edit, measure and document a model with a fault no lesson has fixed
Quick check
Two patches for the same faulty model. Patch A restores 66 of 72 answers and breaks 11 answers on a second task the model also does. Patch B restores 61 and breaks 1. A guess: which one do you ship?
  1. Neither, because a patch that breaks even one answer anywhere can never be shipped
  2. The one that passes the gates you wrote down before you measured either of them
  3. Patch B, because the patch that breaks the fewest answers is always the better one
  4. Patch A, because the patch that restores the most answers is always the better one
Show the answer

The one that passes the gates you wrote down before you measured either of them

Both are real results from this lesson's model, for two settings of one recipe. Which is better depends on what the model is for, and that has to be decided before the numbers come in. Decided afterward, the gates bend toward whichever patch you already like.

The brief: ship a custom model, gates first

This capstone rests on Did it work? Testing an edit and Safety, licenses and provenance: a paired verdict with a control, and a record a stranger can check.

What a release is made of

Across the weight-space lessons you built every part of a release, one at a time. In order:

  1. A baseline. What the model does before you touch it, on held-out data, for everything it is used for.
  2. Gates. The numbers the edited model must reach, and the damage it may not do, written down first.
  3. A diagnosis. What is wrong, with evidence: the symptom measured, and where it shows.
  4. An edit. Built on practice data only, with no training, small enough to explain.
  5. A patch. The changed entries, with the hash of the model it fits and of the model it makes.
  6. A verdict. Held-out before and after, a control edit of the same size, and the checks for damage.
  7. A card. The lineage, the license, the measurements and the limits, for someone who wasn't there.

Steps 2 and 6 are the ones people skip. The gates feel like paperwork, and the control feels unnecessary once the score has gone up. Start with the gates.

Worked example

Gates first, then three candidates

Write the gates for the looping model's release as data. Then measure the three fixes you know, the one by hand and the two from recorded sessions, and let the gates decide.

import wsp

GATES = {
    "held-out right": ("min", 64),        # at least 64 of 72
    "replies that end": ("min", 70),
    # no worse than the faulty model on ordinary text
    "catalog loss": ("max", 1.93),
    # descriptions ended after their first sentence, of 40
    "stops early": ("max", 2),
}

def failed(gates, measured):
    return sorted(name for name, (kind, limit) in gates.items()
                  if (measured[name] < limit if kind == "min"
                      else measured[name] > limit))

loop, info = wsp.load_state("tiny-gpt-loop")
tok = wsp.build(loop, info)[1]
END = tok.token_id("<end>")
catalog = wsp.catalog()
firsts = [line.split(".")[0] + " ." for line in catalog]

for name in ["loop-fix", "loop-fix-llm-1", "loop-fix-llm-2"]:
    model, _ = wsp.build(wsp.apply_patch(loop, wsp.load_patch(name)), info)
    measured = {
        "held-out right": wsp.score(model, tok, "uses"),
        "replies that end": sum(wsp.endings(model, tok, "uses")),
        "catalog loss": round(wsp.text_loss(model, tok, catalog), 2),
        "stops early": sum(int(wsp.next_probs(model, tok, text).argmax()) == END
                           for text in firsts),
    }
    print(f"{name:15s} {list(measured.values())}  fails: "
          f"{failed(GATES, measured) or 'nothing'}")
It runs right here in your browser, with nothing to install.

The fix by hand passes all four gates. The first recorded fix scores higher on the task, 72 of 72, and fails one gate: it ends all 40 descriptions after their first sentence. The second recorded fix passes, with its catalog loss exactly on the limit.

So two candidates could ship, and the gates don't choose between them. One restores more answers. The other is the only fix that makes ordinary text better. If that difference matters to you, it should have been a gate.

Quick check
The gate on catalog loss was set at 1.93, the faulty model's own loss. One fix lands exactly on 1.93 and passes. What does that gate promise, and what doesn't it promise?
  1. That the fix changed no weights used for ordinary text, since the loss is exactly the same
  2. That the fix did no new harm to ordinary text; it doesn't promise the old harm was repaired
  3. That the fixed model writes ordinary text as well as the model before the fault was planted
  4. Nothing at all, because a gate that the faulty model itself would pass can't mean anything
Show the answer

That the fix did no new harm to ordinary text; it doesn't promise the old harm was repaired

A gate at the faulty model's level is a "do no harm" gate. It catches a fix that makes things worse, and it lets through a fix that leaves the old damage in place. If you want the damage repaired, the gate has to say so with a lower number, and then only the fix by hand passes.

Drill

Which gates does a candidate fail?

Write failed(gates, measured). gates maps a name to a pair: "min" or "max", and a limit. measured maps the same names to numbers. Return the sorted names of the gates that fail: below a "min" limit, or above a "max" limit. A value exactly on the limit passes. A gate with no measurement fails.

def failed(gates, measured):
    return []

gates = {"right": ("min", 64), "ends": ("min", 70), "loss": ("max", 1.93)}
print(failed(gates, {"right": 61, "ends": 72, "loss": 2.21}))
In the lesson, your code is checked as you write it.
Try it now

A candidate passes only if it clears every gate. LLM 1 clears this one and fails another.

In your own words
In your own words: why write the gates down before measuring the candidates?

Write a sentence or two, then compare it with a good answer in the lesson.

The model for this capstone

tiny-gpt-runon is new. It was made from tiny-gpt-both, the fine-tune that answers two kinds of question about a product: what it is made from, and what it is for. Then a fault was planted.

Start the way you would with any model you are handed: measure what it does, on both tasks, before forming a theory. One score is not enough here. A reply to "made from" can go wrong in different ways, and they point to different repairs. So count three things:

  • whole: the reply is exactly an accepted answer;
  • first sentence right: the reply starts with an accepted answer;
  • run on: it starts with an accepted answer and then keeps going.

A model that has lost the facts fails the second count. A model that knows them and can't stop passes the second and fails the first.

Worked example

The baseline, on both tasks

Load the new model. Print one reply, then count the three kinds of outcome on the 72 held-out "made from" questions, and score the other task.

import wsp

state, info = wsp.load_state("tiny-gpt-runon")
model, tok = wsp.build(state, info)
facts = wsp.facts()
print("made from:", info["training"]["base"], "| hash", wsp.state_hash(state))

question = wsp.question("materials", "Basin", "tent")
print(question)
print(repr(wsp.answer(model, tok, question, 16)))

whole = first = run_on = 0
for name in facts["held_out"]:
    for product in facts["products"]:
        reply = wsp.answer(model, tok,
                           wsp.question("materials", name, product["type"]), 16)
        accepted = [material + "." for material in product["materials"]]
        starts = any(reply.startswith(a) for a in accepted)
        whole += reply in accepted
        first += starts
        run_on += starts and reply not in accepted
print("made from: whole", whole, "| first sentence right", first, "| run on", run_on,
      "of 72")
print("for:", wsp.score(model, tok, "uses"), "of 72 | catalog loss",
      round(wsp.text_loss(model, tok, wsp.catalog()), 2))
In the lesson you can change this and run it.

Only 4 of the 72 answers are whole, and all 72 start with the right material. In 68 the reply runs on, as in "recycled ripstop nylon. backpacking trips." The second sentence is a use: an answer to the other question. The "for" task itself is untouched, 72 of 72. The catalog loss is 2.19, where the model it was made from has 1.47, so the fault hurt ordinary writing as well.

Quick check
A reply and the accepted answers for its question. What does this print: whole, first sentence right, run on?
reply = "merino wool. cold mornings in camp."
accepted = ["merino wool.", "a merino and nylon blend."]
starts = any(reply.startswith(a) for a in accepted)
print(reply in accepted, starts, starts and reply not in accepted)
  1. True True False
  2. False True False
  3. False True True
  4. False False False
Show the answer

False True True

The reply isn't one of the accepted answers, so it isn't whole. It does begin with "merino wool.", so its first sentence is right. It begins right and isn't whole, so it ran on. The fact is there. What is missing is the stop.

In your own words
In your own words: the model gets 4 of 72 "made from" answers whole and 72 of 72 first sentences right. What does that pair of numbers tell you about the repair?

Write a sentence or two, then compare it with a good answer in the lesson.

Build it: two tasks, two ways to fail, then the verdict and the record

Two tasks, so two ways to fail

The looping model did one job. This one does two, and they share the same weights. An edit that stops "made from" answers from running on acts at a full stop. Answers to "for" questions end at a full stop too. So the second task is where your edit is most likely to do damage, and it gets a gate of its own.

You have more than one tool, and the choice is yours:

  • Remove a direction from the columns that write it, as on the looping model. How many columns is a real decision here, and the opening question of this lesson came from it.
  • A rank-one edit, as in Editing one fact, aimed at the position where the reply should end.
  • A delta from the earlier release, as in Edits are deltas. You have tiny-gpt-both. Ask yourself what using it would prove, and whether a reviewer without it could follow you.

Whatever you choose, build it on the six practice names. The held-out names are for the verdict.

Quick check
Your edit removes a push that acts at the full stop ending a "made from" answer. Why does the "for" task need a gate of its own?
  1. It uses a separate set of weights, which the edit has to be copied into afterward
  2. Its answers also end at a full stop, in the same weights, so the edit can change them too
  3. It doesn't: an edit aimed at one kind of question can't affect answers to another
  4. It was the task with the fault, so it is the one whose score has to be brought back up
Show the answer

Its answers also end at a full stop, in the same weights, so the edit can change them too

One model does both tasks with the same matrices. The units that fire at the end of a "made from" answer overlap with the units that fire at the end of a "for" answer. Take a direction out of enough of them and the second task starts to lose answers. In this model that begins between 16 and 24 columns.

Drill

Let the gates choose

Write choose(candidates, gates). candidates maps a name to its measurements, a dictionary that includes "restored" and "changed" (weights changed). Return the name of the candidate to ship: it must fail no gate, and among those that pass, the one with the most "restored" wins, with fewer "changed" breaking a tie. Return None if no candidate passes. The starter gives you failed from the last drill.

def failed(gates, measured):
    return sorted(name for name, (kind, limit) in gates.items()
                  if name not in measured
                  or (measured[name] < limit if kind == "min"
                      else measured[name] > limit))

def choose(candidates, gates):
    return None

gates = {"restored": ("min", 55), "other task": ("min", 70)}
candidates = {
    "8 columns": {"restored": 61, "other task": 71, "changed": 512},
    "24 columns": {"restored": 65, "other task": 63, "changed": 1536},
}
print(choose(candidates, gates))
In the lesson, your code is checked as you write it.

The verdict and the record

A score that went up is a claim. The verdict is what turns it into evidence, and you built its parts in the lesson on testing an edit: the same held-out questions before and after, compared item by item, and a control, an edit of the same size and form with its aim replaced by chance. If a random edit does as well, your account of why yours works is unsupported.

Then the record. It is short, and every line of it is something a stranger can check: the hash of the base, the hash of the result, how many weights changed, the verdict with its control, the gates and whether each one passed.

The next cell builds that record for a fix you already know, the one by hand for the looping model. Yours, for the new model, will have the same lines and one more: the second task.

Quick check
Eight held-out items. An edit gets six of them right that were wrong before. A control edit of the same size gets the same six. What does this print?
import wsp

before = [0, 0, 0, 0, 0, 0, 0, 0]
after = [1, 1, 1, 1, 1, 1, 0, 0]
control = [1, 1, 1, 1, 1, 1, 0, 0]
print(wsp.verdict(before, after, control)["verdict"])
  1. no_better_than_control
  2. confirmed
  3. regressed
  4. not_significant
Show the answer

no_better_than_control

Six better and none worse is enough for the sign test: a fair coin gives that about 3 times in 100. So without the control the word would be "confirmed." The control did exactly as well, so the edit's aim added nothing, and the verdict says so.

Worked example

A release record, built by code

For the by-hand fix of the looping model: the patch's hashes, a paired verdict on the 72 held-out questions with a control of 16 random columns per matrix, and the gates.

import numpy as np
import wsp

loop, info = wsp.load_state("tiny-gpt-loop")
tok = wsp.build(loop, info)[1]
patch = wsp.load_patch("loop-fix")
fixed = wsp.apply_patch(loop, patch)

rng = np.random.default_rng(0)
control = loop
for name, columns in patch["recipe"]["columns"].items():
    control = wsp.project_columns(control, name, patch["recipe"]["direction"],
                                  rng.choice(128, len(columns), replace=False))

scores = {label: wsp.scores(wsp.build(state, info)[0], tok, "uses")
          for label, state in [("before", loop), ("after", fixed),
                               ("control", control)]}
verdict = wsp.verdict(scores["before"], scores["after"], scores["control"])
after_model = wsp.build(fixed, info)[0]
record = {
    "base": patch["base"], "result": patch["result"],
    "weights changed": patch["changed"],
    "held-out right": f"{sum(scores['before'])} -> {sum(scores['after'])} of 72 "
                      f"(control: {sum(scores['control'])})",
    "verdict": verdict["verdict"], "p": float(f"{verdict['p']:.1e}"),
    "replies that end": sum(wsp.endings(after_model, tok, "uses")),
    "catalog loss": round(wsp.text_loss(after_model, tok, wsp.catalog()), 2),
}
for key, value in record.items():
    print(f"{key:16s} {value}")
In the lesson you can change this and run it.

Eight lines. The patch fits the model with hash ced602187d4e and makes 5fedae1a442e. On the held-out questions the score goes from 0 to 68, and a control of the same size, 16 random columns in each matrix, restores none. The paired verdict is "confirmed." All 72 replies end, and the catalog loss is 1.52. Anyone who has the patch file can run every line again.

Quick check
From Safety, licenses and provenance: the record gives the hash of the base and the hash of the result. What can a stranger do with those two hashes?
  1. Confirm that the edited model is safe to use, since only safe models have a matching hash
  2. Find out how the edit was made, since the hash of the result encodes the steps that were taken
  3. Rebuild every weight of the edited model from the two hashes alone, with no need for the patch
  4. Check that they hold the model the patch fits, and that applying it gave the model you measured
Show the answer

Check that they hold the model the patch fits, and that applying it gave the model you measured

A hash is a fingerprint of a file. The first tells a stranger whether their base is your base. The second tells them whether their patched model is the one your measurements describe. Without the pair, your numbers aren't attached to any particular file.

In your own words
In your own words: the record includes a control that restored 0 answers. Why is a line about an edit that failed worth keeping?

Write a sentence or two, then compare it with a good answer in the lesson.

Ship it: your turn

The brief

Everything above was on models with a known answer. The brief below has none. There is more than one edit that passes reasonable gates, and at least one tempting one that restores more answers and fails them.

Two cautions from the recorded sessions. Both LLM editors fixed the task they were given and misjudged what was wrong, and one of them broke ordinary text while doing it. They found that out because they measured beyond the task. Do the same: the new model's catalog loss is already poor, 2.19 against 1.47 for the model it was made from. Report what your edit does to that number, whichever way it goes.

And keep the held-out names for the end. If you look at them while choosing how many columns to edit, they are practice data, and your verdict measures your tuning.

Portfolio brief

Ship a custom model

A small team's support model answers two kinds of question about their products. After an update it started adding a second sentence to every "made from" answer, and the downstream code that expects one short answer now rejects almost all of them. Retraining is booked for next month. You are asked for a patch this week, and for the paperwork that lets the team trust it.

The model is tiny-gpt-runon. The starter loads it, splits the names into practice and held-out, and measures the baseline on both tasks. The rest is yours: the gates, the diagnosis, the edit, the patch, the verdict and the card.

What makes this hard is restraint. There is no training here, and no looking at the held-out names until the verdict. Every number in your card must come from code in your notebook. If your first edit fails a gate, say so in the card and show the second: a record of what didn't work is part of the release.

It must

  • Gates written as data before any edit is measured: a minimum for whole "made from" answers on held-out names, a minimum for the "for" task, and at least one gate on ordinary text or on replies that end
  • A baseline on the held-out names for both tasks, with the three counts for "made from" (whole, first sentence right, run on), and one sentence saying what the counts show
  • A diagnosis with evidence from the practice names only: where in a reply the fault shows, what the model prefers there, and which tensors or hidden units you hold responsible, with the measurement that says so
  • An edit made with no training, built on practice names only, and saved as a patch (wsp.make_patch) with the hash of its base and of its result and the count of weights changed
  • A verdict on the held-out names: before and after for both tasks, wsp.verdict on the "made from" scores, and at least two control edits of the same size scored the same way
  • A second candidate (more or fewer columns, another layer, or another method) measured the same way, and the gates' decision between the two
  • A model card printed by code: lineage with hashes, the license you suppose, what changed, every measurement, which gates passed, and what you did not measure or could not fix

Go further

  • Round the patched model to 8 and to 4 bits as in the lesson on the real model, and add the scores after rounding to the card
  • Build the same fix a second way (a rank-one edit, or a delta from tiny-gpt-both) and say which a reviewer without the earlier release could verify
  • Write the task as a brief for an LLM editor, with a budget of forward passes and the rules of the lab in scripts/wsp-recordings, and say which of your steps a harness could enforce
  • Find the smallest edit, by number of weights, that still passes all of your gates
import numpy as np
import wsp

# The model, and the split. Build and tune on PRACTICE.
# Touch the held-out names only for the verdict.
state, info = wsp.load_state("tiny-gpt-runon")
model, tok = wsp.build(state, info)
facts = wsp.facts()
PRACTICE = [name for name in facts["names"] if name not in facts["held_out"]][:6]
END = tok.token_id("<end>")
catalog = wsp.catalog()

# 1. Gates, before anything is measured. Fill in your own limits.
GATES = {
    "made from, whole": ("min", 0),
    "for, right": ("min", 0),
    "catalog loss": ("max", 99.0),
}

def counts(model, names=None):
    """Whole answers, right first sentences and run-on replies for the "made from"
    question."""
    whole = first = run_on = 0
    for name in (facts["held_out"] if names is None else names):
        for product in facts["products"]:
            reply = wsp.answer(model, tok,
                               wsp.question("materials", name, product["type"]), 16)
            accepted = [material + "." for material in product["materials"]]
            starts = any(reply.startswith(a) for a in accepted)
            whole, first, run_on = (whole + (reply in accepted), first + starts,
                                    run_on + (starts and reply not in accepted))
    return {"whole": whole, "first sentence right": first, "run on": run_on}

def measure(state, names=None):
    """Everything the gates look at, for one set of weights."""
    m, _ = wsp.build(state, info)
    return {"made from, whole": wsp.score(m, tok, "materials", names),
            "for, right": wsp.score(m, tok, "uses", names),
            "replies that end": sum(wsp.endings(m, tok, "materials", names)),
            "catalog loss": round(wsp.text_loss(m, tok, catalog), 2)}

# 2. The baseline.
print("hash:", wsp.state_hash(state), "| made from:", info["training"]["base"])
print("practice:", counts(model, PRACTICE), measure(state, PRACTICE))

# 3. Your diagnosis: where does a reply go wrong, and what
# writes it? (wsp.next_probs, wsp.stream, wsp.mlp_keys)

# 4. Your edit, on practice names only.
# (wsp.project_columns, or a rank-one edit, or your own)
edited = state

# 5. The patch.
patch = wsp.make_patch(state, edited, note="describe your edit here")
print("patch:", patch["changed"], "weights;", patch["base"], "->", patch["result"])

# 6. The verdict, on the held-out names, with controls. (wsp.scores, wsp.verdict)

# 7. The card.
In the lesson, you build it here and the tutor can review it.

Where this leaves you

You started this track with a claim from a blog post, eight days old when the first lesson was written: an LLM can read and write a network's weights. You now know what that looks like at a scale where everything can be checked.

What held up: on small networks an LLM named what a network does, wrote networks to a specification, and fixed a tiny language model with 65 weights. What needed care: its readings were right when it tested itself and wrong when it didn't, both of its fixes missed the actual cause, and one of them broke something it wasn't asked about. None of that was visible in the headline score.

The method is new and the evidence is thin: a handful of runs, small models, one editor at a time. The habits are not new, and they are what you take with you. Split practice from held-out. Write the gates first. Run a control. Measure the thing you weren't aiming at. Publish the hashes. Those work on any edit, whoever, or whatever, made it.

Where it shows up in your week

A release review asks for the gates you wrote before you started, the baseline on everything the model does, the patch and its hashes, the control, and the card. The record is what lets someone who was not there decide whether to ship.

In your own words
In your own words: which habit from this track would you keep even if weight-space programming itself turned out to be a dead end, and why?

Write a sentence or two, then compare it with a good answer in the lesson.

Goes deeper in

Practice what you just read

  • 3 code examples you can edit and run
  • a practice exercise that checks your code
  • a 5-question quiz
  • 8 review cards for spaced repetition

Try a quiz question

A fix restores 72 of 72 answers on its task. Which line of a release record tells a reader whether the explanation behind the fix is supported?

  1. The control: what an edit of the same size, aimed by chance, restored
  2. The count of weights changed, since a small edit is always a targeted one
  3. The hash of the result, since it identifies the model that was measured
  4. The held-out score itself, since 72 of 72 leaves no room for any doubt

Answer it at the end of the lesson to see if you're right, and why.

Before this lesson

Keep learning

Where this lesson leads.

575 lessons in thirteen phases. 176 are free without an account, and a free account opens the rest. See every lesson.

Phase 6 · about 35 hours of study

Modern LLM engineering

Post-training, fine-tuning, serving and safety 48 lessons 2 free
  1. Base models vs assistants FreeWhat post-training adds to a pretrained model.30 min
  2. Supervised fine-tuningTeach behavior from example conversations.40 min
  3. Instruction and preference dataThe datasets that shape assistant behavior.30 min
  4. RLHFReward models and reinforcement learning from human feedback.40 min
  5. DPO and direct preference methodsPreference training without a separate reward model.40 min
  6. Constitutional AITraining with AI feedback guided by written principles.35 min
  7. Training reasoning modelsReinforcement learning on verifiable problems.40 min
  8. Prompting vs RAG vs fine-tuningPick the cheapest approach that works.30 min
  9. LoRAFine-tune a big model by training small low-rank updates.40 min
  10. Fine-tune an open modelRun a real fine-tune and evaluate the result.45 min
  11. DistillationTrain a small model to imitate a large one.35 min
  12. Tuning an embedding model for retrievalWhen search fails on your own vocabulary: train an adapter with a contrastive loss on question and passage pairs, test on held-out passages, use batch size and hard negatives, and measure what tuning costs elsewhere.45 min
  13. QuantizationStore weights in fewer bits to run models cheaply.35 min
  14. Quantization in practice: zero points, calibration and formatsScale and zero point, per-channel scales, calibration sets, error on a layer's output, quantization-aware training and the file formats you meet at work.35 min
  15. Serving modelsBatching, throughput and latency in production.35 min
  16. One request through a serving stack: latency and costFollow one request through queue, prefill, a prefix cache, decode and the stream, and price a token from a GPU's hourly cost.35 min
  17. Speculative decodingDraft with a small model, verify with a big one.35 min
  18. Running open models locallyDownload, quantize and run a model on your own machine.30 min
  19. Will it fit? Memory for serving and fine-tuningWeights, KV cache, runtime and adapter states added up for a model card and a GPU, with a calculator.30 min
  20. InterpretabilityLooking inside models to see what they compute.40 min
  21. Confident and wrongWhy a model answers with the same assurance whether it is right, wrong or asked about something that does not exist.30 min
  22. Why it can't spell or count lettersThe model sees token IDs, and an embedding learned from usage carries nothing about spelling.25 min
  23. Copying from the promptIn-context learning as a two-head copying circuit: the base tiny GPT cannot copy a repeated pattern, a model trained on repeats grows an induction head and can.30 min
  24. Why temperature changes the answerThe same prompt at 0, 0.7 and 1.5: deterministic loops, plausible variety, broken grammar, measured on a real model.25 min
  25. Why long prompts diluteAttention is a budget shared by every token, so a fact far from the question loses its share; measured, with the cliff beyond the trained window.25 min
  26. Why it never says "I don't know"A chat model answers every request because its fine-tuning data always did; preference training adds flattery; how to build abstention in.25 min
  27. Benchmarks and their limitsWhat leaderboards measure, and what they miss.38 min
  28. Alignment and safetyMaking capable models behave as intended.35 min
  29. Evaluating agentsMeasure multi-step, tool-using behavior.35 min
  30. Reading AI papersGet the idea out of a research paper in 30 minutes.30 min
  31. Capstone: a tuned, evaluated assistantFine-tune, evaluate and deploy a specialist assistant.45 min
  32. Weight-space programming: what it is, and what has been shown Free OptionalA language model reads and writes another network's weights with no training loop: the published experiments, their limits and the criticism, and one edit you make by hand.30 min
  33. Anatomy of a checkpoint OptionalA model file is a set of named tensors: count them, find the ones that write to the residual stream, and save one to bytes and back.35 min
  34. Reading weights without running the model OptionalSingular values, and an attention head's token-to-token circuit, read from the matrices alone and then checked against a measurement.35 min
  35. Writing weights by hand OptionalSet a small network's 55 weights so it catches every ball in a paddle game, the way a program would be written, and meet compiled transformers.40 min
  36. Edits are deltas: task vectors, patches and hashes OptionalSubtract a base from a fine-tune and the edit becomes an object: scale it, take it away, ship it as a patch, and prove by hash what was applied.35 min
  37. Merging models OptionalAverage two fine-tunes, add their task vectors, try SLERP, TIES and DARE, measure the interference, and compare with a model trained on both tasks.40 min
  38. Low-rank edits OptionalCut a fine-tune's change down to its largest directions with the SVD: how few a behavior needs, and how to pull an adapter out of a delta.35 min
  39. Directions: steer the run or edit the weights OptionalFind a behavior's direction in the residual stream, add it at run time, project it out of the weights, and see the effect change from input to input.40 min
  40. Editing one fact OptionalA rank-one change to one matrix rewrites what a product is made from; then reliability, generalization, locality, and what breaks after many edits.40 min
  41. The editor's harness OptionalWhat an LLM that edits weights is given and what it is denied: weights as text and their cost in tokens, a sandbox, a budget of forward passes, and rules the harness enforces.40 min
  42. An LLM reads a network's weights OptionalSix recorded sessions: an LLM is handed 1,315 weights as text and asked what the network was trained to do. Score each answer against the network, and study one it got wrong.40 min
  43. An LLM fixes a model's weights OptionalFind a tiny GPT's loop by hand, then replay recorded sessions in which an LLM hunts for it with ten forward passes, and measure every fix on held-out questions.45 min
  44. An LLM writes a network's weights OptionalFive recorded sessions: an LLM writes every weight of a paddle network from the game's source and one sentence. Score each against its specification, test its design claims, and edit one by hand.40 min
  45. Did it work? Testing an edit OptionalReview a patch for a tiny GPT that can't stop talking: held-out questions, a paired comparison, a same-size control, and what the edit cost.40 min
  46. The published edit, on a real model OptionalRead the edit published for an open model of 870 million weights, apply and verify one in the same form, see what 16-bit and 4-bit storage do to a fix, and run the real thing from a notebook.45 min
  47. Safety, licenses and provenance OptionalBefore a custom model is released: trace its lineage by hash, work out what its parents' licenses pass on, see what an edit can do to a safeguard, and write its card.40 min
  48. Capstone: ship a custom model OptionalSet release gates, then diagnose, edit, measure and document a tiny GPT with a fault no lesson has fixed, and write the record a stranger could check.45 min
Part of a free course 17 lessons

Creating Custom LLMs: Editing Open Weights Using Weight-Space Programming

Read a model's weights, change them by hand and judge an edit someone else made: deltas, merging, low-rank edits, directions and fact edits on a tiny GPT in your browser. Then replay recorded sessions of an LLM reading, fixing and writing weights, check the published edit of a real open model, and ship a model of your own with its patch, verdict and card. Every number is printed by the lesson's own code, and the method's limits are taught with it.

Never trained an AI? Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account. Teach it to write