AI Model Wiki

    Skip to main content
    8 min read
    Lesson 5 of 5

    Production RAG: Evaluation, Monitoring, and Scaling

    From the course RAG & Knowledge Bases: Ground AI in Your Data

    Moving RAG from prototype to production requires evaluation frameworks, monitoring, cost management, and architectural decisions for scale.

    Evaluation Framework

    RAGAS (RAG Assessment) is the most popular framework for evaluating RAG systems. It measures:

    • Faithfulness — Does the answer stick to the retrieved context? (No hallucination)
    • Answer relevancy — Does the answer address the user's question?
    • Context precision — Are the retrieved chunks relevant to the question?
    • Context recall — Were all necessary chunks retrieved?

    Run RAGAS on your evaluation dataset after every pipeline change.

    LLM-as-Judge Use a powerful model (GPT-5, Claude) to evaluate your RAG system's outputs:

    • Rate answers on a 1-5 scale for accuracy, completeness, and helpfulness
    • Compare answers against ground truth
    • Flag potential hallucinations

    Monitoring in Production

    Track these metrics continuously:

    System metrics:

    • Query latency (p50, p95, p99)
    • Embedding API response times
    • Vector database query times
    • LLM generation times
    • Error rates by component

    Quality metrics:

    • User satisfaction (thumbs up/down)
    • Retrieval relevance scores
    • Answer confidence scores
    • Hallucination detection rates
    • Fallback rate (how often does the system say "I don't know"?)

    Cost metrics:

    • Embedding API costs per query
    • LLM token usage per query
    • Vector database storage and query costs
    • Total cost per answer

    Scaling Strategies

    Caching:

    • Cache embedding vectors for frequent queries
    • Cache LLM responses for identical questions
    • Use semantic caching — serve cached answers for semantically similar queries

    Tiered Retrieval:

    1. Check cache first
    2. If miss, do fast keyword search
    3. If insufficient, do full vector search
    4. If still insufficient, expand to broader document set

    Batch Processing:

    • Pre-compute answers for FAQ and common questions
    • Run nightly re-indexing for updated documents
    • Generate weekly summaries for frequently accessed topics

    Architecture Patterns

    Multi-Index RAG: Maintain separate indexes for different document types (policies, technical docs, product info). Route queries to the appropriate index based on intent classification.

    Conversational RAG: Maintain conversation history and reformulate queries based on context:

    • User: "What's the refund policy?"
    • System: retrieves and answers
    • User: "What about for enterprise clients?"
    • System: reformulates as "What is the refund policy for enterprise clients?" and retrieves again

    Agentic RAG: Give the RAG system agency to:

    • Decide which indexes to search
    • Determine if it needs more context
    • Ask clarifying questions
    • Combine information from multiple sources
    • Trigger follow-up actions (create ticket, update docs)

    Common Production Pitfalls

    • Stale data — Documents change but embeddings aren't updated. Set up automated re-indexing.
    • Context window overflow — Too many retrieved chunks exceed the LLM's context. Prioritize and truncate.
    • Embedding model drift — If you change embedding models, you must re-embed all documents.
    • Over-reliance on similarity — High similarity ≠ correct answer. Validate with re-ranking.
    • No fallback — System should gracefully handle queries outside its knowledge scope.

    Key Takeaways

    • •Use RAGAS to evaluate faithfulness, relevancy, precision, and recall
    • •Monitor latency, quality, and costs continuously in production
    • •Implement caching (semantic and exact) to reduce costs and latency
    • •Use multi-index and conversational patterns for complex use cases
    • •Automate re-indexing and set up fallbacks for queries outside scope
    0 of 5 lessons marked complete

    Progress is kept in this browser only.