PXT · AI Consulting Built by engineers since 2007
All articles
Technical 9 min read

RAG for business: how retrieval-augmented generation works and when to use it

What RAG is, how the pipeline works, how it compares to fine-tuning and long context, and why retrieval quality, not the model, decides whether it works.

RAG, short for retrieval-augmented generation, is how most businesses put an AI model to work on their own data. When a question comes in, the system finds the most relevant pieces of your documents and hands them to the model along with the question, so the answer is grounded in your information rather than the model’s general training.

It is usually the first thing to reach for when you want AI that knows your business, and it is cheaper and more flexible than fine-tuning. It is also, in production, mostly a retrieval engineering problem wearing an AI costume. The model is the easy part. This guide explains the pipeline, how RAG compares to the alternatives, and where the actual difficulty lives.

What RAG actually is

A general AI model knows a lot about the world and nothing about your business. It has never seen your policies, your product docs, your support history, or last week’s pricing update. RAG closes that gap without retraining anything.

The idea is simple. Instead of expecting the model to already know your information, you store it separately and retrieve the relevant parts at the moment of each question. The model answers using those retrieved pieces as source material. The result is an AI that can answer about your specific business, cite where each answer came from, and reflect changes the moment you update the underlying document.

The pipeline

StageWhat happensWhy it is harder than it looks
Ingestion and chunkingDocuments are pulled in and split into passagesChunks too big bury the answer in noise; too small lose the context that made them meaningful. Document structure matters more than chunk size
EmbeddingEach chunk becomes a numerical representation of its meaning, stored in a vector storeGeneral-purpose embeddings underperform on domain vocabulary. Your industry’s jargon may not sit where you expect
RetrievalThe question is embedded, and the closest chunks are foundThis step decides everything. The model can only answer as well as the passages it receives
Filtering and access controlResults are restricted to what this user is permitted to seeEasy to forget, painful to retrofit, and a genuine security issue once real users arrive
GenerationRetrieved chunks and the question go to the model togetherThe instruction to answer only from provided material, and to say when the answer is not there, does a lot of work

Notice how little of that is model selection. In every production system we have built, moving from a good model to a better one produced a smaller improvement than fixing how documents were chunked.

Why businesses choose RAG

It stays current. Update a document and the next answer reflects it, with no retraining. For anything that changes, policies, prices, product details, this alone rules out baking knowledge into a model.

It keeps answers traceable. Because the model answers from retrieved passages, you can show which source each answer came from. That citation trail matters enormously for trust, and it is close to mandatory in any regulated context.

It protects your data. Your information stays in your store and is pulled in only at query time, rather than being trained into a shared model. Paired with enterprise agreements that disable retention and, when needed, deployment in your own cloud, RAG lets you put AI on sensitive data without handing that data to anyone.

It is cheaper to build and change. Standing up and updating a RAG system costs far less than repeatedly fine-tuning, and it adapts to new information immediately.

RAG, fine-tuning, or a bigger context window

These get pitched as competitors. They solve different problems, and a serious system often uses more than one.

RAGFine-tuningLong context window
What it changesWhat the model knows at answer timeHow the model behavesWhat the model sees in one request
Best forAnswering from a large or changing body of knowledgeConsistent style, output format, narrow specialized tasksOne-off analysis of a bounded set of documents
UpdatingInstant. Change the documentRequires retrainingNot applicable
TraceabilityStrong. Cites retrieved sourcesNoneWeak at volume
Cost shapeInfrastructure plus per-query retrievalUpfront training, then cheaper inferenceExpensive and slow per request at scale
Fails whenRetrieval surfaces the wrong passagesYou expected it to add knowledgeThe corpus outgrows the window
Typical verdictThe default for business knowledgeA later optimization, not a starting pointGreat for a task, wrong for a system

The single most expensive misconception in this space is that fine-tuning is how you make a model know your business. Fine-tuning shapes behavior. Retrieval supplies knowledge. Teams that fine-tune first usually end up building retrieval afterwards anyway, having paid for both. Our build versus buy guide covers the full ladder.

What makes RAG hard in production

RAG demos in an afternoon and ships in weeks, and the gap between those two is almost entirely retrieval quality. A first version that answers your ten favorite questions can fall apart on the hundred questions real users actually ask.

The hard parts are unglamorous. Chunking documents so the right context is retrievable, which usually means respecting document structure rather than splitting on character count. Choosing embeddings that capture your domain’s meaning rather than general English. Handling source documents messy enough that they are barely usable as text. Filtering retrieval by permission so a user cannot pull a passage they should not see.

