Guides

RAG LLM: ground a model on your data without fine-tuning

Production RAG LLM: an SME method to ground a model on your data, from corpus to citations, with eval and cost under control.

Illustration for: RAG LLM: ground a model on your data without fine-tuning

RAG LLM: grounded answer, not magic memory

A RAG LLM (Retrieval-Augmented Generation) retrieves passages from your documents at question time, then injects them into the model context to generate an answer. The model did not "learn" your PDF into its weights: it reads what the retriever gives it.

You use it when business truth lives outside the model, in your procedures, catalogs, contracts, tickets or wiki. Without retrieval, the LLM politely invents. With bad retrieval, it invents while citing the wrong paragraph.

Before talking about embeddings, look at the process: which question are you handling, where does the source of truth live, what is the risk if the answer is wrong, and who validates the result.

Building blocks of a RAG pipeline

A complete RAG pipeline assembles seven blocks, in this order:

  1. The corpus: allowed sources, with their rights and freshness
  2. Ingestion: parsing, cleaning and metadata (product, date, language, confidentiality)
  3. Chunking: sizes and overlaps that fit the document type
  4. The index: embeddings, optionally completed with full-text or hybrid search
  5. Retrieval: top-k, filters and re-ranking
  6. Generation: a prompt that forces grounding on the provided passages
  7. Post-processing: citations, logs and human review (HITL)

Hybrid search, which combines semantic and keyword matching, often saves exact cases such as SKUs or legal references. A purely vector index misses rare identifiers.

Finally, version the corpus and the index like code, with the ingestion date, the source hashes and the chunking parameters. Without that, you cannot replay an incident.

Quality: measure before adding features

Without an eval set, you optimize on vibes. First build 30 to 100 real questions, with the expected answer or gold passages, then measure:

  • Retrieval recall: does the right chunk land in the top-k?
  • The faithfulness of the answer to the provided passages
  • The rate of correct "I don't know" responses
  • Response time and tokens consumed

Failures fall into a few families: an incomplete corpus, a chunk too big or too small, a bad query, a hallucination despite good context, or an access-rights problem. Each family calls for a different fix, so do not change everything at once.

Clickable citations feed trust and review. If the team never clicks them, the HITL is poorly designed.

Security and access scope

A RAG that indexes the whole Drive without ACLs replays internal leaks, just more politely. So filter by identity and rights at retrieval time, not only in the prompt, and log who saw what.

For personal data, minimize what enters the index, mask what needs masking and set a retention period. A chunk is not harmless just because it is "technical".

When an agent combines tools and RAG, the model can chain a search and then an action. Bound the tools with an allowlist and place human review on the action, not only on the text.

Token cost and latency

Each injected chunk costs input tokens. A top-k too large inflates the bill and the noise, a top-k too small misses passages. Calibrate it on your eval, not on a magic number found on the internet.

Cache embeddings for stable documents. For repeated questions, add an answer cache that you invalidate on every re-ingestion. And measure end-to-end p95 latency, retrieval and generation included.

If cost explodes, start by hunting the noise, such as useless chunks or an overly long chat history, before switching models.

Ship RAG to prod in 30 days

A first RAG fits in four weeks if the scope stays bounded:

  1. Week 1: one flow, a bounded corpus and 30 gold questions
  2. Week 2: the ingestion pipeline, hybrid retrieval and citations
  3. Week 3: the eval and human review on risky cases
  4. Week 4: monitoring (quality, cost, feedback) and controlled corpus growth

Before go-live, check four criteria: acceptable retrieval recall, zero access incidents, a named owner and a re-ingestion runbook. Without that, you have a demo.

To go further, the fine-tuning vs RAG article helps you choose between weights and retrieval, and the LLMOps guide covers evals and observability.

If you want to scope a first RAG LLM on a real corpus, we can do it in 20-40 minutes.

FAQ

What is a RAG LLM?
A RAG LLM is a system that retrieves passages from your data at question time and feeds them to the model for a grounded answer, without retraining it.
RAG or fine-tuning?
RAG suits facts and documents that change. Fine-tuning serves style, format or stable behavior. The two often combine; the detail lives in the fine-tuning vs RAG article.
What chunk size?
There is no universal size. Calibrate it on your eval: a chunk too small cuts meaning, a chunk too large drowns the retriever and burns tokens.
Do we need custom embeddings?
Start with a standard embedding model and hybrid search. Only customize if the eval plateaus after corpus cleanup.
How to reduce hallucinations?
You reduce them with better retrieval, a prompt that forces citing or saying "I don't know", a faithfulness eval and human review on risky cases. Zero hallucination does not exist: you manage a risk.
Who maintains the corpus?
You need a business owner for the content and a tech owner for the pipeline. Without owners, the RAG rots silently.

Sources and references

  1. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks

    Lewis et al., NeurIPS, 2020

    The original paper, the one that gave the method its name. Useful to see what the term meant before it started covering everything.

  2. Retrieval-Augmented Generation for Large Language Models: A Survey

    Gao et al., 2023

    A survey of the variants and the measurement points. Handy to place your own architecture against what exists.

  3. Introducing Contextual Retrieval

    Anthropic, 2024

    A concrete technique against retrieval failures on a corpus split into chunks that lose their context.

Related articles

Scope your first AI agent

20 minutes to review your tools, data and the first useful case. No jargon, no commitment.