Use RAG when the model needs to know your facts. Use fine-tuning when the model needs to behave differently. Retrieval-augmented generation (RAG) gives a language model your documents at the moment it answers, so its replies reflect your policies, prices, and product details. Fine-tuning retrains the model on examples so that it adopts a style, format, or narrow skill. Most businesses that want an assistant to "know our company" need RAG, not fine-tuning.
RAG vs fine-tuning at a glance
| RAG | Fine-tuning | |
|---|---|---|
| What it changes | What the model can look up | How the model behaves |
| Best for | Answers from your own documents | Consistent tone, format, or a narrow task |
| Updating knowledge | Edit or add a document | Retrain the model |
| Can show its sources | Yes | No |
| Data needed | Your existing documents | Hundreds or more of high-quality examples |
| Upfront effort | Build a retrieval pipeline | Prepare training data and run training |
| Main risk | Poor retrieval returns the wrong passage | The model drifts out of date and still sounds confident |
What is RAG, and where the term comes from
RAG is short for retrieval-augmented generation. "Retrieval" is the search step that finds relevant passages. "Generation" is the language model writing an answer. "Augmented" means the answer is written with those passages in front of the model.
The term comes from a 2020 research paper by Patrick Lewis and colleagues, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. The paper combined a text generator with a searchable index of documents so that answers could draw on stored text and not only on what the model had absorbed in training. The business systems built today are simpler in construction than the research model, but the idea is the same: look it up, then answer.
How RAG works
A RAG system has two stages.
Ingestion. Your documents are collected, cleaned, split into passages, and converted into embeddings, which are numerical representations of meaning. The embeddings are stored in a vector database.
Answering. When someone asks a question, the system converts the question into an embedding, finds the passages closest in meaning, and gives those passages to the language model with an instruction to answer from them.
The model itself is unchanged. It is simply handed the right pages before it answers. That is why a RAG assistant can be corrected by fixing a document, and why it can point to the source of each answer.
In Ask Haseeb AI, an open-source RAG assistant built by our founder, documents are picked up automatically from Google Drive, split into passages of about 350 tokens with overlap so that each passage keeps its meaning, embedded with OpenAI, and stored in Pinecone. A FastAPI backend handles the retrieval and answer steps. The code is linked from our work page.
Embeddings and vector search in plain language
These two ideas do most of the work in a RAG system, so they are worth understanding.
An embedding is a long list of numbers that stands for the meaning of a piece of text. An embedding model reads a passage and produces that list. Passages that mean similar things get similar lists, even when they use different words. "What is your refund policy?" and "Can I get my money back?" share almost no words, but their embeddings sit close together. The OpenAI embeddings guide describes how this is used for search.
A useful picture is a map. Every passage from your documents is a pin on the map, and passages about the same subject are pinned near each other. The map has far more than two directions, but the idea holds.
Vector search is the act of finding the nearest pins. The question is embedded in the same way, placed on the map, and the system returns the passages closest to it. A vector database is a database built to store these lists and run that nearest-neighbour search quickly. Pinecone is one example; its documentation explains the concept in more detail.
Two practical consequences:
- Search works by meaning, not keywords. Customers do not need to use the wording in your documents.
- Search is only as good as the passages. If a passage mixes three topics, or is cut in the middle of an explanation, its pin lands in a vague place and is harder to find. This is why document preparation matters so much.
How fine-tuning works
Fine-tuning takes an existing model and trains it further on your examples, usually pairs of input and ideal output. After training, the model produces that kind of output without needing long instructions. The OpenAI fine-tuning guide walks through the process of preparing examples and running a training job.
Fine-tuning is good at:
- a consistent brand voice or writing style
- a strict output format, such as a specific JSON structure
- narrow classification tasks with many labelled examples
Fine-tuning is poor at keeping facts current. Anything the model learned in training is frozen. When your prices change, a fine-tuned model keeps quoting the old ones until you retrain it.
The third option: prompt engineering
Before choosing either, check whether a well-written prompt is enough. Prompt engineering means giving the model clear instructions, the context it needs, and a few examples of good output, all inside the request itself. Nothing is built and nothing is trained.
A prompt alone is often enough when:
- The knowledge is small and stable. If everything the assistant needs fits on a page or two, such as opening hours, a short service list, and a handful of policies, you can place it directly in the prompt. There is nothing to retrieve.
- The problem is tone or format. "Reply in two short paragraphs, friendly, no jargon" plus three examples solves many style problems that people assume need fine-tuning.
- You are still learning what you need. A prompt can be changed in minutes. It is the cheapest way to find out what the assistant should do before paying for a pipeline.
A prompt stops being enough when the content is too large to include every time, when it changes often, or when you need each answer traced to a source. That is the point to add RAG. For a small FAQ, the simpler route is described in how to train your AI chatbot on your FAQs.
When to choose RAG
- Your answers depend on documents that change: policies, pricing, product documentation, internal processes.
- You need answers that can be traced to a source.
- You want to correct the assistant by editing content, without retraining anything.
- You do not have hundreds of clean training examples.
This describes most internal knowledge assistants and customer support chatbots.
When to choose fine-tuning
- The model already has the knowledge it needs, but the output is in the wrong style or format.
- You have a large set of high-quality examples of exactly what good output looks like.
- The task is narrow and repeated at high volume, so shorter prompts save real money.
When to use both
The two are not rivals. A common pattern is RAG for knowledge and light fine-tuning, or simply careful prompting, for tone. In practice we recommend starting with RAG and good prompts. Many teams find that is enough and never need to fine-tune.
A decision checklist
Find the row that matches your situation.
| Your situation | Start with |
|---|---|
| The assistant needs facts from documents that change | RAG |
| All the facts fit in a page or two and rarely change | Prompt engineering |
| Answers must show where they came from | RAG |
| The facts are right but the tone or format is wrong | Prompt engineering, then fine-tuning if that fails |
| You have many labelled examples of a narrow, repeated task | Fine-tuning |
| You have documents but no training examples | RAG |
| The assistant must answer in more than one language from the same content | RAG |
| You need current facts and a strict house style | RAG plus prompting, fine-tuning only if needed |
| You are not sure what the assistant should do yet | Prompt engineering |
On the language row: a RAG assistant can retrieve from one knowledge base and reply in the customer's language, which is how an Arabic AI chatbot can serve Arabic and English speakers from the same documents.
Preparing your data for RAG
Most of the quality of a RAG system is decided before any code runs. Preparation covers five things.
- Choose the sources. List the documents that hold the real answers. Leave out drafts, internal notes that contradict published policy, and anything customers should not see.
- Remove duplicates and old versions. If two files give different prices, the assistant may quote either. Keep one current version of each document.
- Fix the structure. Clear headings, one topic per section, and tables converted into readable text all help. Scanned PDFs need their text extracted and checked.
- Split into passages. Each passage should make sense when read alone. Overlap between neighbouring passages stops an explanation being cut in half.
- Attach metadata. Record the source file, section, and date for each passage, so answers can cite a source and old content can be filtered out.
Then decide how updates will arrive. In Ask Haseeb AI, new files placed in a Google Drive folder are ingested automatically, so keeping the assistant current means saving a document in the right place.
Evaluating a RAG system with real questions
A RAG assistant should be tested the way it will be used. The method is simple and needs no special tooling to begin.
- Collect real questions. Take them from support emails, chat logs, and what staff are asked most. Include awkward phrasings and a few questions the documents do not answer.
- Write down the expected answer and its source for each question.
- Check retrieval first. For each question, look at the passages the system returned. Is the right passage among them? If not, the problem is in chunking, content, or search, and no prompt will fix it.
- Then check the answer. Is it correct, is it supported by the retrieved passages, and does it cite the right source?
- Check the refusals. For questions with no answer in the documents, the assistant should say so and offer a handoff, not guess.
- Fix and re-run. Keep the question set and run it again after every change to documents, chunking, or prompts.
Separating retrieval from answering is the key step. It tells you which half of the system to fix. Fine-tuned models need the same discipline, with a set of examples held back from training and used only for testing.
Cost and maintenance compared
RAG costs more to set up as a system, because there is a pipeline to build: ingestion, chunking, a vector database, retrieval, and evaluation. Maintenance is cheap. Updating knowledge means adding or editing a document.
Fine-tuning needs training data to be collected and cleaned, which is usually the real cost. Each update to the model's knowledge means another training run and another round of testing.
Prompt engineering has almost no setup cost, but every request carries the full instructions and context, so it suits small, stable content.
For a business whose information changes monthly, RAG is almost always cheaper to own over a year. For how these pieces affect a quote, see how much it costs to build an AI agent.
Common mistakes
Fine-tuning to add knowledge. This is the most frequent and most expensive mistake. If the goal is "make it know our documents", build RAG.
Loading messy documents into RAG. Retrieval can only find what is written clearly. Duplicates and outdated files produce contradictory answers. Clean the content first.
Skipping evaluation. Before launch, test the assistant on real questions and check each answer against the source. Retrieval problems are easy to fix once you can see them.
Assuming RAG removes all errors. RAG greatly reduces invented answers, but the model can still misread a passage. Keep a human handoff for anything that matters.
Expecting RAG to take actions. RAG gives accurate answers. If the assistant also has to update a record or change a booking, that is an agent, usually with RAG inside it. See AI agent vs chatbot.
How Axenor AI builds RAG systems
We start with your documents and a list of real questions people ask. We build the ingestion and retrieval pipeline, test it against those questions, and show you how the system is structured so your team can maintain it. Read more on our RAG knowledge assistants page, or see what a RAG chatbot is for a plain-language introduction.
If you are unsure which of the three options fits, our AI automation consulting starts with that question, and you can book a free automation audit to talk it through.