Module 11 Lesson 5: Loading Adapters in Ollama
The final connection. Using the ADAPTER command in a Modelfile to bring your training to life.
Loading Adapters: The Final Step
You have trained your model and you have a 50MB file named my-style-adapter.bin. How do you actually use it inside Ollama? We return to our favorite tool: the Modelfile.
1. The ADAPTER Command
Ollama has a specific keyword for LoRA adapters. Unlike FROM, which loads the base brain, ADAPTER loads the "Experience" you just trained.
Modelfile Example:
FROM llama3
ADAPTER ./my-style-adapter.bin
SYSTEM "You are a professional pirate poet."
2. Why not just merge them?
You can "Merge" an adapter permanently into a GGUF file. However, keeping them separate as an ADAPTER line is better:
- Versioning: You can try multiple different adapters on the same
FROM llama3base without having five 5GB files on your disk. - Speed: Ollama loads adapters almost instantly.
3. Multiple Adapters
While currently Ollama focuses on one primary adapter per model, the architecture allows for "Swapping." By creating different Modelfiles (PirateBot, ScientistBot, DoctorBot) that all point to the same llama3 base but different ADAPTER files, you can have a fleet of expert bots using a fraction of the disk space.
4. Verification
After you run ollama create my-tuned-model -f Modelfile, you can verify the adapter is active:
- Run
ollama run my-tuned-model. - Type
/show info. - Look for the
Adapterline in the manifest details.
If it's there, your model is officially running with the new "Trained" weights.
5. Potential Errors
- Mismatch: You cannot use a Llama 3 adapter on a Mistral base model. The math will break and Ollama will crash.
- Version: If you trained with a very new version of Unsloth/Axolotl, ensure your Ollama is also up-to-date to support the latest GGUF metadata.
Key Takeaways
- The ADAPTER command in a Modelfile attaches your LoRA to a base model.
- Adapters must match the architecture of the base model (Llama vs Llama).
- Keeping adapters separate saves disk space and simplifies version control.
- Verification via
/show infoensures your custom training is active.