Retrieval-Augmented Generation (RAG) retrieves evidence from a corpus and gives it to the model for generation. Knowledge can then change without retraining the model, and the answer can point back to the source that supported it.

A useful RAG system is a pipeline. Query processing determines what search sees. Retrieval decides which evidence survives. Context assembly decides what the model receives. Evaluation and production controls keep those stages honest.

For a support question such as “What changed in API v2 rate limits?”, the system retrieves release notes and policy documents first. The model answers from those sections and cites them instead of relying on an old fact stored in its weights.

Core Flow

flowchart LR
    Q[User Query] --> D{Translate query?}
    D -->|No| R[Retrieval and Fusion]
    D -->|Yes| T[Query Translation]
    T --> R
    R --> RR[Optional Reranking]
    RR --> C[Context Assembly]
    C --> G[LLM Generation]
    G --> V[Groundedness and Citation Checks]

Each stage limits the next. When translation is used, retrieval cannot repair a rewrite that changed the intent, and reranking cannot promote evidence that search never returned. A baseline can send the original query directly to retrieval. Treating RAG as one large prompt hides these boundaries.

Operational Baselines

  • Each added pattern sits behind a feature flag, so its retrieval precision and generation faithfulness can be compared with latency p95 and cost per query.
  • Iterative and agentic retrieval run under a cap. A retry budget bounds latency. Unsupported output should fail closed instead of looping until it sounds plausible.
  • Query drift can accumulate between retrieval rounds. Semantic similarity to the original query makes gradual topic changes visible.
  • Expensive stable work is worth caching: query rewrites, multi-query results, contextual chunk enrichment, and read-only tool results scoped to the caller’s authorization. Mutating tool calls need idempotency, not response caching. Caching covers keys and invalidation.
  • Simple questions go through the cheapest path. Multi-hop retrieval is wasted work on a single-hop lookup.

RAG Vs Fine-Tuning

RAG and Fine-tuning change different parts of the system. RAG supplies knowledge at request time. Fine-tuning changes behavior in the model weights. Retrieval is the safer place for facts that change.

A weekly policy change can enter RAG through reindexing. Fine-tuning would bake in another snapshot and still give weak source traceability.

AxisRAGFine-tuning
Knowledge freshnessChanges when the corpus is reindexedChanges when the model is trained again
Source traceabilityDirect when citations are retainedWeak unless supplied separately
Behavioral consistencyDepends on prompt and model behaviorCan improve through training examples
Time to first valueUsually fasterUsually slower
Operational complexityRetrieval and index operationsTraining, evaluation, and model release operations
  1. RAG is the first choice when facts change often or answers need citations.
  2. Fine-tuning is added when format or policy behavior stays unstable after prompt work.
  3. Mutable facts stay in the corpus, and learned behavior stays in the weights.

The two techniques can work together. Fine-tuning can stabilize format or refusal behavior, while RAG supplies current facts. The boundary still holds: knowledge changes through reindexing, and behavior changes through retraining.

Questions

References

9 items under this folder.