What a RAG pipeline is, and where it fails
A RAG pipeline retrieves passages from your own documents and hands them to a language model so the answer is grounded in what you actually wrote, rather than in what the model remembers from training. The name covers two halves: retrieval, which decides what the model gets to read, and generation, which writes the answer from it.
Most failures are retrieval failures. Naive pipelines miss the right passage on a large share of real queries, and the model answers anyway, confidently and wrong. Generation can only ever be as good as what reaches it, so the engineering effort belongs on the retrieval half.
It is also worth saying when a RAG pipeline is the wrong tool. If the material is small, stable and relevant to nearly every question, put it in the prompt and skip the index. Build retrieval when the corpus exceeds the window, changes faster than your deployments, needs citations, or must be filtered by who is asking.
Ingestion and chunking: where accuracy is decided
Everything downstream depends on how documents enter the index. Layout-aware parsing keeps tables, headings and hierarchy intact through PDFs, decks, tickets and wikis, so a row in a pricing table still knows which column it belongs to after it becomes text. Flattening a document to a string is the first and most common way to lose meaning.
Chunking decides the unit of retrieval. Fixed windows of a few hundred characters are easy to implement and slice rules in half. Semantic chunking follows the document's own boundaries, a section, a clause, a table with its caption, and in most corpora it is the single largest lever on retrieval accuracy.
- Parse with layout: headings, tables, lists and footnotes preserved
- Chunk on document structure, not character counts
- Attach metadata to every chunk: source, section, date, owner, permissions
- Plan incremental ingestion from day one, so a changed document is re-indexed rather than the whole corpus
Embeddings and hybrid retrieval
An embedding model turns each chunk into a vector so that semantically similar text sits close together. Dense vector search is good at meaning and poor at exact strings: a part number, an error code or a person's name may not embed near the query that quotes it. Keyword search has the opposite profile.
Hybrid retrieval runs both. Dense search and BM25 run in parallel and their results fuse with reciprocal rank fusion, producing a wide candidate set that catches both the paraphrase and the exact match. The embedding model itself should be chosen per corpus and benchmarked on your own queries rather than taken from a leaderboard, because domain vocabulary changes the ranking.
Storage is a secondary decision. Qdrant, pgvector, Pinecone and Elasticsearch all serve well; what matters is that the store supports metadata filtering at query time, because access control and freshness both depend on it.
Reranking and selection: what the model is allowed to read
A wide candidate set is the right output of search and the wrong input to a model. A cross-encoder reranker scores each candidate against the actual question and orders them by how well they answer it, which is a more expensive comparison than a vector distance and a far better one.
Selection is the step teams skip. Handing over twenty passages because twenty were available spends budget and attention on eighteen that do not help, and irrelevant context does not sit inertly beside relevant context; it competes with it. Take the top few, put the strongest passage nearest the question, and stop.
This is the sense in which retrieval is context management. It is not only a way to get information in front of the model; it is the layer that keeps the rest out.
Grounding and citations by construction
Grounding means the answer is written from the retrieved passages and says so. Every generated claim should carry the passage and source it came from, so a reviewer can check the answer instead of being asked to trust it. This is a design property of the pipeline, not a prompt instruction: the system knows which chunks it selected, and the output format makes the model attribute each claim to one of them.
Grounding also needs an honest failure mode. When retrieval returns nothing relevant, the right answer is to say so, not to let the model fill the gap from memory. For multi-part questions, a planner can decompose the query, retrieve for each part and judge whether it has enough context before answering; it costs more per call, so apply it to the question types that earn it.
Evaluation, and catching drift before users do
Retrieval that worked at launch degrades quietly as documents are added, edited and retired. The difference between a demo and a system is whether anybody finds out before a user does, and that requires numbers rather than impressions.
Build a golden set
Draw question-and-answer pairs from your own corpus and the questions people actually ask. Score retrieval hit rate, faithfulness and answer relevance against it on every index, embedding or prompt change, so a regression in chunking shows up as a number rather than a support ticket.
Track it per release
Recall and groundedness belong in the pipeline the same way tests do. Incremental ingestion and change-data capture keep the index current as source systems move, and the golden set is re-run whenever they do, so freshness and accuracy are measured together.
Access control, and how Supremacy builds RAG pipelines
A RAG pipeline that ignores permissions is a data leak with a search box. Document-level access control has to be enforced at query time against your identity provider, so a user can only ever retrieve what they were already entitled to read in the source system. Filtering after generation is too late; the passage has already shaped the answer.
This is the order Supremacy builds in: layout-aware ingestion, semantic chunking, hybrid search fused with reciprocal rank fusion, a cross-encoder reranker, citations by construction, permission filtering at query time, and an evaluation harness on a golden set drawn from your corpus. Vector stores and embedding models are chosen per corpus and benchmarked on your queries. You get the harness and the numbers, so accuracy is tracked continuously rather than sampled once at launch.
The honest caveat is the one from the first section. If your material fits comfortably in a prompt and rarely changes, we will say so and build the simpler thing, because a retrieval pipeline nobody needed is a maintenance burden bought for nothing.


