Skip to main content

What is Fine-Tuning (for LLMs)?

What is fine-tuning in AI models? Learn how to adapt LLMs with your own training data for specific tasks.

FHFinn Hillebrandt
Last updated:
Technology
What is Fine-Tuning (for LLMs)?

Fine-tuning means adapting a pre-trained LLM (large language model) to a specific task or domain by further training it on a specialized dataset.

During this process, the model's weights are updated so that it better captures the specifics of the task or domain.

Fine-tuning thus allows you to optimize the broad but superficial knowledge base of LLMs for specific use cases.

Did that just go over your head?

No problem, here's a simpler explanation:

Think of an LLM as a new employee in your company who has a lot of general knowledge but little understanding of internal processes and communication within your organization.

Through fine-tuning, you feed your employee the necessary specialized knowledge so they can better fulfill their role in the company.

1. Benefits of Fine-Tuning

Fine-tuning improves "few-shot learning" by training with many more examples than would fit in a prompt.

This means you no longer need to provide as many examples in your prompts to get the desired output. Additionally, you don't need to give the LLM as many details about its task, such as the writing style to use, the target audience, or the output length. This can save a lot of time.

Furthermore, fine-tuning can help an LLM respond with lower latency and consume fewer tokens. Fine-tuning can therefore also reduce costs for API usage or computing power.

2. What Steps Are Required for Fine-Tuning?

Fine-tuning sounds complicated. But it's actually a relatively simple, though very time-consuming process.

The key steps in fine-tuning are:

  1. Prepare and upload training data (by far the most labor-intensive step for you)
  2. Train a new fine-tuned model
  3. Evaluate results and return to step 1 if needed
  4. Use your fine-tuned model

2.1 How Do You Prepare Training Data?

The most important and time-consuming step in fine-tuning is preparing the training data.

For this, you need to create a diverse set of example conversations that resemble the conversations the model will encounter in production.

Each example in the dataset must have a specific format. When fine-tuning OpenAI models, for example, the training data must be in the same format as the Chat Completions API.

To achieve the best results with fine-tuning, you should primarily train an LLM with cases where it doesn't give the desired responses and provide your preferred answers in the training data.

Here's an example from OpenAI where a chatbot named "Marv" is fine-tuned to give sarcastic responses:

