CyberFreezeDev Loading
  1. Home
  2. Services
  3. LLM fine-tuning

LLM fine-tuning for tasks a prompt cannot get right

Further training on your examples so a model follows your format and decisions consistently.

3D render of matte panels of neural network nodes, with activations lighting up layer by layer

At a glance

LLM fine-tuning
Base models
Open-weight models such as Llama, Qwen, Mistral and Gemma, sized to the task and the hardware
Methods
Supervised fine-tuning with LoRA or QLoRA adapters; full fine-tuning only when justified
Tooling
Hugging Face Transformers, PEFT and TRL, Unsloth, Axolotl
Data format
JSONL instruction or chat pairs, versioned with the training run
Outputs
Adapter weights, merged model, GGUF for llama.cpp and Ollama where useful
Serving
vLLM or llama.cpp on your server, or a hosted endpoint you own

When fine-tuning is the right answer

Fig. 01 GPU test bench used for sizing and benchmarks

Missing knowledge needs RAG and vague instructions need better prompts. Fine-tuning pays off for strict formats, high volume, private data or specialised vocabulary.

Read more about When fine-tuning is the right answer

Most teams who ask for LLM fine-tuning actually need something else. If the model does not know your products, policies or prices, that is a knowledge problem and a RAG chatbot solves it better, because documents change and retrieval picks up the change on the next index. If the model gets a task wrong because the instructions are vague, better prompts and a few examples usually fix it in a day.

Fine-tuning earns its cost when:

  • the output must follow a strict structure every time (a JSON schema, a report layout, a coding scheme) and prompting still slips;
  • the task is narrow and repeated thousands of times, so a small fine-tuned model can replace a large general one at a fraction of the running cost;
  • the data must stay on your premises and a small open model needs to match a larger hosted one on that one task;
  • the vocabulary is specialised (clinical shorthand, trade terms, a regional language mix) and the base model keeps misreading it.

We start every project by trying the cheaper options against your test set. If they pass, you save the training budget.

How LoRA and QLoRA keep it practical

Train a small adapter, not the whole model

LoRA trains a small adapter on a frozen base; several adapters share one server.

Read more about Train a small adapter, not the whole model

LoRA (low rank adaptation, Hu et al. 2021) freezes the base model and trains small extra matrices. The adapter is a few hundred megabytes at most, and several adapters can share one base model on one server.

Quantized training on modest GPUs

With a 4 bit base model, QLoRA trains mid-sized models on one workstation GPU.

Read more about Quantized training on modest GPUs

QLoRA (Dettmers et al. 2023) loads the base model in 4 bit precision while training the adapter, which lets mid sized models train on a single workstation GPU rather than a cluster.

Reversible

The base model stays untouched; a new base means retraining only the adapter.

Read more about Reversible

The base model is untouched. If a new base model is released, you retrain the adapter on the same dataset rather than starting over.

How a fine-tuning project runs

Fig. 02 Face on: nodes lighting up in the first layer, later layers behind
  1. 01 Define the task and the score

    One task, a held-out test set of real cases and a scoring method.

    Read more about Define the task and the score

    One task, written down, with a held out test set of real inputs and correct outputs and a way to score them: exact match, field accuracy, a rubric checked by a reviewer, or a mix.

  2. 02 Baseline

    A strong hosted model and untrained open models set the score to beat.

    Read more about Baseline

    Run the test set through a strong hosted model with a good prompt, and through the candidate open models without training. This is the number fine-tuning has to beat.

  3. 03 Build the dataset

    Examples collected, cleaned and agreed with your experts, which usually takes longer than training.

    Read more about Build the dataset

    Collect and clean examples from your records, remove personal data that is not needed, fix inconsistent labels and agree on edge cases with your domain experts. This step usually takes longer than training.

  4. 04 Train and compare

    Adapters trained with a few settings and scored against the baseline, failures included.

    Read more about Train and compare

    Train adapters with a few settings, score each on the test set, and inspect the failures by hand. We report the results against the baseline, including where the tuned model is worse.

  5. 05 Package and deploy

    The adapter served behind a logged API, quantized for your hardware and wired in.

    Read more about Package and deploy

    Merge or serve the adapter, quantize if needed for your hardware, put it behind an API with logging, and connect it to the workflow that uses it.

  6. 06 Keep the dataset alive

    Corrections made in production become new examples for the next training run.

    Read more about Keep the dataset alive

    Corrections your team makes in production are collected as new examples, so the next training run starts from better data.

The hardware it needs

What we test on in the lab

Small models and quick experiments run on our 8 GB laptop GPU, results published.

Read more about What we test on in the lab

Our lab machine includes an RTX 3070 Ti laptop GPU with 8 GB of memory, which suits small models and quick experiments. We publish what we run on it, with versions and dates, in local LLMs.

Larger runs

Rented cloud GPUs for a one-off run, or your own server for frequent retraining.

Read more about Larger runs

For bigger models we size the training hardware with you: rented cloud GPUs for a one-off run, or a server you own if you will retrain often. See GPU servers and AI hardware.

Serving is a separate decision

Train on rented GPUs, serve on a smaller office machine, both planned up front.

Read more about Serving is a separate decision

A model can be trained on rented GPUs and served on a smaller machine in your office. We plan both before training starts.

Questions

How many examples do we need?

It depends on the task. A narrow formatting or extraction task can show clear gains with a few hundred good examples; a task that needs judgement needs more and needs them consistent. We decide after the baseline, when we can see where the model fails.

Can you fine-tune ChatGPT or Claude?

Some hosted providers offer fine-tuning for some of their models, with the trained model staying on their platform. We use those where they fit, but most of our work is on open-weight models because you own the result and can run it anywhere.

Will fine-tuning stop the model from making things up?

Not on its own. Fine-tuning shapes behaviour and format; it is a poor way to store facts. For factual answers combine a tuned model with retrieval from your documents.

Who owns the model?

You do. The dataset, adapter weights, training configuration and evaluation results are handed over. Check the base model's licence as well; we flag any restrictions before training.

Last updated