Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Building with LLMs

Fine-tuning

Further training a model on task-specific examples, and knowing when RAG is enough.

Advanced
Bookmark

Bookmarks are kept in your free account, so you can find this page again on any device.

Sign in to bookmark
On this page

Overview

Fine-tuning continues training a pretrained model on your own examples so it adopts a format, style or narrow skill more consistently, or so a smaller, cheaper model can do a job that previously needed a larger one. Parameter-efficient methods such as LoRA make this possible on a single GPU.

The most important part of the skill is judging when not to fine-tune. Better prompts, retrieval or a different model solve most problems faster, and fine-tuning is a poor way to add facts. When it is the right tool, success depends on clean, representative training data and an eval set that shows the tuned model is actually better than the baseline.

What you will practise

  • Decide whether prompting or retrieval would solve the problem first
  • Prepare clean, consistent training examples
  • Run a LoRA or QLoRA fine-tune on a single GPU
  • Show with an eval that the tuned model beats the baseline

Learning paths

  • Local models and fine-tuning

    Run open-weight models on your own hardware, use them on private documents, decide when fine-tuning beats RAG or long context, and try a small LoRA fine-tune.

    Intermediate11 h8 steps

Tutorials

  • Fine-tune a small model with LoRA

    Fine-tune a small open model with LoRA using TRL and PEFT, measure it on a held-out set before and after, and decide whether the gain is worth keeping.

    Advanced2 h

Articles

Tools for this skill

  • Axolotl

    Config-driven toolkit for fine-tuning open models, from LoRA to full multi-GPU runs.

    Fine-tuningOpen source

  • Hugging Face

    Hub for models, datasets and Spaces, plus open-source ML libraries.

    Models and local inferenceFreemiumHugging Face

  • MLX LM

    Runs and fine-tunes LLMs on Apple silicon with MLX.

    Models and local inferenceOpen source

  • Modal

    Serverless cloud for running Python on GPUs for inference, batch jobs and training.

    Models and local inferenceUsage-basedModal

  • Sentence Transformers

    Python library for embedding and reranker models.

    Retrieval and vector searchOpen sourceHugging Face

  • Together AI

    Cloud for running and fine-tuning open models, with serverless endpoints and GPUs.

    Models and local inferenceUsage-basedTogether AI

  • Transformers

    Hugging Face's library of open model definitions.

    Models and local inferenceOpen sourceHugging Face

  • TRL

    Hugging Face's post-training library: supervised fine-tuning, DPO, GRPO and reward models.

    Fine-tuningOpen sourceHugging Face

  • Unsloth

    Faster, lower-memory LoRA and QLoRA fine-tuning for open models.

    Fine-tuningOpen sourceUnsloth

Key terms

Words you will meet while learning this, defined in the glossary.

Full glossary
  • Constitutional AI

    A training method in which a model learns to be harmless by critiquing and revising its own answers against a written list of principles.

  • Distillation

    Training a smaller model to imitate the outputs of a larger one, keeping much of the quality at a lower cost and latency per request.

  • DPO

    Direct Preference Optimization: training a model directly on pairs of preferred and rejected outputs, with no separate reward model needed.

  • Fine-tuning

    Further training a pretrained model on task-specific examples to change its behaviour, format or style, rather than its general knowledge.

  • LoRA

    Low-Rank Adaptation: a fine-tuning method that freezes the model's weights and trains small added matrices instead, cutting memory needs.

  • Post-training

    Training after pretraining that shapes a model's behaviour, including instruction tuning and preference or reinforcement learning.

  • Pretraining

    The first, most expensive stage of training, in which a model learns general patterns by predicting the next token across a huge corpus.

  • Reward model

    A model trained to score responses the way human raters would, used as the signal when another model is tuned with reinforcement learning.

  • RLHF

    Reinforcement learning from human feedback: training a model with a reward signal learned from people's preferences between two outputs.

  • Supervised fine-tuning (SFT)

    Fine-tuning on labelled input and output pairs so the model learns to produce the target output for each input.

  • Synthetic data

    Training or test examples generated by a model or program instead of collected from real users, used when real data is scarce.