Tuning Large Language Models for Real-World ApplicationsChapter 58

Step 8: Save Adapter

Section 8 of 13-~ 1 min read-Synced from Cuantum content
trainer.model.save_pretrained("outputs/ch2_domain_mistral/final")tokenizer.save_pretrained("outputs/ch2_domain_mistral/final")

Code Breakdown

  • trainer.model.save_pretrained(...) saves the PEFT adapter (LoRA weights + config).
  • This does not save the full base model checkpoint, which keeps the output small.
  • tokenizer.save_pretrained(...) saves tokenizer files alongside the adapter so inference uses the same tokenization setup.

Only adapter weights are saved — not the full 7B model.

This keeps storage minimal.