And above all, evaluation. When a RAG system gives a wrong answer, the model is rarely the culprit. It answered faithfully from bad context that retrieval handed it. Without a way to measure retrieval quality across real questions, you cannot tell the difference between those two failures, which means you cannot fix either.

What this looks like in a real system

Two production examples, both of which spent most of their engineering effort somewhere other than the model.

On a mortgage build, retrieval ran on Postgres with pgvector for borrower-history lookup. The choice of a vector extension on a database the client already operated, rather than a separate vector product, was deliberate: one fewer system to run, back up and secure, on a workload that did not need more. A sensitive-data pipeline also ran a local model purely for PII anonymization before anything reached a hosted model.

On a logistics document pipeline, the corpus was messy shipping paperwork, bills of lading, customs forms and proof-of-delivery scans, and a dedicated vector store was the right call at that volume. The number worth knowing from that build is not the throughput. It is that the system ran a custom evaluation harness of 1,200 cases on every pull request.

That is what separates a RAG demo from a RAG system. Every change to chunking, embeddings, retrieval parameters or prompts was measured against 1,200 real cases before it shipped, so a change that improved ten questions and quietly broke forty never reached production. Building that harness was a meaningful share of the project cost and the reason the system was still running eighteen months later.

If you take one thing from this article: budget for the evaluation harness explicitly, in the plan and in the number. It is invisible in a demo and it is the whole difference in production.

A checklist before you build

Define the questions it must answer. Collect a real set of questions users will actually ask, including the awkward, ambiguous and adversarial ones. This becomes your evaluation target, and building it first keeps the project honest.

Get the source documents in order. RAG can only retrieve what exists in usable form. If your knowledge lives in messy PDFs, out-of-date wikis or people’s heads, that cleanup is part of the project. Pretending otherwise is how RAG systems disappoint.

Decide where the data lives and who can see it. Pick your store, confirm retention is disabled on the model side, and settle access rules so a user only retrieves what they are permitted to see. Access control inside retrieval is easy to forget and painful to retrofit.

Plan evaluation from day one. Decide how you will measure whether retrieval surfaces the right passages and whether answers are grounded. Without this you are shipping on vibes and will not learn where it fails until users tell you.

Plan for freshness. Decide how updated documents get back into the system, and how fast. A RAG system that silently answers from last quarter’s policy is worse than no system, because it is confidently wrong.

Run through those five and most RAG projects go smoothly. Skip them and you get the classic outcome: a demo that dazzles on ten questions and frustrates on the hundred that follow.

Frequently asked questions

Is RAG the same as a chatbot? No. A chatbot is an interface. RAG is the technique that lets that chatbot, or any AI feature, answer from your data. You can use RAG behind a chatbot, a search box, or an automated workflow with no chat at all. It is also the layer underneath most useful AI copilots in SaaS products.

Do we need a vector database for RAG? Usually some form of vector search, but it can be an extension on a database you already run, like Postgres with pgvector, rather than a separate product. The right choice depends on scale, latency requirements and what you already operate well. Fewer systems is a real advantage.

Can RAG work on our private, sensitive data? Yes, and it is a common reason businesses choose it. The data stays in your store, is retrieved only at query time, and never trains a shared model. With retention disabled and, where needed, deployment in your own environment, RAG is the standard pattern for sensitive information. For health data specifically, see our guide to HIPAA-compliant AI.

How long does a RAG build take? A useful first version often takes a few weeks. The time goes into retrieval quality and evaluation on your real documents, not model integration. Budget for the evaluation work explicitly; it is what separates a demo from a system users trust.

How do we know if retrieval is the problem? Look at the retrieved passages for a wrong answer before you look at the model. If the right passage was not retrieved, the model was never going to answer correctly and no prompt change will fix it. If the right passage was retrieved and the answer is still wrong, then you have a generation problem, which is much rarer.


The cheapest useful thing you can do before starting a RAG project: write down fifty real questions your users would ask, including the ones you hope nobody asks. That list will tell you more about feasibility than any vendor demo, and you will need it as your evaluation set regardless of who builds the system.

If you want a read on whether RAG fits your data and where the effort will actually land, that is what our custom AI work starts with. Often the honest answer is that retrieval quality, not the model, is the whole project.

Recognise your own problem in this?

Enough reading. Let's scope it.

Bring us the workflow. We'll tell you what it would take, what it would cost, and whether it's worth doing at all.

No deck · No demo · No sales pressure