How to Fine-Tune an LLM in 2026

    Published September 17, 2026·12 min read

    TL;DR

    Fine-tuning teaches an LLM a behavior, style, or skill — not new facts (that's RAG's job). It appears in 26% of AI-engineer job descriptions (Dexity), the same rate as RAG, but it's the most over-reached-for of the three techniques. In 2026 you almost never full-fine-tune: a LoRA or QLoRA adapter on a strong base model, trained with SFT (then DPO if you need preference alignment) on a few hundred to a few thousand curated examples, is the default — runnable on a single GPU for a few dollars. This guide covers the decision (fine-tune vs RAG vs prompt), the methods (LoRA/QLoRA, SFT vs DPO), data, the tool stack (HF TRL/PEFT, Unsloth, Axolotl, Modal), evaluation, and the failure modes.

    Summarize with AIChatGPTClaude

    What does it mean to fine-tune an LLM in 2026?

    It means taking a strong pretrained model and further training it on your own examples so it reliably produces a behavior, style, or format — not to stuff new facts into it. In 2026 you almost never touch every weight: you train a small adapter (LoRA, usually on a 4-bit base — QLoRA) on top of a frozen model, using supervised fine-tuning (SFT) on input/output pairs, then optionally preference tuning (DPO) to align tone. The whole thing runs on a single GPU for a few dollars. The hard part isn't the training — it's the decision: fine-tuning appears in 26% of AI-engineer job descriptions (Dexity), the same as RAG, but it's the one people reach for when a better prompt or retrieval would do. Here's when it's the right tool, and exactly how to do it.

    Key facts

    • Fine-tuning appears in 26% of live AI-engineer JDs — the same rate as RAG, and below evals (56%) and agents (50%) (Dexity's July 2026 scan of 390 postings).
    • You rarely full-fine-tune in 2026: a LoRA/QLoRA adapter on a strong base is the default; LoRA trains a fraction of a percent of the parameters (Hu et al., 2021).
    • QLoRA fine-tunes a 65B model on a single 48GB GPU while matching full 16-bit performance (Dettmers et al., 2023) — the stat that made local fine-tuning normal.
    • Fine-tuning teaches behavior, not facts: training on new knowledge is learned slowly and increases hallucination (Gekhman et al., EMNLP 2024).
    • DPO replaced most RLHF as the default way to align a model to preferences — simpler and more stable (Rafailov et al., 2023).
    • OpenAI's own guidance: roughly 80% of proposed fine-tunes are better solved by a better prompt, few-shot, or RAG — don't fine-tune until you can state the eval metric prompting can't move.

    Should you fine-tune at all — or use RAG or prompting?

    Usually you shouldn't fine-tune first. The consensus sequence is prompt engineering → RAG → fine-tuning, and you don't skip ahead. OpenAI is blunt about it: most proposed fine-tunes are better solved with a stronger prompt, few-shot examples, or retrieval — and their gate is "don't fine-tune until you can state your eval metric and why prompting can't move it."

    ℹ️The honest test before you fine-tune: (1) Have you exhausted prompting and few-shot? (2) Do you have a held-out eval that prompting can't improve? (3) Is the thing you want a *behavior* (tone, format, a skill), not fresh *facts*? If you can't answer yes to all three, fine-tuning is probably the wrong tool.

    Fine-tuning vs RAG vs long context — what is each for?

    This is the decision that saves you weeks. Each technique solves a different problem:

    Approach Best for Trade-off
    RAG Answering over your own, changing knowledge base Retrieval quality is the hard part
    Fine-tuning Teaching a style, format, or skill Doesn't add fresh facts; costly to update
    Long context One-off analysis of a few big docs Expensive per call; "lost in the middle"; no persistence

    The rule of thumb: RAG for knowledge, fine-tuning for behavior, long context for one-shot. And they're complementary, not either/or — Meta's guidance is that a hybrid of RAG plus fine-tuning often wins. The empirical backing for "not for facts" is real: Gekhman et al. (EMNLP 2024) found LLMs mostly acquire knowledge in pretraining, and fine-tuning them on new facts is learned slowly and linearly increases their tendency to hallucinate. Fine-tune to change how the model behaves; use RAG to change what it knows.

    What are the main ways to fine-tune?

    Method Trains Relative VRAM Best for
    Full fine-tuning All weights Highest Max capacity; rarely needed, high forgetting risk
    LoRA Low-rank adapters (<1% of params) Moderate The default adapter method
    QLoRA LoRA on a 4-bit-quantized base Lowest Big models on a single GPU

    Full fine-tuning updates every weight — maximum capacity, maximum cost and memory, and the highest risk of the model forgetting its other skills. In 2026 it's rarely worth it. Parameter-efficient fine-tuning (PEFT) freezes the base and trains a tiny set of new parameters instead, which sidesteps both the hardware wall and most of the forgetting.

    What are LoRA and QLoRA, and why do they dominate?

    LoRA (Hu et al., 2021) freezes the pretrained weights and injects small trainable low-rank matrices into each Transformer layer — so you train a fraction of a percent of the parameters while matching full fine-tuning on many tasks. QLoRA (Dettmers et al., 2023) goes further: it back-propagates through a frozen 4-bit quantized base into the LoRA adapters, using 4-bit NormalFloat, double quantization, and paged optimizers. The headline result is why local fine-tuning became normal: QLoRA fine-tunes a 65B model on a single 48GB GPU while preserving full 16-bit task performance. In practice you almost always reach for QLoRA — it's LoRA's quality at a quarter of the memory.

    SFT vs preference tuning (DPO vs RLHF) — which do you need?

    Two stages, and most projects only need the first:

    Stage Method What it's for
    Supervised fine-tuning (SFT) Train on (input, output) pairs, minimize next-token loss on the target Teaching a format, style, or skill — the workhorse
    Preference tuning DPO (default), or RLHF/PPO Aligning to human preference, after SFT

    SFT is where you teach the behavior. If you also need the model to prefer one kind of answer over another (tone, helpfulness, refusals), you add preference tuning. DPO (Rafailov et al., 2023) — "your language model is secretly a reward model" — turned this into a simple classification loss over chosen/rejected pairs, needing only two models and no separate reward model or online sampling. It replaced the older, unstable RLHF/PPO pipeline for most teams. (Newer single-stage variants like ORPO and KTO exist too, supported in the same tools.)

    How much data do you need, and how should it be formatted?

    Less than people expect — quality beats quantity, every time. Directional sizing (not laws):

    Task type Examples (directional)
    Simple (classification, extraction, format) ~50–100 to start
    Common sweet spot / plateau ~300–1,000
    Complex (translation, summarization) 5,000–200,000+

    Returns diminish early — many teams see performance plateau by a few hundred examples, with more data mainly reducing run-to-run variance. The practitioner rule: 1,000 carefully curated examples beat 50,000 scraped ones. Format matters as much as size — match your training format to how you'll prompt at inference. Common shapes:

    {"messages": [{"role": "user", "content": "What color is the sky?"},
                  {"role": "assistant", "content": "It is blue."}]}   // conversational
    {"prompt": "The sky is", "completion": " blue."}                  // prompt-completion
    

    Conversational datasets get the chat template applied automatically; train on assistant turns only, and keep a de-duplicated train/eval split.

    What GPU and budget do you actually need?

    Rough, directional figures — they vary with sequence length, batch size, and optimizer, so treat them as estimates, not benchmarks:

    Model Method Typical GPU ~VRAM ~Cost/run
    7B QLoRA RTX 4090 6–10 GB ~$1–5
    13B QLoRA A100 40GB 12–18 GB ~$2–5
    34B QLoRA A100 80GB 24–36 GB ~$8–14
    70B QLoRA H100 80GB 40–60 GB ~$11–16
    70B Full fine-tune 8× H100 ~640 GB ~$255–510

    The takeaway: a 7B QLoRA run can cost under $5, and QLoRA now fits an 8B fine-tune on a single 12–16GB consumer GPU. Full fine-tuning a 70B is 20–50× the cost — another reason adapters won.

    Dexity Intel · free newsletter

    Liking this? Get the next one in your inbox.

    JD-backed career reads, AI market signals, and field-tested tool guides — a few times a month. No fluff, no spam.

    Which tools should you use?

    Tool Pick it when
    HuggingFace TRL + PEFT The reference path; SFTTrainer + LoraConfig, full control
    Unsloth Fastest single-GPU on-ramp — ~2× faster, up to ~70% less VRAM
    Axolotl Config-driven YAML; reproducible, scales to multi-GPU
    Modal (or any serverless GPU) You have no local GPU — on-demand A100/H100, scales to zero

    For a first fine-tune, Unsloth or HF TRL on a single GPU is the right start; reach for Axolotl when you want a reproducible YAML config, and Modal when you don't own the hardware.

    How do you run a fine-tune, step by step?

    1. Confirm you should fine-tune (behavior, not facts; prompting exhausted; eval defined).
    2. Curate the dataset — a few hundred high-quality, consistently-formatted examples; hold some out for eval.
    3. Pick base + method — a strong open base, QLoRA adapter.
    4. Train — the HuggingFace TRL reference path:
    from datasets import load_dataset
    from trl import SFTTrainer, SFTConfig
    from peft import LoraConfig
    
    dataset = load_dataset("your/dataset", split="train")
    
    trainer = SFTTrainer(
        model="Qwen/Qwen3-8B",
        train_dataset=dataset,
        args=SFTConfig(learning_rate=1e-4, num_train_epochs=2, max_length=1024),
        peft_config=LoraConfig(r=16, lora_alpha=32, lora_dropout=0.05, task_type="CAUSAL_LM"),
    )
    trainer.train()
    # QLoRA: also pass quantization_config=BitsAndBytesConfig(load_in_4bit=True)
    

    Recommended starting hyperparameters (directional — tune against your eval):

    Hyperparameter Starting point
    rank r 16–32 (higher = more capacity + overfit risk)
    lora_alpha r or 2·r
    learning rate ~2e-4 (LoRA/QLoRA)
    epochs 1–3 (>3 = diminishing returns + overfit)
    target modules all linear layers, not attention-only
    1. Evaluate, then decide to ship (next section).

    How do you evaluate a fine-tuned model?

    You cannot skip this — a fine-tune that "feels better" is not a fine-tune that is better. The method:

    • Compare on a held-out test set the model never trained on, against both the base model and your best-prompt baseline, on task-specific metrics.
    • Open-ended tasks → LLM-as-judge or rubric scoring (the same eval discipline RAG needs; evals appear in 56% of AI-engineer JDs for a reason).
    • Watch train vs. eval loss for overfitting — a training loss dropping below ~0.2 is a red flag.
    • Run a general-capability check on a small held-out benchmark to catch regressions from catastrophic forgetting.

    What are the most common failure modes — and their fixes?

    Failure What it is Fix
    Catastrophic forgetting Model loses prior skills as it fits your task (worse at larger scale) Use PEFT/LoRA not full-FT; lower LR/epochs; mix in general data
    Overfitting Memorizes the train set, fails to generalize 1–3 epochs, weight decay, early-stop on eval loss
    Trying to inject facts New knowledge learned slowly, raises hallucination Use RAG for knowledge; fine-tune only for behavior
    Too little / low-quality data Weak or noisy signal Curate; consistent format; quality over quantity
    Format drift Training format ≠ inference format Match the chat template exactly; train on assistant turns only

    Where does fine-tuning fit in the AI-engineer skill map?

    Honestly? Below where most people put it. In Dexity's 390-posting scan, fine-tuning is a 26% skill — tied with RAG, and well behind evals (56%) and agents (50%). It's real and worth knowing, but it's the one candidates over-index on because it sounds like the deep AI work. The higher-leverage skills to build first are RAG, evals, and agents — fine-tuning is the specialist tool you add once you can prove, with an eval, that nothing simpler will do. Learn the decision discipline first; the training is the easy part.

    Frequently asked questions

    Is fine-tuning better than RAG?

    They solve different problems. RAG adds knowledge that changes; fine-tuning teaches style, format, or a skill. They're often combined — RAG for the facts, fine-tuning for the behavior — and Meta's guidance is that a hybrid usually wins. Don't fine-tune to add facts; that raises hallucination (Gekhman et al., 2024).

    How many examples do I need to fine-tune an LLM?

    Directionally: ~50–100 can start a simple task, ~300–1,000 is a common sweet spot, and complex tasks may want thousands. Quality and consistent formatting matter more than raw count — 1,000 curated examples beat 50,000 scraped ones.

    Can I fine-tune on my own GPU?

    Often yes. QLoRA fits a 7–8B fine-tune on a 12–16GB consumer GPU (a 7B run can cost under $5), and a single 48GB GPU can fine-tune a 65B model (Dettmers et al., 2023). Full fine-tuning of large models still needs a cluster.

    LoRA vs QLoRA — which should I pick?

    QLoRA for almost everything — it's LoRA's quality on a 4-bit base, at a fraction of the VRAM. Use plain LoRA only when you have memory to spare and want to avoid quantization.

    What's the difference between SFT and DPO?

    SFT teaches behavior from (input, output) pairs — the workhorse. DPO aligns the model to human preferences from chosen/rejected pairs, run after SFT, and has replaced the older RLHF/PPO pipeline for most teams.

    Does fine-tuning add new knowledge to a model?

    Poorly. Models learn new facts slowly during fine-tuning, and doing so increases hallucination (Gekhman et al., EMNLP 2024). For knowledge, use RAG; reserve fine-tuning for behavior, style, and format.

    Build the judgment, not just the training script

    The hard part of fine-tuning isn't the code — it's knowing when it's the right tool, and proving it with an eval. Dexity's Ship Production Code with AI course builds exactly that judgment: you ship a real, evaluated LLM feature and learn the decision discipline (prompt → RAG → fine-tune) that separates engineers who reach for the right technique from those who fine-tune everything and measure nothing.

    Sources — verified (primary): LoRA, Hu et al. 2021; QLoRA, Dettmers et al. 2023; DPO, Rafailov et al. 2023; fine-tuning on new knowledge → hallucination, Gekhman et al. EMNLP 2024; HuggingFace TRL SFTTrainer; OpenAI fine-tuning best practices; Meta — to fine-tune or not. VRAM/cost and dataset-size figures are directional practitioner estimates (Spheron), not benchmarks — verify current prices. JD figures from Dexity's analysis of live US AI-engineer postings (2026); directional, US-only. · Dexity.com

    Go from reading to doing · Dexity Course

    Ship Production Code with AI

    Most senior engineers have tried Cursor or Claude Code and ended up with larger PRs, more review cycles, and hidden technical debt. The problem isn't the tools — it's that nobody taught the system design and reasoning control behind them.

    5 Weeks
    Live instruction
    3 Projects
    Real deliverables
    30 Seats
    Per cohort, capped
    Marcus Chen
    Marcus Chen
    Principal Platform Engineer · Databricks
    Explore the course
    Anmol Gulwani

    Anmol Gulwani

    Dexity

    Connect on LinkedIn
    Questions or suggestions?hello@dexity.com