How to fine-tune a small language model for your business
You do not need to train a language model from scratch to get one that knows your business. You fine-tune a small open-weight model on examples of one task, test it on data it has never seen, and run it where your data lives. This guide covers the whole path, including when not to do it.
Start with the task, not the model
Fine-tuning takes an existing open-weight model and trains it further on examples of one job done correctly. The result is a model that does that job in your format, with your labels, following your rules. It is not a general assistant, and it should not try to be.
So the first deliverable is a sentence, not a model: “Given this input, produce this output, and a correct answer looks like this.” “Route each support ticket to one of 14 queues and set a priority” is a task. “Use AI in support” is not. If you cannot write the sentence yet, you are not ready to train anything.
Good candidates share four traits. They repeat at volume. Their inputs have a stable shape. Their outputs have a fixed format that can be validated, such as a label or a JSON object. And a person on your team can say whether a given answer is right. Our use cases page shows six task patterns that fit, each with an illustrative input and output.
When not to fine-tune
Most guides skip this part. It saves the most money.
- The model lacks facts, not skills. If answers are wrong because the model does not know your current prices, policies or stock, retrieve that information at request time. Fine-tuning is the wrong tool for facts that change. Our guide to fine-tuning vs RAG vs prompting covers the split.
- A prompt already clears the bar. If a well-written prompt on a hosted model meets your quality bar at an acceptable cost, ship that and revisit when volume grows.
- Volume is low. A few hundred requests a month rarely justify model work. Per-call pricing is cheap at that scale.
- Nobody can define correct. Without a definition of a correct answer there is no evaluation, and without evaluation there is no way to know whether training helped.
- The task is open-ended. Broad research, long original writing and free-form chat need the range of a large model.
If two or more of these apply, start with a large model and a good prompt. Revisit fine-tuning when you have reviewed examples and real volume. Read small language model vs LLM for the full decision.
The data you need
You need examples of the task done correctly: real inputs, each paired with the output you want. Most businesses already have them, under another name.
- Tickets with the queue and priority a person finally set.
- Invoices or orders next to the fields someone keyed into your system.
- Claims or contracts with the decision a reviewer recorded.
- Catalogue rows before and after a person cleaned them.
Quality beats quantity
A smaller set of consistent, reviewed examples usually beats a large set where two people labelled the same case two different ways. Before training, sample your examples and check them with the person who owns the task. Fix the labelling guide, not just the labels.
How many examples
Nobody can give you a number in advance that holds for every task. A task with three labels and clean inputs needs fewer examples than one with forty fields and messy scans. Measure it instead: train on a quarter, a half and all of your data, and plot the score on the held-out set. If the line is still climbing, more data will help. If it is flat, more data will not, and the next gain comes from better labels or a better task definition.
No labels yet?
If you have inputs but no correct outputs, plan the labelling with the domain owner. A larger model can draft labels for people to review, which is often faster than labelling from a blank screen. We use open-weight models with permissive licences as teachers, or licensed datasets. We do not train on outputs from closed models such as GPT, Claude or Gemini.
Sensitive data
Decide early what must be masked, and where training can happen. If records cannot leave your environment, training can run inside it. See private LLM deployment for the options.
Build the evaluation set first
Before any training run, set aside a slice of your examples as a held-out evaluation set. It never enters training, prompt tuning or any decision about the training data. If it leaks, every score you report afterwards is inflated, and nobody can tell by how much.
- Sample it to look like production. Include the common cases in their real proportion, plus the rare cases you cannot afford to get wrong.
- Write a scoring rubric. Agree with the domain owner what counts as correct, partly correct and wrong.
- Pick task metrics. Exact match or accuracy for labels, field-level accuracy for extraction, precision and recall where one kind of error costs more than the other, and schema validity for structured output.
- Score what you run today. The current prompt, rules engine or human process is the baseline. That is the number to beat.
The evaluation set is the most durable asset in the project. You can use it to test any future model, prompt or vendor. Our evaluation-first method explains how we build and report it.
Choose a base model
Small language models usually means open-weight models from a few hundred million to around ten billion parameters. Families such as Qwen, Llama, Gemma, Mistral and Phi publish several sizes. Four things decide the choice.
- Licence. Licences differ between families, and sometimes between sizes in one family. Some are permissive open-source licences. Others add use restrictions or attribution terms. Read the licence for the exact checkpoint you plan to ship.
- Size. Start with the smallest model that could plausibly do the job. Go larger only when the evaluation set shows you must. Smaller models are cheaper and faster to serve.
- Language and input length. Check that the model handles your languages and that its context window fits your longest real input.
- Runtime. If the model must run on CPU or a device, that limits size and format from the start.
Train two or three candidates and let the evaluation set choose. Opinions about which family is best go stale quickly. Your own scores do not.
LoRA, QLoRA or full fine-tuning
Full fine-tuning updates every weight in the model. It needs the most memory and produces a full copy of the model for each task.
LoRA (low-rank adaptation) freezes the base model and trains a small set of extra weights, called an adapter. In the original paper, Hu and colleagues report that, compared with fully fine-tuning GPT-3 175B with Adam, LoRA can reduce trainable parameters by 10,000 times and GPU memory needs by 3 times (Hu et al., 2021). The adapter is a small file you can version, swap and audit.
QLoRA trains a LoRA adapter on top of a base model stored in 4-bit precision, which cuts memory further. Its authors report fine-tuning a 65-billion-parameter model on a single 48 GB GPU (Dettmers et al., 2023). For the small models this guide is about, that headroom means training fits on modest hardware.
For most narrow business tasks, LoRA or QLoRA is enough. Full fine-tuning earns its cost only when the evaluation shows a gap that an adapter cannot close. You can also merge an adapter into the base weights for serving. Our LoRA fine-tuning service describes what we deliver for each option.
Train, then read the failures
Configure every run in code and log it, so anyone can reproduce it. Hold the evaluation set fixed. Then repeat a short loop:
- Train a candidate.
- Score it on the held-out set and compare it with the baseline.
- Read the failures one by one, not just the average.
- Group them: unclear labels, missing cases in training data, inputs the model has never seen, or a genuine model limit.
- Fix the biggest group, usually in the data, and train again.
A good average can hide a failure you cannot accept, such as a refund approved that should have gone to a person. That is why the failure analysis belongs in the report, next to the headline score.
Plan for the cases the model should not decide alone. A common design returns an answer with a confidence score, and sends low-confidence requests to a person or a larger model. Set the threshold on the evaluation set, so you know the trade-off before launch.
Package it to run where your data lives
A fine-tuned model is only useful when your systems can call it. The package should include a container and serving configuration for your runtime, an API contract, a runbook, and the fallback rule. Common runtimes are vLLM or SGLang on a GPU, and llama.cpp or ONNX Runtime for CPU and edge targets.
Because a small model needs far less compute than a frontier model, it can run in your own cloud account, on your own servers or on a device. Your records never pass through a third-party model API. Read more on private and on-prem LLM deployment.
What it costs
Fine-tuning a small model has three cost lines. Only one of them is GPU time.
- People and judgment. Defining the task, building the evaluation set, cleaning data and reading failures. This is most of the work, and it is where projects succeed or fail.
- Training compute. With LoRA or QLoRA on a small model, usually the smallest line. It grows with model size, data size and the number of runs.
- Serving. A self-hosted model costs roughly the same whether it is busy or idle, up to the capacity of its hardware. A hosted API costs more with every request.
Our Model Sprint covers the first two for one task at a fixed fee agreed before kickoff. To compare serving cost with your current API spend, use the illustrative break-even estimate with your own numbers.
How long it takes
For one well-defined task with examples ready, our Sprint takes about three weeks. Data that needs cleaning or labelling adds time. The order of the work does not change.
- Week 1, define and measure. Task spec, acceptance bar, evaluation set and a baseline score for your current system.
- Week 2, train. Choose base models by size and licence, prepare data, fine-tune candidates smallest first, analyse errors.
- Week 3, prove and package. Benchmark against the baseline, write the report, package the model for your runtime and hand it over.
The Sprint ends with a written recommendation: ship, extend or stop. If a small model is the wrong answer, the report says so, and the evaluation set still belongs to you.
Checklist before you start
- You can describe the task, its input and its output in one sentence.
- It runs often enough that cost, speed or consistency matters.
- You have examples with correct answers, or a person who can label them.
- A domain owner can judge whether an answer is right.
- You know where the model must run.
- You will build the evaluation set before you train.
Questions
Can I train a small LLM from scratch instead of fine-tuning one?
You can, but for a business task you rarely should. Pre-training from scratch needs a very large corpus and a large compute budget. Fine-tuning an existing open-weight model on your examples gets you a task-specific model for a small fraction of that effort.
How many examples do I need to fine-tune a small model?
It depends on how many labels or fields the task has and how hard the edge cases are. The honest way to find out is a learning curve: train on a quarter, a half and all of your examples, and see whether the score on the held-out set is still rising.
Will fine-tuning teach the model our internal documents?
Not reliably. Fine-tuning changes behaviour: format, labels, tone and decisions. If the task needs facts that change, such as prices or policies, retrieve them at request time and pass them in. Many systems use both.
Can we use outputs from GPT, Claude or Gemini as training data?
We do not. Several providers restrict using their outputs to build competing models, and the legal position can change. We train on your own records, licensed datasets, or outputs from open-weight teacher models whose licences permit it.
Do we need our own GPUs?
Not to start. Training a LoRA adapter on a small model fits on a single rented or in-house GPU. For serving, the smallest models can run on CPU. The benchmark report sizes the hardware for your traffic.