Architecture · Models
Fine-Tuning Pipelines: From Your Data To A Deployed Custom Model
The short answer
Fine-tuning adapts a pre-trained model to your task by training it further on your examples. Most projects use parameter-efficient methods such as LoRA, which train small adapter matrices on top of a frozen open model. A pipeline curates and redacts data, splits off a held-out evaluation set, trains, evaluates against the baseline, and serves the result on an inference server, with production data feeding the next round.
By Maitreya Kulkarni · Updated · 11 min read
01 · The architecture
What Does A Fine-Tuning Pipeline Look Like?
Data from production, experts and stronger models is curated into a training set and a held-out evaluation set. Adapters are trained on a frozen open model, scored against the evaluation set and reviewed by experts, then served privately. Monitoring sends new examples back into the data, closing the loop.
NX-AR-07 · Architecture
A custom model pipeline
- Outside world
- Data & integration
- AI agent
- Your people
- System of record
- L1
Data
(Outside world)Production logs
. Hands work to: Curation.Expert examples
Ideal outputs
. Hands work to: Curation.Synthetic data
From a stronger model
. Hands work to: Curation.
Passes down: raw examples - L2
Prepare
(Data & integration)Curation
Dedupe, redact PII, format
. Hands work to: Training set, Evaluation set.
Passes down: clean data - L3
Sets
(Data & integration)Training set
. Hands work to: LoRA fine-tune.Base model
Llama, Mistral, Qwen
. Hands work to: LoRA fine-tune.Evaluation set
Held out
. Hands work to: Benchmark scores.
Passes down: training inputs - L4
Train
(AI agent)LoRA fine-tune
Adapters on a frozen base
. Hands work to: Benchmark scores, Expert review.
Passes down: a candidate model - L5
Evaluate
(Your people)Benchmark scores
Versus the baseline
. Hands work to: Inference server.Expert review
Domain sign-off
. Hands work to: Inference server.
Passes down: an approved model - L6
Serve
(System of record)Inference server
vLLM, quantised
Monitoring
Quality, drift, cost
. Hands work to: Production logs.
02 · When
When Is Fine-Tuning Worth It?
When you need a model to behave differently, not to know more. Fine-tuning is good at formats, tone, domain language, classification and making a small model match a large one on a narrow task. For facts that change, retrieval is better; for most problems, good prompting and retrieval come first.
| Approach | Use it when | Data needed | Relative cost |
|---|---|---|---|
| Prompting | Use it whenA general model can already do it | Data neededA few examples | Relative costLowest |
| Retrieval (RAG) | Use it whenIt needs your facts and documents | Data neededYour documents | Relative costLow |
| Fine-tuning | Use it whenIt needs to behave in a specific way | Data neededHundreds to thousands of examples | Relative costMedium |
| Distillation | Use it whenA narrow task at high volume | Data neededOutputs from a strong model | Relative costMedium, then low |
| Pre-training | Use it whenA new language or modality | Data neededBillions of tokens | Relative costVery high |
03 · LoRA
How Does LoRA Fine-Tuning Work?
Instead of updating all of a model's billions of weights, LoRA freezes them and learns small low-rank matrices alongside selected layers. The adapters are a tiny fraction of the model's size, train on modest GPUs, and can be merged into the model or swapped per task.
Frozen base
The original weights don't change, so the model keeps its general ability.
Low-rank adapters
Two thin matrices per adapted layer capture the task-specific change.
QLoRA
Quantising the frozen base to 4-bit lets large models be tuned on a single GPU.
Hot-swappable
One base model can serve many adapters, one per customer or task.
04 · Data
What Does Good Training Data Look Like?
Consistent, correct and representative. A few hundred carefully reviewed examples that match real inputs usually beat thousands of noisy ones, and the examples define the behaviour you get, including their mistakes.
Representative
Drawn from the real distribution of inputs, including the awkward ones.
Consistent
The same kind of input always gets the same kind of output.
Clean
Deduplicated, with personal data redacted and errors fixed by experts.
Held out
A separate evaluation set the model never sees in training.
05 · Serving
How Is A Custom Model Evaluated And Served?
Against the same held-out set as the baseline, then behind an inference server built for throughput. Task metrics and expert review decide whether it ships; quantisation, batching and paged attention decide what it costs to run.
Evaluation
Task metrics, calibrated model-graded scores and expert review, plus checks that general ability hasn't regressed.
Inference servers
Engines such as vLLM use paged attention and continuous batching to serve many requests per GPU.
Quantisation
Lower-precision weights cut memory and cost with little loss in quality.
The data flywheel
Production failures become new training and evaluation examples for the next version.
The ecosystem
PyTorch
Hugging Face
Llama
Mistral
NVIDIA
Python
Sources and further reading
- [1]Hu et al., LoRA: Low-Rank Adaptation of Large Language Models (2021)
- [2]Dettmers et al., QLoRA: Efficient Finetuning of Quantized LLMs (2023)
- [3]Kwon et al., Efficient Memory Management for LLM Serving with PagedAttention (vLLM, 2023)
- [4]Hinton et al., Distilling the Knowledge in a Neural Network (2015)
- [5]Hugging Face, PEFT library


