🧠 Artificial intelligence

Fine-tuning or prompting? How to adapt a model to your needs

When good instructions are enough, when you need RAG and when fine-tuning a language model is worth it: costs, data required, pros and cons.

Anyone who starts using artificial intelligence in a structured way soon reaches a question: how do I get the model to work the way I need? There are three possible answers, often confused with one another: write better instructions, give the model the right documents, or change its behaviour through further training, known as fine-tuning. Choosing well avoids spending weeks and budget on a problem that a good prompt could have solved.

Three different levers

1. Instructions and examples in the prompt

This is the simplest and fastest lever. You describe the task, tone, format and constraints, and provide a few examples of the desired result. Many services let you save these instructions permanently, as the "system instructions" of a custom assistant.

Suited to: format and style of answers, rules of behaviour, new tasks to experiment with.

2. Information retrieval (RAG)

The model is connected to a document base: before answering, the system retrieves the relevant passages and places them in the context.

Suited to: giving the model specific, up-to-date knowledge, such as internal procedures, price lists and technical documentation, with verifiable citations.

3. Fine-tuning

You take an already trained model and train it further on a set of your own examples, usually pairs of question and ideal answer. The model's weights are changed, and the new behaviour becomes part of the model itself.

Suited to: teaching a very specific and consistent style, a rigid output format, a narrow and repetitive task, or getting performance similar to a large model from a smaller, cheaper one.

A frequent mistake: using fine-tuning to add knowledge

It is intuitive to think: "I'll train the model on my manuals so it knows them". In practice this approach works poorly for facts. Fine-tuning is effective at changing how the model answers, much less at making it reliably memorise what to say. Moreover, every time a document changed, training would have to be repeated. For knowledge that gets updated, RAG is almost always the right path.

Practical comparison

Criterion Prompt RAG Fine-tuning
Time to get started Minutes Days or weeks Weeks
Data required A few examples Existing documents Hundreds or thousands of curated examples
Updating Immediate Just update the documents New training run
Specific knowledge Limited to context Excellent Unreliable
Consistent style and format Good Neutral Excellent
Skills required Low Medium High

How fine-tuning works, briefly

The typical process involves:

  1. collecting examples: real inputs and ideal outputs, reviewed by experts;
  2. cleaning and balancing, so the model does not learn mistakes or specialise only in the most frequent cases;
  3. training, often with efficient techniques such as LoRA, which instead of modifying all the weights adds small trainable components, greatly reducing cost and resources;
  4. evaluation on held-out examples, comparing the fine-tuned model with the original;
  5. monitoring after release.

One risk to be aware of is the loss of general capabilities: a model fine-tuned aggressively on a narrow task may get worse at other tasks it previously handled well.

In the vast majority of cases it pays to proceed step by step.

  1. Start with the prompt. Write clear instructions, add examples, test on real cases. It is often enough.
  2. Add RAG if the problem is that the model does not know your information.
  3. Consider fine-tuning only if, after the first two steps, there are remaining problems of style, format or cost that you have measured, and if you have enough good-quality examples.

The three levers can also be combined: a model fine-tuned to always answer in a certain format can be connected to a document base and receive specific instructions for each use.

Example: a customer service desk

A company wants an assistant that answers customers about warranty status.

  • With the prompt it defines a polite tone, a maximum length and the rule of handing refund cases over to an operator.
  • With RAG it connects the current warranty terms and product sheets.
  • Fine-tuning comes into play only if, after months of use, the company wants to transfer the behaviour to a smaller model to cut costs, using as examples the best answers already approved by operators.

Data and confidentiality

The examples used for fine-tuning become part of the model. If they contain personal or confidential data, the model might in some cases reproduce fragments of it. It is therefore important to pseudonymise examples and check with the provider where the training data and the resulting model are stored.

In short

  • There are three levers for adapting a model: prompting, RAG and fine-tuning.
  • Prompting is the quickest solution for style, format and rules of behaviour.
  • RAG is the right choice for specific, updatable knowledge.
  • Fine-tuning serves consistent behaviour, narrow tasks or cost reduction.
  • Proceed step by step and measure results before moving to the next lever.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. A computer science graduate, he combines rigorous technical analysis with attention to the people who use technology.

Read also