Fine-tuning is the process of continuing to train an already pretrained model on a smaller, task-specific dataset so that it adapts to a particular task, domain, output format or style. Instead of learning from scratch, the model starts from weights that already encode broad knowledge and adjusts them, which makes fine-tuning far cheaper than pretraining and effective with relatively little data.
In artificial intelligence, fine-tuning is the main form of transfer learning for large models. It covers several methods, from updating every weight to training small add-on matrices, and it is the stage in which a raw base language model becomes an instruction-following assistant or a specialist for one job.
How fine-tuning works
Fine-tuning uses the same gradient-descent training loop as pretraining, but with three key differences: the starting point is a pretrained checkpoint, the dataset is small and curated, and the learning rate is much lower so that existing knowledge is adjusted rather than overwritten.
For language models, each training example is usually a prompt and a target response. The loss is typically computed only on the response tokens, so the model learns what to answer, not how to repeat the question. Training runs for a small number of passes over the data, often one to five epochs, while a held-out validation set shows when the model starts to overfit.
The table summarizes how fine-tuning differs from pretraining in practice.
| Aspect | Pretraining | Fine-tuning |
|---|---|---|
| Starting point | Random weights | Pretrained checkpoint |
| Data volume | Trillions of tokens | Hundreds to hundreds of thousands of examples |
| Data type | Mostly unlabeled raw text | Curated, task-specific examples |
| Compute | Large GPU clusters for weeks or months | One to a few GPUs for hours or days |
| Goal | General language and world knowledge | Specific behavior, format or domain |
Types of fine-tuning
Fine-tuning methods differ in which weights change and what kind of signal the model learns from. The choice drives cost, risk and the kind of improvement that is possible.
| Method | What is trained | Training signal | Typical purpose |
|---|---|---|---|
| Full fine-tuning | All model weights | Labeled examples | Maximum adaptation when compute allows |
| LoRA | Small low-rank matrices beside frozen weights | Labeled examples | Efficient task or style adaptation |
| QLoRA | LoRA matrices over a 4-bit quantized base model | Labeled examples | Fine-tuning large models on one GPU |
| Supervised fine-tuning | All weights or adapters | Prompt and ideal response pairs | Instruction following, output format |
| Preference tuning | All weights or adapters | Preferred versus rejected responses via RLHF or DPO | Helpfulness, tone, safety |
| Continued pretraining | All weights | Unlabeled domain text | Vocabulary and knowledge of a new domain |
Parameter-efficient methods change very few weights. For a single 4,096 by 4,096 weight matrix with 16,777,216 parameters, a LoRA adapter of rank 8 adds 8 times (4,096 plus 4,096), or 65,536 trainable parameters, about 0.39 percent of that matrix. Adapters can be stored separately and swapped per task on one shared base model.
Key settings and resource needs
Most fine-tuning outcomes depend on data quality and a few hyperparameters more than on the choice of framework. The ranges below are common starting points for language models, not universal rules.
| Setting | Typical starting range | Effect if too high |
|---|---|---|
| Learning rate, full fine-tuning | About 0.00001 to 0.00005 | Forgetting of general skills, unstable loss |
| Learning rate, LoRA | About 0.0001 to 0.0003 | Overfitting to training phrasing |
| Epochs | 1 to 5 | Memorization of examples |
| LoRA rank | 8 to 64 | More memory with diminishing gains |
| Dataset size | A few hundred to tens of thousands of examples | Higher cost; quality matters more than volume |
Memory is the practical constraint. Full fine-tuning with the Adam optimizer in mixed precision needs roughly 16 bytes per parameter for weights, gradients and optimizer states, so a 7-billion-parameter model needs about 112 GB before activations. With QLoRA, the frozen base model stored in 4 bits takes about 3.5 GB, which is why a 7-billion-parameter model can be fine-tuned on a single 24 GB GPU.
When to fine-tune and when not to
Fine-tuning is the right tool for teaching how to respond, not for supplying facts that change. Before fine-tuning, teams should confirm that prompting and retrieval cannot meet the goal, because those options are cheaper to build and easier to update.
| Situation | Recommended approach | Reason |
|---|---|---|
| Answers must reflect frequently updated documents | Retrieval-augmented generation | Knowledge updates without retraining |
| Strict output format or schema | Supervised fine-tuning | Consistency beyond what prompts achieve |
| Distinct brand voice or tone | Fine-tuning with LoRA | Style is learned from examples |
| High volume, narrow task | Fine-tune a smaller model | Lower latency and cost per request |
| Few examples, early prototype | Prompting with examples | Fast iteration, no training needed |
Fine-tuning and retrieval are often combined: a model fine-tuned to use retrieved passages faithfully and answer in a fixed format, with facts supplied at request time.
Risks and common mistakes
The most frequent fine-tuning failures come from data problems and missing evaluation, not from the training code. Typical issues include:
- Catastrophic forgetting: aggressive training erodes general abilities the base model had.
- Overfitting: the model repeats training phrasing and fails on new inputs; validation loss rises while training loss falls.
- Eroded safety behavior: even benign fine-tuning data can weaken refusals learned in alignment, so safety must be re-tested after training.
- Inconsistent or wrong labels: the model faithfully learns the errors in its examples.
- Test data leakage: evaluation examples that also appear in training data inflate scores.
- No baseline: without comparing against a well-prompted base model, gains cannot be proven.
A sound process fixes a held-out test set before training, compares against the prompted baseline and checks both task metrics and general capability after every run.
The simple explanation
Fine-tuning is like giving an experienced professional focused on-the-job training. A pretrained model already knows a great deal about language in general; fine-tuning shows it hundreds or thousands of examples of one specific job until it does that job the way you want.
It works best for teaching habits such as a format, a tone or a narrow task. It is not a good way to teach facts that keep changing, because every change would require another round of training.
How it is used in practice
A software company receives thousands of support tickets a day and wants each one turned into a structured record: product, category, severity and a one-sentence summary in a fixed JSON format. A large general model prompted with examples handles the task, but it is slow and expensive at that volume, and about 18 percent of its records have a wrong field or a format error.
The team collects 4,000 tickets with verified records, keeps 500 more aside as a test set and fine-tunes an 8-billion-parameter open model with LoRA at rank 16 for three epochs on a single GPU. Training takes a few hours.
On the held-out test set, the fine-tuned small model produces correct records for about 95 percent of tickets, compared with about 82 percent for the prompted large model, and it runs at a fraction of the cost per request. The team retrains quarterly with newly corrected tickets so the model keeps up with new products and categories.