Skip to main content

Lesson 12 of 13

Module 9 Practice

Practice the RAG concepts with a structured exercise.

15 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Practice: Design a RAG System

Practice: Design a RAG System
# Practice: Design a RAG system for a specific use case

def design_rag_system(use_case):
    """
    Design a RAG system for a specific use case.
    Fill in each section for your chosen use case.
    """
    print(f"=== RAG System Design for: {use_case['name']} ===")
    print()

    sections = [
        ("Documents to index", use_case["documents"]),
        ("Chunk size recommendation", use_case["chunk_size"]),
        ("Number of chunks to retrieve", use_case["top_k"]),
        ("System prompt instruction", use_case["system_prompt"]),
        ("Example user question", use_case["example_question"]),
        ("Expected answer grounding", use_case["expected_grounding"]),
    ]

    for section_name, content in sections:
        print(f"{section_name}:")
        if isinstance(content, list):
            for item in content:
                print(f"  - {item}")
        else:
            print(f"  {content}")
        print()

# Example RAG system design
customer_support_rag = {
    "name": "E-commerce Customer Support RAG",
    "documents": [
        "Product catalog with descriptions, specifications, and pricing",
        "Return and refund policy",
        "Shipping and delivery information",
        "Frequently asked questions document",
        "Warranty information",
    ],
    "chunk_size": "300-400 words per chunk (captures complete policy sections)",
    "top_k": "3-5 chunks (enough context without noise)",
    "system_prompt": "You are a customer support agent. Answer questions based only on the provided product and policy information. If you do not find the answer in the context, tell the customer to contact support directly. Never make up pricing or policy details.",
    "example_question": "Can I return a product I bought 45 days ago?",
    "expected_grounding": "Return policy document chunk about return window",
}

design_rag_system(customer_support_rag)
Diagram
Loading diagram…

Practice Diagram

Key Takeaways from Module 9

  • RAG (Retrieval-Augmented Generation) connects AI to your specific documents so it can answer questions about them accurately
  • It solves the problem of AI knowledge cutoff, hallucinations, and lack of access to private data
  • RAG works in three main steps: retrieve relevant chunks, augment the prompt with context, generate a grounded answer
  • Embeddings are lists of numbers that represent the meaning of text, enabling semantic search
  • Vector search finds documents similar in meaning to the user's question, not just keyword matches
  • RAG is widely used for customer support, internal knowledge bases, legal review, and research tools
  • For production, use dedicated vector databases like ChromaDB, Pinecone, or Weaviate

Key Takeaways

  • Practice the RAG concepts with a structured exercise.
  • RAG (Retrieval-Augmented Generation) connects AI to your specific documents so it can answer questions about them accurately
  • It solves the problem of AI knowledge cutoff, hallucinations, and lack of access to private data
  • RAG works in three main steps: retrieve relevant chunks, augment the prompt with context, generate a grounded answer

Finished this lesson?

0 of 13 in Module 9
Sign in to save progress

Topics in This Module

0/13 done