On-Prem AIGlossary

What Is RAG (Retrieval-Augmented Generation)?

Also known as: Retrieval-Augmented Generation, Retrieval Augmentation

Definition

RAG (Retrieval-Augmented Generation) is an architecture that searches your own document store for passages relevant to a question, inserts them into the LLM prompt, and instructs the model to answer only from that retrieved evidence.

RAG (Retrieval-Augmented Generation) Explained

A RAG pipeline has two halves. The offline half ingests source documents, splits them into chunks of a few hundred tokens, converts each chunk into an embedding vector, and stores the vectors alongside their text and metadata in a vector database. The online half embeds the incoming question with the same model, retrieves the nearest chunks by vector similarity, assembles them into a prompt with an instruction to answer only from the supplied context, and returns the generated answer with source citations attached.

Retrieval quality, not model quality, determines whether a RAG system works. If the right passage is not in the retrieved set, no model can produce a correct answer. Production systems therefore rarely use pure vector search. Hybrid retrieval combines dense vector similarity with keyword search such as BM25, because exact identifiers like part numbers, order numbers, and error codes are precisely what embeddings handle worst. A reranking model then reorders the candidate set before the top few chunks reach the prompt.

Chunking strategy carries more weight than teams expect. Chunks that are too small lose the surrounding context needed to interpret them. Chunks that are too large dilute the embedding and waste context window. Respecting document structure, splitting on headings, table boundaries, or work-instruction steps rather than fixed character counts, usually beats any amount of parameter tuning. Overlapping chunks by ten to twenty percent prevents an answer from being cut in half at a boundary.

RAG is the default enterprise pattern because it solves problems fine-tuning does not. Documents change daily and reindexing takes minutes, whereas retraining takes days. Access control can be enforced at retrieval time by filtering on user permissions, so a shop-floor operator and a controller see different evidence from the same system. And every answer carries citations a person can open and verify, which is usually a hard requirement in regulated and audited environments.

Why It Matters

  • Grounds answers in your current ERP data, drawings, and procedures, which is the single most effective control against hallucinated output.
  • Updates instantly when a document changes, avoiding the retraining cycle that a fine-tuned knowledge base would require.
  • Enforces row-level and document-level permissions at retrieval time so users only ever see evidence they are cleared to read.
  • Produces citations that auditors, quality engineers, and regulators can trace back to a controlled source document.

In Practice

A classic failure: users ask "what is the lead time on part 44-7192" and retrieval returns nothing useful, because the embedding of a part number carries almost no semantic signal. The fix is hybrid search. Run a keyword or exact-match query in parallel with the vector query and merge the results before reranking.

Frequently Asked Questions

Is RAG better than fine-tuning?

They solve different problems and are often combined. RAG supplies facts the model does not know and keeps them current, which is what most enterprise knowledge use cases need. Fine-tuning changes behavior: output format, tone, domain vocabulary, and task-specific accuracy. If your issue is that the model lacks your data, use RAG. If it has the data but formats answers wrong, fine-tune.

Does RAG eliminate hallucinations?

It reduces them substantially but does not eliminate them. A model can still misread a retrieved passage, blend two chunks incorrectly, or answer from pretraining memory when retrieval returns nothing relevant. Effective mitigations include instructing the model to say it does not know when evidence is missing, requiring inline citations, and running an automated check that every claim traces to a retrieved chunk.

Working with RAG (Retrieval-Augmented Generation) in a live environment? Our engineers do this every day - and our AI agents automate most of it.