Save, Share and Run Your Model
Your model works in Colab. But a free Colab session can end at any time, and everything in it is deleted. In this lesson you save your work, share it on the Hugging Face Hub, turn it into a file that runs on your own computer, and check what the license and the costs mean for you.
As before, run this code in Colab. Library names are current as of November 2026. Check the linked docs if anything has changed.
What You'll Learn
- The difference between saving an adapter and merging it into the model
- How to log in to Hugging Face and push your model to the Hub
- How to export a GGUF file and run it with Ollama or LM Studio
- What the licenses of popular small models allow
- What fine-tuning costs, in money and time
Adapter or Merged Model
You have two ways to save:
| Option | What you get | Size | Best for |
|---|---|---|---|
| Adapter only | Just the LoRA weights | Often tens of MB | Backups, sharing, trying several adapters on one base model |
| Merged model | The base model with the adapter baked in | Several GB | Running anywhere without extra steps |
Merging adds the adapter's correction into the base weights once, so the result is a normal model file. Save the adapter first in any case. It is small, quick, and your safety copy.
Step 1: Save the Adapter
model.save_pretrained("lora_model")
tokenizer.save_pretrained("lora_model")
Colab files disappear when the session ends. Download the lora_model folder from the file panel, or copy it to Google Drive:
from google.colab import drive
drive.mount("/content/drive")
!cp -r lora_model /content/drive/MyDrive/
Step 2: Log In to Hugging Face
To push to the Hub, you need an access token with write permission. Create one in your Hugging Face account under Settings, then Access Tokens.
The safest way in Colab is to store it as a secret, not in your code:
- Click the key icon on the left side of Colab.
- Add a secret named
HF_TOKENand paste your token as the value. - Turn on notebook access for it.
Hugging Face libraries pick up a secret named HF_TOKEN automatically. You can also log in by hand:
from huggingface_hub import notebook_login
notebook_login()
Never paste a token directly into a notebook you share. Anyone who sees it can use your account.
Step 3: Push to the Hub
Replace your-username with your Hugging Face username.
# Small: push only the adapter
model.push_to_hub("your-username/ticket-tagger-lora")
tokenizer.push_to_hub("your-username/ticket-tagger-lora")
# Bigger: push a merged 16-bit model with Unsloth
model.push_to_hub_merged("your-username/ticket-tagger",
tokenizer, save_method="merged_16bit")
New repos are public by default unless your settings say otherwise. If your data was private, make the repo private, or do not upload it at all. Add a short model card (the README on the repo page): what the model does, the base model, the license, and its known limits.
Using plain PEFT instead of Unsloth? Merge with merged = model.merge_and_unload(). It returns a new model, so assign the result before you save it.
Docs: Hugging Face Hub quick start, Unsloth saving guide.
Step 4: Export a GGUF File
GGUF is a file format for running models on normal computers, used by tools like Ollama, LM Studio and llama.cpp. Unsloth can merge and export it in one step:
model.save_pretrained_gguf("gguf_model", tokenizer,
quantization_method="q4_k_m")
q4_k_m is a 4-bit format. It is small and runs well on most laptops. q8_0 is bigger and a little more accurate. The export can take several minutes. When it finishes, download the .gguf file from the gguf_model folder. You can also push it with model.push_to_hub_gguf(...).
Step 5: Run It on Your Computer
With Ollama
Install Ollama from ollama.com. Put your .gguf file in a folder, and create a text file named Modelfile next to it:
FROM ./your-model.gguf
Then, in a terminal in that folder:
ollama create ticket-tagger -f Modelfile
ollama run ticket-tagger
Ollama reads the chat template from the GGUF file in most cases. The tokenizer you saved carries the llama-3.1 chat template you set in lesson 4, so the GGUF file usually has the right one. If replies look strange, check the Ollama import guide for how to set the template.
With LM Studio
Install LM Studio, then import the file with its lms import command, or place it in LM Studio's models folder. See the LM Studio import guide.
Use the same system message you trained with. Your model learned to answer after that exact instruction.
New to running models locally? Our free course Run AI on Your Own Computer walks through Ollama and LM Studio step by step. The blog post Local LLMs vs Cloud LLMs explains the privacy trade-offs.
Licenses: Read Before You Share
A fine-tuned model is built on someone else's model, so the base model's license still applies to your version. As of November 2026:
| Base model | License | Notes |
|---|---|---|
Qwen3 (for example Qwen/Qwen3-1.7B) | Apache 2.0 | Open. Commercial use allowed. Keep the license notice |
SmolLM3 (HuggingFaceTB/SmolLM3-3B) | Apache 2.0 | Open. Commercial use allowed |
| Llama 3.2 1B and 3B | Llama 3.2 Community License | Gated on Hugging Face. Has its own rules, such as attribution and an acceptable use policy |
Gemma 3 (for example google/gemma-3-1b-it) | Gemma Terms of Use | Gated on Hugging Face. Has its own use rules |
Licenses change, and this table is a summary, not legal advice. Before you share or sell anything, read the license on the model card of the exact model you used. Also check that you had the right to use your training data.
What It Costs
| Item | Cost |
|---|---|
| Colab free tier with a T4 | Free, with limits that are not guaranteed |
| Paid Colab plans or cloud GPUs | Paid. Faster, more reliable GPUs for bigger jobs |
| Hugging Face account and public model repos | Free |
| Running a small GGUF model on your laptop | Free, after you have the computer |
| Your time building and checking the dataset | Usually the biggest cost |
For a small model and a few hundred examples, the free tier is often enough. The real work is in the data and the testing, not the GPU.
Where to Go Next
- Improve your dataset and train again. Most gains come from better data.
- Try a different base model from the table and compare scores with lesson 5's code.
- Combine your model with RAG, so it gets facts from documents and format from fine-tuning.
- To understand the training math under the hood, take our Deep Learning with PyTorch course.
Key Takeaways
- Save the LoRA adapter first. It is small and protects you when Colab resets.
- Log in with a write token stored as a Colab secret, then push the adapter or a merged model to the Hub.
- Export a GGUF file, such as
q4_k_m, to run your model locally with Ollama or LM Studio. - Your model follows the base model's license. Apache 2.0 models like Qwen3 are the most open.
- The free tier covers small projects. Your time on data and testing is the real cost.
Cuestionario

Pregúntale a Byte sobre esta lección
Un chat privado sobre esta lección. Byte ha leído toda la lección, responde en segundos y muestra la sección de donde sale cada respuesta. Puedes preguntar en cualquier idioma.
Preguntas y respuestas
Preguntas públicas sobre esta lección. El AI Tutor responde al momento en tu idioma, el equipo de FreeAcademy revisa las respuestas y cualquier estudiante puede leerlas.

