A general-purpose model may write fluently yet still miss the tone, terminology, or output format a particular task needs. That gap can slow development, frustrate users, and lead to extra work correcting results. Fine-tuning offers one way to adapt an existing model with examples of the task you need.
This beginner’s guide covers language and other machine learning tasks. You will see how task-specific examples can shape an existing model, how to check results, and when a different approach may fit better. The right choice depends on the job, your training data, and the behavior you need. A good adaptation starts by deciding what the model should do differently, not by collecting data at random.
Key Takeaways
- Fine-tuning continues training from an already trained model.
- Task examples can help shape a model’s behavior and output format.
- PEFT methods train fewer parameters than full fine-tuning.
- RAG can supply changing facts without changing model weights.
- Evaluation on unseen examples helps reveal weak spots.
What Is Fine-Tuning in Machine Learning?
Fine-tuning adapts a model that has already learned broad patterns by continuing its training on examples for a more specific task. Those examples guide the model toward a target behavior, such as answering in a set format. Fine-tuning is continued training of a pretrained model, not a change to a few settings.
Transfer learning means reusing knowledge learned on one task as a starting point for a related or specialized task. Fine-tuning is one way to apply transfer learning: the model starts with learned parameters, then trains on task-specific data. Stanford HAI explains transfer learning as reusing what a model learned for a new task.
Pretraining commonly adjusts model parameters through repeated forward passes, loss measurement, and backpropagation. A forward pass produces a prediction, and a loss score measures how far it is from the target. Backpropagation uses that loss to adjust parameters. The model repeats this cycle across many examples and training epochs.
Changing a learning rate or batch size changes the training setup; fine-tuning trains the model’s parameters.
Ordinary hyperparameter tuning tests settings such as learning rate or batch size. It does not, by itself, train the model. Fine-tuning can use supervised, reinforcement, self-supervised, or semi-supervised learning, depending on the task and available labels.
For example, supervised fine-tuning (SFT) uses examples that pair inputs with desired outputs. Reinforcement learning from human feedback (RLHF) uses human preferences to guide later training. Each method provides a different learning signal, so the data must match the goal.
A model’s starting point matters. A pretrained model has already learned patterns from earlier training, while a new task dataset steers those patterns toward a narrower goal. For a fuller look at model training and its stages, see how large language models work.
Training from scratch starts with randomly initialized parameters, while fine-tuning starts with the model’s learned parameters already in place.

Which fine-tuning methods can you choose?
The main choice is whether to update every model weight or train a smaller task-specific set. Full fine-tuning offers broad control, while parameter-efficient fine-tuning (PEFT) reduces the number of trained parameters. Choose based on measured task results and the compute you can support.
Full fine-tuning updates the whole network, which can let the model adapt deeply to a new task. It also needs more memory and compute than methods that train only part of the model. A smaller learning rate can reduce large, destabilizing updates during training.

Full fine-tuning updates the whole network
Updating all weights can help when the task differs from the model’s earlier work. Yet a large update can also damage useful patterns from pretraining. Teams often test a lower learning rate to limit that risk, then compare results on held-out data.
Full fine-tuning can also create a separate, large model copy for each task. That may be hard to store or serve when several task-specific models are needed. The extra parameter updates can raise resource needs during both training and deployment.
PEFT keeps most pretrained weights frozen
PEFT trains a smaller set of parameters while keeping most original weights frozen. Some methods update selected layers. Adapter-based approaches add small trainable modules, while reparameterization methods express an update in a compact form.
LoRA, or Low-Rank Adaptation, freezes the base weights and represents updates with two smaller matrices. Its rank, written as r, changes the size of those trainable matrices. In Hugging Face PEFT, standard LoRA uses a scaling factor of lora_alpha/r. Rank-Stabilized LoRA instead uses lora_alpha/math.sqrt(r).
LoRA adapters can be merged into the base weights after training, avoiding added inference latency. Prompt tuning trains prompt-related parameters, while QLoRA combines quantized base weights with LoRA updates. A study of BERT adapters found equivalent performance while training just 3.6% as many parameters.
| Method | What trains | Original weights | Practical trade-off |
|---|---|---|---|
| Full fine-tuning | All parameters | Updated | Flexible, high compute |
| Partial fine-tuning | Selected layers | Mostly frozen | Fewer updates, less flexibility |
| Adapter-based PEFT | Added modules | Frozen | Small task modules, extra components |
| LoRA | Low-rank matrices | Frozen until merge | Compact updates, rank affects capacity |
LoRA appeared in 20,509 of 20,834 sampled Hub model cards mentioning one PEFT method, or 98.4%. It also appeared in 7,111 of 10,000 sampled image-generation checkpoints, reported as 95.0%. LoRA scored 53.2% on the MetaMathQA test benchmark.
The same sample found 71.3% of GitHub results for a specified PEFT import pattern were for LoRA. Those counts show its use in sampled materials, not a guarantee of performance on your task. Choose the smallest adaptation method that meets the task’s measured performance needs.
A review of fine-tuning methods for specialized language models discusses PEFT, supervised training, and validation.
How do you fine-tune a model step by step?
Begin with a measurable task, such as classifying support messages correctly, before choosing the model or training setup. A clear target helps you pick useful examples and a fair test. You can fine-tune an AI model by defining the task, preparing data, training, and testing the result.
The tools and compute depend on model size and method. A small classifier may need less hardware than a large language model. The same basic process still applies: define what success looks like before training starts.