{"messages": [{"role": "system", "content": "Marv is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What is the capital of France?"}, {"role": "assistant", "content": "Paris, as if everyone doesn't know that already."}]}
{"messages": [{"role": "system", "content": "Marv is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "Who wrote 'Romeo and Juliet'?"}, {"role": "assistant", "content": "Oh, just some guy named William Shakespeare. Ever heard of him?"}]}
{"messages": [{"role": "system", "content": "Marv is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "How far is the Moon from Earth?"}, {"role": "assistant", "content": "About 384,400 kilometers. Give or take a few, as if that really matters."}]}

3. Which AI Models Can Be Fine-Tuned?

Fine-tuning is available for many different AI models, from proprietary APIs to open-source models. Here's a comprehensive overview of all currently available models:

Showing 29 models

ProviderModelParametersPlatformMethod
Alibaba / QwenQwen30.6B–235BOpen Source
FullLoRA
Alibaba / QwenQwen2.5-MaxMoEAlibaba Cloud
SFT
Alibaba / QwenQwen2.50.5B–72BOpen Source
FullLoRA
AmazonAmazon Nova 2 LiteAmazon Bedrock
Reinforcement FT
AmazonAmazon Titan TextAmazon Bedrock
SFT
AnthropicClaude 3 HaikuAmazon Bedrock
SFT
CohereCommand R (08-2024)32BCohere API
SFTLoRA
CohereCommand R+ (08-2024)104BCohere API
SFTLoRA
DeepSeekDeepSeek R1 Distill1.5B–70BOpen Source
LoRAQLoRA
DeepSeekDeepSeek V3671B (37B MoE)Open Source
QAT
GoogleGemini 2.5 ProVertex AI
SFT
GoogleGemini 2.5 FlashVertex AI
SFT
GoogleGemini 2.5 Flash-LiteVertex AI
SFT
GoogleGemini 2.0 FlashVertex AI
SFT
GoogleGemma 31B–27BOpen Source
FullLoRA
MetaLlama 3.370BOpen Source
FullLoRA
MetaLlama 3.21B–90BOpen Source, Amazon Bedrock
FullLoRA
MetaLlama 3.18B–405BOpen Source
FullLoRA
MistralMistral Large 3123BMistral API, Open Source
SFTLoRA
MistralMistral Nemo12BMistral API, Open Source
SFTLoRA
MistralCodestralMistral API
SFT
MistralMistral SmallMistral API
SFT
MistralMistral 7B7BOpen Source
FullLoRA
OpenAIGPT-4.1OpenAI API
SFTDPO
OpenAIGPT-4.1 miniOpenAI API
SFTDPO
OpenAIGPT-4.1 nanoOpenAI API
SFTDPO
OpenAIGPT-4o (2024-08-06)OpenAI API
SFT
OpenAIGPT-4o miniOpenAI API
SFT
OpenAIGPT-3.5 TurboOpenAI API
SFT

3.1 Explanation of Fine-Tuning Methods

  • SFT (Supervised Fine-Tuning): Classic supervised fine-tuning with input-output pairs
  • DPO (Direct Preference Optimization): Training with preference data (which answer is better)
  • Full Fine-Tuning: All model weights are adjusted
  • LoRA (Low-Rank Adaptation): Efficient method that only trains small adapter layers
  • QLoRA: LoRA with quantized base model (requires less VRAM)
  • QAT (Quantization-Aware Training): Training that accounts for later quantization
  • Reinforcement FT: Fine-tuning with reinforcement learning from human feedback

Note: Google AI Studio no longer supports fine-tuning since 2025. For Gemini models, Vertex AI must be used.

Tip: You can also further fine-tune an already fine-tuned model. This is useful when you receive additional data and don't want to repeat the previous training steps.

4. When Should You Use Fine-Tuning?

Fine-tuning is a great method for getting better output from an LLM and is especially useful when it's easier to "show than to explain."

The problem is, however:

Fine-tuning is, as already explained, very time-consuming.

Therefore, it always makes sense to first check whether you can get better results with other methods and only resort to fine-tuning when you've exhausted these methods.

These include:

  1. Prompt Engineering (i.e., formulating prompts, such as adding a role, precisely defining the answer format, etc.)
  2. Prompt Chaining (breaking complex tasks into multiple prompts)
  3. Function Calling (e.g., calling external interfaces or databases)

A major advantage of these methods is that you get feedback much faster and more easily.

For example, if you add a role to your prompt, you can immediately compare your output with the prompt without a role.

With fine-tuning, you often have to spend days or even weeks preparing your training data. Then you have to wait for the model to be fine-tuned and can only test what the fine-tuning actually achieved after these two steps.

5. Approaches to Fine-Tuning

There are various ways to fine-tune LLMs:

ApproachDescriptionAnalogy
Full Fine-TuningRetraining the entire model, requires a lot of data and resourcesCompletely training a new employee
Parameter Efficient Fine-Tuning (PEFT)Adding new efficient adapters without changing the model structureFurther training an employee
DistillationTraining a smaller specialized model that replicates the decisions of the large modelHaving an experienced employee train a new employee
Sources and References
FH

Finn Hillebrandt

AI Expert & Blogger

Finn Hillebrandt is the founder of Gradually AI, an SEO and AI expert. He helps online entrepreneurs simplify and automate their processes and marketing with AI. Finn shares his knowledge here on the blog in 50+ articles as well as through his ChatGPT Course and the AI Business Club.

Learn more about Finn and the team, follow Finn on LinkedIn, join his Facebook group for ChatGPT, OpenAI & AI Tools or do like 17,500+ others and subscribe to his AI Newsletter with tips, news and offers about AI tools and online business. Also visit his other blog, Blogmojo, which is about WordPress, blogging and SEO.