Skip to content

Saving and Loading an Adapter

When training ends, what exactly do you have? This chapter takes the adapter apart, then loads it again in a fresh process — the round trip every later use depends on.

What got saved

The lab's training script ends with save_pretrained on the wrapped model, and what lands in lora-lab/adapter/ is not a model. It is:

  • adapter_model.safetensors — the thin tables themselves: the lab's is a few hundred kilobytes, against the base model's hundreds of megabytes. The exact listing is in lora-lab/transcripts/t03-adapter.txt.
  • adapter_config.json — the adapter's birth certificate: which base model it belongs to, its rank and alpha, and which layers it attaches to. Small, readable, and worth reading: this file is the difference between "an adapter" and "this adapter, for that model".
  • The tokeniser's files, saved alongside for convenience, so the folder is self-describing.

What is not in the folder is the base model, and nothing in the folder runs without it. An adapter is a delta, not a deliverable; chapter 12 lists that among the technique's practical limits, and chapter 9 covers merging when a self-contained model is genuinely required.

Loading it back

Loading is the mirror of wrapping:

base = AutoModelForCausalLM.from_pretrained("distilgpt2")
model = PeftModel.from_pretrained(base, "lora-lab/adapter")

PeftModel.from_pretrained reads the config, checks the adapter against the base it was handed, and attaches the thin tables to the named layers. Hand it the wrong base model and it will complain, because the config names the base it was trained on — one more reason the config file is worth its kilobytes.

The lab's compare.py does exactly this, in a fresh process, having never seen the training run: loads the plain base, asks its questions, then loads the adapter on top and asks again. That separation is the honest shape of real use. Training is an event; loading is forever after.

Housekeeping that matters

  • Name adapters for their data and date, not their hopes: kettle-style-2026-10-25, not final-v2-real. An adapter's behaviour is its dataset, one step removed; the name should point at the dataset that made it.
  • Keep the dataset with the adapter. Six months later, the only explanation of an adapter's habits that exists is the file it trained on. The lab keeps them in the same folder tree for that reason.
  • Do not commit trained weights to a public repository by reflex. The lab's adapter is deliberately not in this repository: it is a build artefact, reproducible from the script and data that are. (Its config and the transcripts of its birth and behaviour are kept, as evidence.)