Prepare examples and choose a base model
Choose a pretrained model that can already handle the broad type of work. A language model can start a writing task, while an image model can start a classification task. Then describe the desired input and output in plain terms.
Gather examples that resemble real use, including common cases and important edge cases. Remove duplicates, fix mislabeled entries, and use one consistent format. If examples include private details, remove or protect them before training.
Divide the dataset into training, validation, and test sets. The training set teaches the model. The validation set helps you check choices during training. Keep the test set separate for the final check on unseen examples.
A beginner-friendly model training workflow also covers data splits and evaluation. Use a task metric that reflects the actual goal, not a score that looks good but misses costly errors.
Train, validate, and refine the model
Choose an adaptation method, then set a learning rate, batch size, and number of epochs. The learning rate controls the size of model updates. Batch size controls how many examples the model processes before an update. Epochs count passes through the training data.
Watch validation results during training. Accuracy measures the share of correct predictions. Precision measures how many positive predictions are correct, while recall measures how many actual positives the model finds. Pick metrics that match the task’s risks.
- Define the task and metric.
- Select a suitable base model.
- Prepare examples and split the data.
- Train while checking validation results.
- Test, deploy, and monitor the model.
After training, assess the final model on held-out test data. Deploy only when it meets task-specific criteria, then watch real-world behavior for errors or changes. A practical guide to using AI models and checking outputs can help with evaluation choices.
Keep the test set separate until the final evaluation so it remains a check on unseen examples.
What can fine-tuning improve?
Fine-tuning can make a general model more consistent on a narrow task, but it cannot guarantee that every answer becomes more accurate. Useful gains may include better task accuracy, a steadier style, or a more reliable output format. Results depend on the task, example quality, and evaluation method.
A model may follow a requested tone more often after seeing many examples in that tone. It may also use domain terms in a more consistent way. For structured tasks, examples can help it return fields in a required order or format.

