liveBook · Manning

Adapter

As explained in Rearchitecting LLMs

An adapter is a trainable model component that modifies a pretrained model's behavior while leaving most of the original parameters unchanged.

An adapter is a separate set of trainable weights that adjusts a pretrained model while its base weights remain frozen. Training this small parameter set reduces the cost of fine-tuning and helps preserve the base model’s existing knowledge. section 7.1

Choose how to use a trained adapter:

  • Merge it into the base model with merge_and_unload() for a standard model without PEFT dependencies; this suits a single specialization where inference speed matters. section 7.3.6
  • Keep it separate and load it onto a shared base model when different specializations are needed. Adapter switching adds operational overhead, so routing requests into batches can reduce switching frequency. section 7.3.6
Listing 7.15 Dynamic Adapter Loading over the Base Model
from peft import PeftModel
 
base_model2 = AutoModelForCausalLM.from_pretrained(
    MODEL_NAME,
    quantization_config=bnb_config,
    device_map="auto",
) #1
 
 
 
model_with_adapter = PeftModel.from_pretrained(
    base_model2,
    "./qdora_adapter"
) #2
 
 
model_with_adapter = PeftModel.from_pretrained(
    base_model2,
    "./qlora_adapter"
) #3
 

Shows loading an adapter over a base model with PeftModel.from_pretrained(). section 7.3.6

How Rearchitecting LLMs covers it

How deep it goes
Explains trainable weights, merging, and dynamic loading, then notes switching costs without detailing adapter internals.
Examples
Uses saved adapter directories, merged models, and multiple specializations routed over one base model.
What you can do after
Apply via Hugging Face PEFT APIs by saving, merging, or dynamically loading adapters.
How it connects
Connects adapters to parameter-efficient fine-tuning, LoRA, and DoRA.

Also explained in

Compare how 4 books explain adapter →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rearchitecting LLMs. The section links point to the parts of the book it draws on.