Skip to content
AI Glossary

Retrieval-Augmented Generation (RAG)

A technique that retrieves relevant passages from your own documents and gives them to an LLM, so answers are grounded in your data rather than the model's memory.

Definition

Retrieval-augmented generation combines a search step with a generation step. When a user asks a question, the system first retrieves the most relevant passages from a prepared index of your documents. It then places those passages in the prompt alongside the question and asks the LLM to answer using only that material.

The index is built in advance: documents are split into chunks, each chunk is turned into an embedding, and the embeddings are stored in a vector database. At query time the question is embedded the same way and the nearest chunks are returned. Many production systems add keyword search and reranking to improve what reaches the model.

Example: an HR assistant is asked "how many days of parental leave do I get in Sweden?". RAG pulls the Swedish leave policy section from the handbook, passes it to the model, and the answer cites that section. If the policy changes, you update the document, not the model.

RAG pipeline: documents are chunked, embedded and indexed; a question is embedded, matched against the index, and the retrieved passages are given to the LLM with the question INGEST (in advance) Documents Chunk + embed Vector index QUERY (each request) Question Embed Retrieve top-knearest chunks LLM question + passages → answer with citations
RAG has two halves: an ingestion pipeline that runs when documents change, and a query pipeline that runs on every request.

Why it matters for your business

  • Answers come from your current documents, with sources, instead of from a model's training snapshot.
  • Updating knowledge means re-indexing a file, not retraining anything.
  • Access control can be enforced at retrieval time, so people only get answers from documents they may see.
  • Retrieval quality, not the model, is usually the limiting factor. Chunking, search and evaluation deserve most of the effort.

How Teksmobile uses it

RAG is the foundation of our AI knowledge base and enterprise RAG services, where we design ingestion, retrieval and evaluation as one system. Where documents are sensitive, our secure RAG architecture work adds permission-aware retrieval and prompt-injection controls.

Part of the Teksmobile AI Glossary. Read the full guide: RAG explained.

FAQ

Frequently asked questions

Does RAG stop hallucinations completely?

No. It reduces them sharply because the model answers from supplied text, but the model can still misread a passage or fill a gap. Citations, evals and a clear "I don't know" path are still needed.

Is RAG better than fine-tuning?

For knowledge that changes (policies, prices, product docs) RAG is almost always the right choice, because you update documents rather than retrain a model. Fine-tuning is for style and format. See our guide on prompt engineering vs fine-tuning.

How long does a RAG pilot take?

A focused pilot on one document set usually takes four to eight weeks, including ingestion, evaluation and a working interface. Production hardening, security and integration add to that.

Ready to make AI work in production?

Tell us about your systems, your data and your constraints. We reply within one business day with a straight answer and a suggested next step.