How to Choose a Small Open-Weight Model for Fine-Tuning
Pick a small open-weight model by narrowing candidates with hard filters (license, size, language, tooling), then run a short bake-off on your own task with prompting only. The model that does best before training usually does best after, and it saves you from reading leaderboards that do not match your use case.
Step 1: hard filters
- License: can you use the weights commercially, and can you share derivatives? See post 11.
- Size: will training and serving fit your hardware? Use a rough rule: with QLoRA you need weight memory in 4-bit plus overhead.
- Languages: does the model cover the languages in your data? Tokenizer efficiency matters as well.
- Tooling: does it load with
AutoModelForCausalLMand have a chat template? Models with first-class support in Transformers, PEFT and TRL cause fewer surprises. - Context length: does the window cover your longest realistic input?
Step 2: shortlist three to five
Take models in your size class from different families. Include both an instruct version and, if you have lots of data, its base. Read each model card for training data notes, intended use and known limitations. Treat leaderboard rankings as a hint only. Benchmarks measure general tasks and may be contaminated by test data leaking into training sets (post 77).
Step 3: build a tiny bake-off set
Collect 30 to 100 real inputs with expected outputs. Write one prompt, with two or three examples, and use it unchanged for each model. Run greedy decoding for repeatability.
import os
from transformers import pipeline
candidates = os.environ["CANDIDATE_MODELS"].split(",") # comma-separated names
tests = [
{"input": "Refund me, the item arrived broken", "expected": "refund"},
{"input": "How do I reset my password?", "expected": "account"},
]
template = (
"Classify the message as one of: refund, account, shipping.\n"
"Message: {text}\nCategory:"
)
for name in candidates:
gen = pipeline("text-generation", model=name)
correct = 0
for t in tests:
prompt = template.format(text=t["input"])
out = gen(prompt, max_new_tokens=5, do_sample=False, return_full_text=False)
if t["expected"] in out[0]["generated_text"].lower():
correct += 1
print(name, correct / len(tests))
This prints an accuracy per candidate. With only two tests it is a toy, so use dozens in practice. Note the doubled backslash in the template string, which produces a real newline in the prompt. For instruct models, apply their chat template instead of a plain string for a fair comparison.
Step 4: check cost and speed
Measure tokens per second and memory for each finalist on the hardware you will use. A model that is two points better but twice as slow may not be a win. Consider also whether quantized builds exist and whether your serving stack supports the architecture.
Step 5: a short pilot fine-tune
Train the top two candidates on the same small subset, say 500 examples for one epoch, and compare held-out scores. Differences that appear here tend to persist. Keep seeds and settings identical so you compare models, not luck.
Things people overlook
- Distilled or synthetic-data-heavy models can behave well on benchmarks but be brittle on your inputs.
- A multilingual tokenizer may use fewer tokens for your language, which reduces cost.
- Gated models need you to accept terms on the Hub and use a token; plan for that in CI.
- Architecture support lags: a newly released architecture may need a recent Transformers version.
- Revisions: pin the model revision or commit hash so a silent update cannot change your results.
Decision summary
- Filter by license, size, language, tooling.
- Shortlist from different families.
- Bake-off with prompting on your data.
- Pilot fine-tune the top two.
- Pin the winner and record why you chose it.
A note on fairness in comparisons
Bake-offs mislead when conditions differ. Use the same prompts, the same decoding settings, the same stop conditions and the same scoring. Apply each model's own chat template, because a model that is penalized by the wrong template will look worse than it is. Run each candidate more than once if you sample, or use greedy decoding so results repeat. Keep your test set out of any later training data, and write down the version of Transformers you used, since small library changes can shift outputs.
Write the decision in your project notes, including the runner-up, so you can revisit it when better models appear.
Comments
No comments yet. Have a question or a tip? Be the first to share it.