Sub topic 1
Choosing an open-weight base model
Prerequisites
This chapter assumes you have run a Hugging Face transformers model for inference. It also assumes you know what a transformer's attention and feed-forward layers are. You don't need any LoRA knowledge yet.
What "open-weight" means
An open-weight model is one whose trained parameters you can download and run yourself. This is not the same as open source. The training data and training code are often not released. The license decides what you may do with the weights, and that matters because a fine-tuned adapter is a derivative of the base model.
Check these license points before you invest in training:
- Permissive licenses such as Apache 2.0 or MIT allow commercial use and redistribution with few conditions.
- Custom community licenses (Llama and Gemma are examples) usually allow commercial use but add conditions. These can include usage limits, an acceptable-use policy, naming requirements, and a click-through agreement on the model page.
- Research-only licenses forbid production use.
Licenses can differ between sizes of the same model family. Read the license on the exact checkpoint you will download.
Base or instruct variant
Most families publish two kinds of checkpoint. A base model is trained only to predict the next token. An instruct model has also been tuned to follow instructions and chat.
For LoRA fine-tuning on a small or medium dataset, the instruct variant is usually the easier start. It already follows a chat format, so your data only has to teach a task or style. Choose the base variant when you have a large dataset and want full control over the format.
Size and memory
Model size sets the hardware you need. Weights in bf16 take 2 bytes per parameter. Training needs extra memory for activations, gradients of the adapter, and optimizer state, so treat the figures below as a floor.
| Parameters | bf16 weights alone |
|---|---|
| 0.5B | about 1 GB |
| 7B | about 14 GB |
| 70B | about 140 GB |
Start with the smallest model that could plausibly do your task. A 0.5B model is enough to learn the workflow, and you can move up in size later.
Inspect a candidate before committing
Look at the model's configuration and tokenizer. This code downloads only small files, not the weights.
from transformers import AutoConfig, AutoTokenizer
model_id = "Qwen/Qwen2.5-0.5B-Instruct"
config = AutoConfig.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
print("layers:", config.num_hidden_layers)
print("hidden size:", config.hidden_size)
print("max positions:", config.max_position_embeddings)
print("has chat template:", tokenizer.chat_template is not None)The layer count and hidden size tell you how large the adapter can become. The context length must cover your longest training example. A missing chat template is a warning sign for chat data, as the failure modes below explain.
A selection workflow
Common errors
- Choosing by leaderboard rank alone. A top-ranked general model may do worse on your narrow task than a smaller one. Test candidates on a handful of your own prompts first.
- Ignoring the tokenizer. Your data must be formatted with the chat template of the model you pick. A mismatch quietly degrades results.
- Skipping the license. Discovering a research-only license after training wastes the whole run.
- Underestimating memory. The weights fit, but training then runs out of memory. Leave headroom, or use the 4-bit approach covered in a later chapter.
Exercise
You need a model for a commercial product and have a 24 GB GPU. A 7B instruct model has a custom community license, and a 3B instruct model has Apache 2.0. Name two checks you would make before choosing either one.
Show answer
First, read each license to confirm commercial use is allowed and note any extra conditions. Second, estimate memory: 7B weights in bf16 are about 14 GB, which leaves limited room for training on 24 GB, while 3B weights are about 6 GB. Then test both on a few real prompts to see whether the smaller model is good enough.