Deep-dive

RAG in practice: when to use it (and when not to)

RAG (Retrieval-Augmented Generation) explained without the hype: what it is, how it works, when it actually solves your problem and when it's over-engineering. The guide from someone who runs it in production.

Jul 22, 2026·9 min read·.md

RAG has become the default answer to everything. "How do I make the AI know about my data?" — "RAG!". "How do I reduce hallucination?" — "RAG!". And most of the time that's right — but RAG is also one of the most misused things around right now, thrown at problems that don't call for it. This post is the honest guide: what RAG really is, when it solves your problem, and when you're building expensive infrastructure for nothing.

What RAG is, without the hype

A language model knows what was in its training data and nothing beyond that. It doesn't know your internal documents, your catalog, your company's policy. And its context is limited — you can't just paste 10,000 pages into the conversation.

RAG (Retrieval-Augmented Generation) solves this by fetching, at question time, the relevant pieces of information and injecting them into the model's context. The flow:

  1. You break your knowledge base into pieces (chunks) and generate embeddings — numerical representations of the meaning of each piece.
  2. You store those vectors in a vector database.
  3. When a question comes in, you turn it into a vector and search for the most semantically similar pieces.
  4. You inject those pieces into the prompt and the model answers based on them.

The result: the LLM answers about your data, up to date, citing the source — without making things up. It's "giving the model the right cheat sheet before the exam."

When RAG actually solves your problem

RAG shines when you have a lot of external knowledge, that changes, and that the model needs to consult:

If your problem is "the AI needs to answer based on a lot of my documents that change," RAG is the tool.

When NOT to use RAG (the part nobody talks about)

Here's the counterpoint that saves months of unnecessary work:

If the information fits in the context, you don't need RAG. Modern models have huge context windows. If your knowledge is a 20-page document, put it in the prompt and be done. RAG for that is using a cannon to kill a fly.

If the answer comes from a system, use function calling, not RAG. "What's the status of my order?" is not a semantic-search question — it's a database query. The right tool is function calling: the agent calls get_order(id) and gets the exact data. RAG would search for "documents similar to the question," which is wrong for structured data.

If you don't have many documents, RAG is over-engineering. Embeddings, a vector database, an ingestion pipeline, reindexing — that's real infrastructure. It only pays off when the volume justifies it.

The filter question: does my answer depend on searching for meaning across many texts, or on looking up a specific piece of data? If it's searching texts, RAG. If it's looking up data, function calling.

The details that decide whether your RAG works

A badly built RAG is worse than no RAG — it brings back the wrong piece with confidence. What separates a RAG that works:

The product view

RAG is not a goal — it's a means, like every AI technology. The mistake I see most is teams building an elaborate RAG pipeline before asking whether the problem calls for it. Often, what solves it is function calling into a system, or simply putting the document in the context. RAG comes in when the knowledge is large, textual, and changing — and then it's powerful.

As always: the right question isn't "which trendy AI technique am I going to use?". It's "what's the problem, and what's the simplest tool that solves it?". Sometimes it's RAG. Often it isn't. Knowing the difference is what separates the people who ship from the people who just follow hype.


I build AI systems that solve the right problem with the right tool — RAG, agents, integration — in production. If you're not sure whether you need RAG, let's talk.

Frequently asked questions

What is RAG (Retrieval-Augmented Generation)?

RAG is a technique where, before answering, the system searches an external knowledge base (documents, FAQs, company data) for relevant information and injects that content into the language model's context. The LLM then answers based on real, up-to-date data instead of just what it 'knows' from training — reducing hallucination and letting you use private knowledge.

What's the difference between RAG and fine-tuning?

Fine-tuning changes the model's weights, teaching it a behavior or style; it's expensive and static. RAG doesn't train anything: it retrieves information on the fly and injects it into the context, so the knowledge base can change at any time without retraining. To answer based on documents that change, RAG is almost always the right choice; fine-tuning is better suited to the style/format of the response.

When should you NOT use RAG?

When the information already fits in the model's context, when the answer doesn't depend on specific external knowledge, or when a simple function call to an API/database does the job better. RAG adds infrastructure (embeddings, a vector database, an ingestion pipeline) — if the problem doesn't require semantic search across many documents, it's over-engineering.

LS
Written by Lucas Silva
I build AI products that ship — from diagnosis to production.
RAGLLMRetrievalVector DatabaseAI EngineeringContext

Got a business problem to solve with AI?

Tell me the problem and I'll hand you a product that actually runs.

Get in touch

Keep reading

Guide

Guardrails: how to stop an AI agent from doing something stupid in production

An LLM hallucinates, obeys whoever manipulates it, and gets things wrong with confidence. The practical guide to the guardrails that separate a safe agent from an accident waiting to happen.

Guide

MCP (Model Context Protocol): what it is and why it matters for AI agents

The no-nonsense guide to the Model Context Protocol: what it solves, when to use it, and why it became the 'USB-C' that connects AI agents to your business tools.