Large Language Model Fine-Tuning
LLM fine-tuning adapts a pre-trained large language model to a specific domain or task by continuing training on curated examples. It covers full fine-tuning, parameter-efficient methods like LoRA, dataset preparation, and evaluation of the specialized model.
itArtificial intelligence and machine learning | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic — Large Language Model Fine-Tuning
Fine-tuning is how you alter a pretrained language model by showing it labeled examples until its weights lean toward a task or style. That sounds like teaching a very large parrot new manners. It is closer to changing the parrot's habits than placing a fresh note in its cage for every request.
The important distinction is between behavior and knowledge. A prompt or retrieved document changes what the model sees at inference time. Fine-tuning changes how it tends to respond after training. If the model needs a current return policy, retrieval is the sensible tool. If it knows the policy but keeps returning the wrong JSON shape, training examples may be the missing ingredient.
There is a ladder, because computing your way out of an unclear problem is an expensive hobby. Start with prompt engineering. Add retrieval when facts are missing or stale. Move to fine-tuning when repeated instructions still fail to produce stable behavior. The training dataset then becomes the practical description of the behavior you want, so inconsistent examples teach inconsistency with admirable diligence.
Most current work uses parameter-efficient fine-tuning, or PEFT. Instead of updating every pretrained weight, it freezes most of the model and trains a small addition. LoRA is the common version: two low-rank matrices provide the update beside the frozen weights. QLoRA keeps that arrangement but quantizes the frozen model, cutting the memory needed to train the adapter. The base model remains the same; adapters become swappable task-specific attachments.
The method follows the evidence. Supervised fine-tuning, or SFT, uses input and output examples. DPO uses preferred and rejected responses when “better” is the real target. Reinforcement fine-tuning uses a reward signal for behavior that fixed labels do not capture neatly. SFT is where most projects start, because a clear example is usually less mysterious than a reward function.
The trap is assuming that a completed training job proves anything. Hold out examples before training. Run the same prompts against the base model and the candidate. Check the behavior that matters, including formatting, labels, and awkward cases. A falling training loss is pleasant, but it cannot certify that the model handles new requests rather than remembering old ones.
Read the Cheatsheet when you need the adaptation ladder, LoRA vocabulary, and method comparison in one place. The Practice Reference turns the data and evaluation boundary into a small controlled task. The Reference tab leads to current vendor documentation, because managed fine-tuning platforms change their knobs with the enthusiasm of a software release.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://developers.openai.com/api/docs/guides/model-optimization
Supports
- Prompt engineering is the recommended starting point before other optimization methods
- Fine-tuning is positioned as a later step once prompting and evaluation reveal a persistent gap
- Fine-tuning is useful when the model needs to consistently format responses or handle inputs prompting cannot reliably cover
- https://developers.openai.com/api/docs/guides/supervised-fine-tuning
Supports
- Supervised fine-tuning trains on example input/output pairs to customize model behavior
- Training data uses JSONL format with a messages array matching the inference message format
- Minimum 10 training examples; recommended starting point around 50 well-crafted examples
- Workflow includes upload, job creation, evaluation against holdout data, and deployment via a fine-tuned model ID
- OpenAI is winding down its self-serve fine-tuning platform; new organizations cannot start jobs, existing customers' job creation is being phased out, but inference on existing fine-tuned models continues until base model deprecation
- https://developers.openai.com/api/docs/guides/fine-tuning-best-practices
Supports
- Model performance is bounded by the consistency of the people/process producing training data
- Mismatched training data distribution degrades performance
- Training examples should match inference-time format
- Recommended optimization order is data quality first, then quantity, then hyperparameters
- https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/fine-tuning
Supports
- Microsoft Foundry offers supervised fine-tuning, direct preference optimization, and reinforcement fine-tuning
- Fine-tuning is recommended over prompt engineering for higher quality, more examples than context allows, and lower per-request tokens or latency
- Fine-tuning is recommended over RAG when the goal is changing model behavior rather than augmenting factual knowledge
- Fine-tuning implementation is LoRA-based to reduce complexity
- https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models/gemini-supervised-tuning
Supports
- Supervised fine-tuning customizes Gemini models using labeled training examples
- Fine-tuning is recommended when standard prompting proves insufficient and quality training data is available
- Vertex AI supports parameter-efficient fine-tuning approaches including LoRA and QLoRA
- https://huggingface.co/docs/peft/en/index
Supports
- PEFT fine-tunes a small number of additional model parameters instead of all parameters, reducing computational and storage cost
- PEFT methods yield performance comparable to a fully fine-tuned model while being more accessible on limited hardware
- https://huggingface.co/docs/peft/en/conceptual_guides/lora
Supports
- LoRA freezes pretrained weights and adds trainable low-rank decomposition matrices instead of updating the full weight matrix
- The weight update is the product of the two smaller low-rank matrices
- Rank controls adapter capacity and parameter count
- QLoRA quantizes pretrained weights before training low-rank adapters, reducing GPU memory requirements
- https://aws.amazon.com/blogs/aws/fine-tuning-for-anthropics-claude-3-haiku-model-in-amazon-bedrock-is-now-generally-available/
Supports
- Amazon Bedrock is described as the fully managed service that provides the ability to fine-tune select Claude models
- https://arxiv.org/abs/1706.03762
Supports
- Attention Is All You Need introduced the Transformer architecture in 2017
- https://arxiv.org/abs/1801.06146
Supports
- ULMFiT described universal language-model fine-tuning for text classification in 2018
- https://arxiv.org/abs/1810.04805
Supports
- BERT demonstrated fine-tuning pretrained bidirectional representations for downstream NLP tasks in 2018
- https://arxiv.org/abs/1910.10683
Supports
- T5 presented a unified text-to-text transfer-learning framework in 2019
- https://arxiv.org/abs/2106.09685
Supports
- LoRA introduced low-rank adaptation in 2021
- https://arxiv.org/abs/2203.02155
Supports
- InstructGPT described supervised fine-tuning, ranked outputs, and reinforcement learning from human feedback in 2022
- https://arxiv.org/abs/2305.14314
Supports
- QLoRA combined quantized pretrained weights with low-rank adapters in 2023
- https://arxiv.org/abs/2305.18290
Supports
- Direct Preference Optimization presented a classification-loss approach to preference optimization in 2023
- https://huggingface.co/docs/trl/en/index
Supports
- TRL provides trainer workflows for supervised fine-tuning and preference optimization
- https://axolotl.ai/
Supports
- Axolotl provides configuration-driven tooling for fine-tuning language models
- https://unsloth.ai/
Supports
- Unsloth provides tooling for efficient local language-model fine-tuning
- https://cloud.google.com/vertex-ai
Supports
- Vertex AI is Google Cloud's managed AI platform
- https://azure.microsoft.com/en-us/products/ai-foundry
Supports
- Microsoft Foundry is Microsoft's managed AI development platform
- https://aws.amazon.com/bedrock/
Supports
- Amazon Bedrock provides managed foundation-model services on AWS
