Beginner path
- Read the definition of RAG.
- Study the pipeline from documents to citations.
- Learn the difference between RAG, fine-tuning, and long context.
- Use the glossary whenever a term is unfamiliar.
Learn RAG
Understand why RAG emerged, how it differs from fine-tuning and long-context models, and how modern RAG systems are designed.
Retrieval-Augmented Generation connects a language model to external knowledge sources. The retriever finds relevant evidence, and the model uses that evidence to answer with better grounding, accuracy, traceability, and domain relevance.
RAG emerged because model weights cannot reliably contain every private, current, or specialized fact. Retrieval lets knowledge be updated independently from the model.
RAG is generally suitable when information changes or must be cited. Fine-tuning is generally suitable for behavior, tone, formatting, or domain patterns rather than constantly changing facts.
Long context can hold more material, but retrieval still helps select relevant evidence, reduce cost, improve traceability, and manage very large collections.
Naive RAG retrieves chunks directly. Advanced RAG adds query rewriting, hybrid search, reranking, and evaluation. Modular RAG separates components. Graph, agentic, and multimodal RAG add relationships, tool use, and multiple content types.
Important concepts include chunking, embeddings, vector databases, hybrid search, metadata, reranking, query rewriting, retrieval evaluation, hallucination control, and citations.
A RAG system is only as good as the knowledge it can retrieve. Good knowledge-base design defines source authority, metadata, ownership, update cadence, permissions, document structure, and deprecation rules before indexing starts.
Retrieval quality depends on chunking, embeddings, keyword coverage, metadata filters, reranking, and query transformation. Inspect failed questions directly; dashboards alone rarely explain why a source was missed.
Citations should help users verify claims, not merely decorate answers. Strong systems preserve source IDs, page numbers, section titles, timestamps, permissions, and snippets throughout the pipeline.
RAG systems must handle access control, prompt injection, sensitive data, logging, retention, source licensing, and human escalation. Retrieved text should be treated as untrusted content that cannot override system policy.
Production RAG requires monitoring, test sets, trace review, feedback loops, source refresh workflows, incident handling, and clear ownership. A prototype can answer questions; a production system must be maintained.
RAG improves grounding and updateability, but it can still fail through bad ingestion, weak retrieval, stale sources, prompt injection, poor evaluation, or unsupported generation.
Common mistakes include chunking everything the same way, ignoring metadata, skipping evaluation, trusting top-k retrieval blindly, failing to manage permissions, and not showing sources to users.
Start with a narrow use case, curate sources, keep metadata, evaluate retrieval and answers separately, use reranking for noisy corpora, add citations, monitor failures, and define human escalation.
A university policy assistant receives the question: 'Can graduate students borrow interlibrary loan books?' The retriever searches approved library policy pages, finds the relevant borrowing rule, and passes that passage to the model. The answer cites the policy page instead of relying on model memory.
RAG is not a cure for every AI problem. If the task is pure classification, style transfer, translation, or extraction from a single provided document, retrieval may add unnecessary complexity.
The best first RAG project is narrow, source-rich, and easy to evaluate: an internal policy assistant, course-material Q&A bot, support documentation assistant, or research-paper explorer.
These approaches solve different problems and can be combined. Choose according to the knowledge, behavior, traceability, and maintenance requirements of the task.
| Strategy | Choose when | Do not rely on it when | How it combines |
|---|---|---|---|
| Prompting | The model already has the needed knowledge and the main problem is instructions, format, tone, or reasoning scaffolding. | Answers require private, rapidly changing, or citable sources. | RAG prompts still define source use, uncertainty, answer format, and citations. |
| Long context | The relevant material is already known, fits comfortably, and must be considered together. | The corpus is much larger than the context window, changes frequently, or contains substantial irrelevant material. | Use retrieval to select a compact evidence set, then use long context for cross-document synthesis. |
| RAG | Knowledge is external, private, changing, too large for a single prompt, or must be traced to sources. | The task needs no external knowledge or retrieval cannot access an authoritative corpus. | Use prompting for behavior and fine-tuning for stable task patterns where justified. |
| Fine-tuning | The goal is stable behavior, style, output structure, domain language, or learned task patterns. | The main requirement is updating factual knowledge or producing verifiable citations. | A fine-tuned model can still retrieve current evidence through RAG. |
There is no universally correct chunk size. Treat chunking as a retrieval design decision and evaluate it on representative questions from the target corpus.
“The model hallucinated” is often too vague to be actionable. Diagnose the full chain, starting with whether the right source was available at all.
Failure: The authoritative answer is absent, stale, duplicated, contradictory, or inaccessible.
Inspect: Inspect corpus coverage, ownership, dates, permissions, and superseded documents.
Improve: Curate sources before changing models or retrieval settings.
Failure: The answer exists but tables, headings, pages, or relationships were damaged during ingestion.
Inspect: Compare parsed chunks with the original document visually.
Improve: Use format-aware parsing, structure-aware chunks, and preserved provenance.
Failure: Relevant evidence is not returned or is buried under irrelevant passages.
Inspect: Evaluate expected-source recall and relevance of each top result.
Improve: Tune chunking, hybrid search, metadata filters, query rewriting, and reranking.
Failure: Good evidence is truncated, duplicated, ordered poorly, or mixed with conflicting sources.
Inspect: Log the exact context sent to the model.
Improve: Deduplicate, prioritize authority and freshness, compress carefully, and expose conflicts.
Failure: The model ignores, misreads, overgeneralizes, or invents beyond the supplied evidence.
Inspect: Break the answer into claims and map each claim to supporting context.
Improve: Improve instructions, require claim support, reduce noise, or use a better-suited model.
Failure: The answer may be supported, but users cannot verify which source supports which claim.
Inspect: Test citation correctness, granularity, links, page numbers, and source snippets.
Improve: Preserve provenance end to end and design citations as a verification workflow.
On this page
Trusted starting sources