Starting with a pretrained model can require less compute and labeled data than training a large model from scratch. PEFT can also reduce memory and storage demands. Those savings matter when a team has limited hardware or needs several small task adaptations.
Still, fine-tuning does not guarantee better model performance. Poor or unrepresentative training data can teach the wrong pattern. A strong result on one metric may hide failures that matter in daily use, so assess more than one kind of example.
A base model may also be a poor fit when the target task differs greatly from what it learned before. A small amount of task training may not bridge a major gap in language, input type, or skill. In that case, a better starting model may matter more than extra training.
Compare the adapted model with the original on examples the model did not train on. A careful AI app build process also treats testing as part of product development, not a last-minute step.
Which tasks are a good fit for fine-tuning?
Fine-tuning is most useful when a task calls for repeatable behavior that examples can demonstrate. Consistent examples can teach a model the desired response pattern, label, or visual category. Fine-tuning fits best when you can represent and evaluate the behavior with examples.
It is a weaker choice when the model simply needs access to changing documents. In that case, retrieval can provide current information at answer time. The key difference is whether you need a stable behavior or more up-to-date facts.
Language tasks benefit from consistent examples
Language models can learn a coding style by training on examples of code and expected output. Customer-support examples can teach a response structure or a brand voice. Domain-specific terms can become more familiar through clear, repeated use.
Classification tasks can use labeled messages, such as sentiment categories. Summarization can improve when examples show the length and details a summary should preserve. A stable writing style can also be learned when the examples show how that style handles different topics.
For each task, examples should show both typical inputs and meaningful variations. A model trained only on simple support questions may struggle with unclear or upset customers. A coding model may need examples across the languages or formats it will face.
Vision tasks can learn new labels or styles
Image models can learn to recognize new categories, such as additional bird species in a wildlife collection. Image detection can also adapt to objects or settings that the original model misses. Each label needs examples that clearly show what belongs in that category.
Fine-tuning can also steer image generation toward a consistent illustration style. The target style should appear across varied subjects, not just one repeated scene. That gives the model a better chance to apply the pattern beyond the exact training images.
- Coding output that follows a team’s preferred format.
- Customer-support replies with a consistent response style.
- Sentiment classification for labeled messages.
- Image-category recognition for added bird species.
Check that the training examples represent the situations the model will face after deployment.
How does fine-tuning compare with RAG?
Choose RAG when answers need to draw on frequently changing documents, and consider fine-tuning when the desired behavior stays stable across many requests. RAG retrieves external information at inference time without changing model weights. Fine-tuning updates weights during training, while RAG brings in facts when the model answers.
Retrieval-augmented generation (RAG) can use new documents without retraining the model. Fine-tuning needs another training run to absorb changes in its training data. That makes RAG a better fit for policies, product details, and other information that changes often.
| Approach | Effect on model weights | How new information arrives | Good fit |
|---|---|---|---|
| Fine-tuning | Updated during training | Another training run | Stable behavior, high-volume tasks |
| RAG | Unchanged | Retrieved at inference | Frequently changing documents |
| Hybrid | Updated through training | Training plus retrieval | Stable style with current facts |
Fine-tuning can suit high-volume, low-latency tasks when the behavior stays stable. RAG can add useful context, though retrieval quality affects the answer. A hybrid system combines retrieval with fine-tuning, and it outperformed either approach alone across cited benchmarks.
For example, 500 retrieved context tokens at $1.75 per million input tokens cost $0.000875 per query. That figure covers those input tokens only, not the full cost of an application or model response.
Learn more about how RAG retrieves external information and how connected documents can support answers. A guide to AI search and retrieval explains why indexed material must be findable and relevant.
Use retrieval for facts that need regular updates and fine-tuning for patterns the model should apply consistently.
What can go wrong when you fine-tune?
A model that performs well on its training examples can still fail on new cases if it has memorized patterns instead of learning a useful rule. That failure is called overfitting. Check performance on examples the model did not train on.
Catastrophic forgetting can weaken skills the original model had before adaptation. Biased or noisy examples can teach unfair or incorrect patterns. A base model that poorly matches the task can also produce weak results, even after careful training.
Overfitting can happen when a model learns quirks in the training set instead of patterns that apply more broadly. Early stopping ends training when validation results stop improving. Regularization adds constraints that discourage overly complex fits. Both methods can help, but neither removes every risk.
A model can also appear strong on one score while failing in less common cases. Review a mix of normal, difficult, and sensitive examples. Keep the original model’s results beside the adapted model’s results to spot lost capabilities.
A research review of overfitting and methods such as early stopping covers ways to limit this problem.
- Inspect examples for errors, missing labels, and imbalance.
- Compare training and validation results for a widening gap.
- Check the original model’s capabilities after adaptation.
- Test outputs for bias and unsafe responses.
Keep a baseline from the original model so regressions are visible during evaluation.
What does fine-tuning require in time and cost?
Fine-tuning costs depend on the model, training setup, and number of experiments, so separate training charges from ongoing inference charges. Training runs are only part of the work. Compute, data preparation, repeated experiments, and evaluation all add time or cost.
Larger models often need more compute than smaller ones. Dataset cleaning can take time before a training job begins, and each experiment adds another round of work. Evaluation also takes resources, especially when you compare multiple model versions or test many task cases.
OpenAI fine-tuning is unavailable to new users. Existing users can create training jobs for the coming months. Fine-tuned models remain available for inference until their base models are deprecated.
The listed prices below apply to the o4-mini-2025-04-16 fine-tuned model. Training costs $100.00 per hour. Standard inference charges differ for input and output tokens, while Batch inference has its own rates.
| Charge | Rate | Billing unit | Condition |
|---|---|---|---|
| Training | $100.00 | Per hour | o4-mini-2025-04-16 fine-tuning |
| Standard input inference | $4.00 | Per million input tokens | o4-mini-2025-04-16 fine-tuned model |
| Standard output inference | $16.00 | Per million output tokens | o4-mini-2025-04-16 fine-tuned model |
| Batch input inference | $2.00 | Per million input tokens | o4-mini-2025-04-16 fine-tuned model |
| Batch output inference | $8.00 | Per million output tokens | o4-mini-2025-04-16 fine-tuned model |
These figures make the difference between training and serving clear. A training job is billed by time, while inference costs depend on token use. For the listed model, Batch input and output rates are lower than Standard rates.
Estimate both the training runs and the expected input and output tokens before comparing deployment options.
How did human feedback shape instruction-tuned models?
Instruction tuning can teach a model to answer prompts more directly by showing it examples of useful responses. Human feedback can then guide training toward answers people prefer. The InstructGPT study used supervised demonstrations followed by reinforcement learning from human rankings.
The supervised examples paired prompts with desired responses. Human labelers wrote demonstrations, then ranked model outputs. Researchers used those rankings to train a reward model, which scored responses during reinforcement learning.
Demonstrations teach desired responses
The InstructGPT study used 40 contractors to label human feedback. Their demonstrations showed the model how to respond to prompts in the study. This approach gave the model examples of helpful answers rather than relying only on broad language patterns.
Supervised fine-tuning can shape how a model follows instructions, but the effect depends on its examples and test prompts. The InstructGPT findings describe that study, not every version of ChatGPT or every current chatbot.
Human rankings guide further training
On the study’s prompt distribution, people preferred the 1.3-billion-parameter InstructGPT model over 175-billion-parameter GPT-3, despite its 100-times-smaller size. The 175-billion-parameter InstructGPT model beat same-size GPT-3 outputs 85 ± 3% of the time.
People preferred that InstructGPT model over few-shot 175-billion-parameter GPT-3 outputs 71 ± 4% of the time. In closed-domain tests, hallucination rates were 21% for InstructGPT and 41% for GPT-3.
When prompted to be respectful, InstructGPT produced about 25% fewer toxic outputs than GPT-3.
The study also reported better truthfulness and fewer toxic outputs, with minimal regressions on public natural language processing datasets. Those findings show how rankings can guide model behavior while leaving room for trade-offs.
Treat evaluation results as specific to the tested prompts and conditions, not as a guarantee for every user or task.
Conclusion
Fine-tuning is a way to adapt learned capability, not a substitute for a clear task and reliable examples. Representative examples can teach a stable, measurable behavior, while retrieval can supply reference material that changes often. The best choice follows the kind of change your work needs.
Start with a small set of input-output examples. Include ordinary cases and meaningful variations, then decide how you will measure success before choosing a model or method. Start by defining one task and the evidence that would show the adapted model is doing it well.
FAQ
What is fine-tuning in LLM vs RAG?
Fine-tuning updates a language model’s weights during training, while RAG retrieves external information when the model answers. Fine-tuning suits stable behavior that should stay consistent across many requests. RAG often fits documents that change often, such as current policies or product details. A system can combine both when it needs a steady response style and up-to-date facts.
How was ChatGPT fine tuned?
The InstructGPT study used supervised demonstrations followed by reinforcement learning from human rankings. Those steps helped shape instruction-following behavior in the models tested. The study is not a full account of every version of ChatGPT, and its results do not guarantee the same behavior across current products. Model training methods can vary by model and release.
How much data do you need to fine-tune a model?
There is no fixed example count that fits every task. Use enough representative examples to cover meaningful differences in inputs, labels, and expected outputs. Keep held-out data for evaluation, since training examples cannot show how well the model handles unseen cases. A narrow, consistent task may need fewer examples than a broad task with many edge cases.
Can fine-tuning make an AI model forget what it already knows?
Yes, fine-tuning can weaken capabilities the original model had, a problem called catastrophic forgetting. Compare the adapted model with the original baseline on tasks beyond the new target. Conservative training choices can help limit unwanted changes, but they cannot promise that every earlier skill will remain unchanged. Keep those comparison results when deciding whether to deploy.
How long does it take to fine-tune an LLM?
Fine-tuning time depends on model size, hardware, dataset preparation, and training settings. A training job is only part of the schedule. Include time for cleaning examples, checking validation results, testing the final model, and repeating experiments when results fall short. A larger model or several rounds of testing can add more time.
Can you fine-tune an LLM without changing all its weights?
Yes, PEFT methods such as LoRA train a smaller set of parameters while keeping the base weights frozen. LoRA uses smaller matrices to represent task updates, and its rank affects their size. This can lower memory and storage needs compared with updating every weight. The best method still depends on whether the task meets its evaluation goals.


