Ninestack

How to Customize an LLM: Prompt Engineering vs RAG vs Fine-Tuning

Prompt engineering, RAG or fine-tuning? A practical way to choose the right LLM customization approach, combine them, and prove it works.

Ninestack · · 9 min read

LLM customization is the work of adapting a general-purpose large language model so it performs reliably on your tasks, with your data, in your format. A base model can write, summarise and reason, but it does not know your products, your terminology or the rules your answers must follow. Customization closes that gap.

There are three main ways to customize an LLM: prompt engineering, retrieval-augmented generation (RAG) and fine-tuning. They solve different problems, they cost different amounts of effort, and the best systems often combine two of them. This guide explains what each one does, when to use it, and a simple order of steps that avoids building more than you need.

What is LLM customization?

Customizing an LLM means changing what the model sees or how it behaves, so its output matches a specific job. You can change three things:

  • The instructions it receives: prompt engineering.
  • The information it can look up at answer time: retrieval-augmented generation (RAG).
  • The model's own weights, so new behaviour is learned rather than instructed: fine-tuning.

A useful rule of thumb: RAG changes what the model knows when it answers; fine-tuning changes how it behaves. Prompt engineering is the cheapest way to try both before committing to either.

1. Prompt engineering

Prompt engineering means writing clear system instructions, giving the model examples of good answers (few-shot prompting), and defining the output format. Nothing about the model changes; you change what you ask and how.

When prompt engineering is enough

  • The model already has the knowledge it needs, and the task is mostly about tone, format or structure.
  • You are still discovering what good output looks like and need to iterate quickly.
  • Volumes are modest, so longer prompts do not add meaningful cost or latency.

Where it stops working

Prompts cannot add knowledge the model does not have, such as your internal policies or this week's product data. Very long prompts also become slow and expensive at scale, and complex rules written in prose are followed inconsistently.

2. Retrieval-augmented generation (RAG)

RAG connects the model to your own content. When a question comes in, the system searches your documents, databases or knowledge base, retrieves the most relevant passages, and gives them to the model with the question. The model answers from that material and can cite where each answer came from.

When to use RAG

  • Answers must come from your own documents: policies, contracts, manuals, product specs or support history.
  • The information changes often. Updating a document updates the answers, with no retraining.
  • You need traceability: users or auditors want to see the source behind an answer.
  • Access rules matter, so different users should only see answers from documents they are allowed to read.

Where RAG falls short

RAG is only as good as its retrieval. Poorly structured documents, weak search or the wrong passage sizes lead to confident answers built on the wrong text. RAG also does not teach the model a new writing style, a strict output format or specialist reasoning; it gives the model better material, not new habits.

3. Fine-tuning

Fine-tuning trains an existing model further on examples of the inputs and outputs you want, so the behaviour becomes part of the model. Parameter-efficient methods such as LoRA and QLoRA adjust a small set of extra weights instead of the whole model, which makes fine-tuning faster and cheaper to run and to repeat.

When fine-tuning is worth it

  • Output must follow a consistent structure or house style every time, such as reports, classifications or structured data.
  • The task needs domain-specific judgement that examples teach better than instructions.
  • You want a smaller, faster or cheaper model to match a larger model's quality on one narrow task.
  • Your prompts have grown so long that latency and cost are becoming a problem.

What fine-tuning will not do

Fine-tuning is a poor way to give a model facts that change. Knowledge baked into weights goes out of date, cannot be cited, and is hard to remove. It also needs a well-curated set of examples and an evaluation set to prove the tuned model is actually better.

RAG vs fine-tuning: which do you need?

Most teams asking about LLM customization are really choosing between RAG and fine-tuning. The comparison below covers the questions that usually decide it.

QuestionPrompt engineeringRAGFine-tuning
What it changesInstructions and examplesInformation available at answer timeThe model's behaviour (weights)
Adds your company knowledgeNoYes, and stays currentPartly, and goes out of date
Teaches format, style or judgementSomewhatNoYes
Can cite sourcesNoYesNo
Effort to startLowMediumMedium to high
Needs training dataNoNo (needs good documents)Yes (curated examples)
Updating itEdit the promptUpdate the documentsRetrain the model

If the problem is missing knowledge, start with RAG. If the problem is inconsistent behaviour, look at fine-tuning. If you have both problems, combine them: a fine-tuned model that answers from retrieved documents is common in production.

A simple decision path

The order matters more than the technique. Each step is cheaper than the next, and each one tells you whether the next is needed.

  1. Write down what good looks like. Collect 50 to 200 real questions or inputs with examples of correct answers. This becomes your evaluation set.
  2. Start with prompt engineering on a strong base model and score it against the evaluation set.
  3. If answers fail because facts are missing or out of date, add RAG over your documents and score again.
  4. If answers fail on format, consistency or specialist judgement, fine-tune on curated examples and score again.
  5. Combine techniques only where the evaluation shows a clear gain, then monitor quality in production.

Common LLM customization mistakes

  • Fine-tuning first, when a better prompt or RAG would have solved the problem faster.
  • Using fine-tuning to teach facts that change, then retraining every time they do.
  • Building RAG on messy documents without cleaning, structuring or testing retrieval quality.
  • Skipping the evaluation set, so nobody can say whether the change made answers better.
  • Ignoring privacy and access rules: who can see which documents, and where the model runs.

How to measure whether customization worked

Judge every change against the same evaluation set, not against a few impressive examples. Typical measures are answer accuracy, how often the model follows the required format, the share of answers that cite the right source (for RAG), response time, and cost per request. Re-run the evaluation whenever the model, the prompt or the documents change, because quality can drift in either direction.

Getting started

The right LLM customization approach depends on your data, your quality bar and how often your information changes. If you want help choosing, or want to see how this works on your own documents, these pages explain how Ninestack approaches it:

FAQ

Common questions about LLM customization.

What is LLM customization?+
LLM customization is adapting a general-purpose large language model to a specific task, dataset or format. The three main methods are prompt engineering, retrieval-augmented generation (RAG) and fine-tuning, used alone or together.
Is fine-tuning better than RAG?+
Neither is better in general; they solve different problems. RAG gives the model up-to-date knowledge from your own documents and can cite sources. Fine-tuning changes how the model behaves, such as its format, style or specialist judgement. Many production systems use both.
Can you combine RAG and fine-tuning?+
Yes. A common pattern is a fine-tuned model that has learned the required format and tone, answering from documents retrieved by a RAG pipeline so the facts stay current and traceable.
How much data do you need to fine-tune an LLM?+
It depends on the task, but quality matters more than volume. Narrow tasks can improve with a few hundred well-chosen examples, while broader behaviour changes usually need thousands. A separate evaluation set is essential to confirm the tuned model is better.
Does customizing an LLM keep our data private?+
It can, depending on how the system is deployed. Options include models hosted in your own cloud or on-premises, access controls on the documents RAG can retrieve, and agreements that prevent your data being used to train third-party models.
LLM customization

Not sure which approach fits? Book a call.

Tell us the task, the data you have and the quality bar you need. We’ll come back with a recommendation and a scoped plan inside one business day.