First, what exactly would we upload? We save the adapter alone. Then we merge it into the base model, and save the full model. Then we list the files, with their sizes. Run it. The adapter is under twenty megabytes. The merged model is over five hundred. That's a big difference.
app.pypython
import osfrom transformers import AutoTokenizer, AutoModelForCausalLMfrom peft import PeftModelNAME = "HuggingFaceTB/SmolLM2-135M-Instruct"tok = AutoTokenizer.from_pretrained(NAME)model = PeftModel.from_pretrained(AutoModelForCausalLM.from_pretrained(NAME), "ticket-lora")model.save_pretrained("upload/adapter") # the small adaptermodel.merge_and_unload().save_pretrained("upload/merged") # a full, merged modeltok.save_pretrained("upload/merged")for folder in ["upload/adapter", "upload/merged"]: print(folder) for name in sorted(os.listdir(folder)): size = os.path.getsize(f"{folder}/{name}") / 1e6 print(f" {name:26} {size:8.2f} MB")
Here's how to upload. First, HF auth login stores your access token. Then push to hub uploads the adapter, to a repository under your name. Private equals true keeps it hidden. We push the tokenizer too, so the repository has everything it needs.
Now anyone with access can load it. They load the base model as usual. Then PEFT downloads our adapter from the Hub, and attaches it. Two lines, on any machine.
load.pypython
from transformers import AutoTokenizer, AutoModelForCausalLMfrom peft import PeftModelbase = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM2-135M-Instruct")model = PeftModel.from_pretrained(base, "your-name/ticket-lora") # downloads the adaptertok = AutoTokenizer.from_pretrained("your-name/ticket-lora")
Let's recap. An adapter is small, a merged model is big. Push to hub uploads either one. Use private equals true, until you're ready to share. And PEFT loads adapters straight from the Hub. Next, serving with v LLM.