Preprocessing paid once, amortized over all queries
KB size
Large and elastic
Bounded by the context window / cache budget
Freshness
Update one doc, re-embed that doc
Recompute and reload the whole cache
Python RAG Sample
# Sample knowledge base (documents)KNOWLEDGE_BASE = [ "Python is a high-level programming ...", "Python supports multiple programming ...", "Pandas is a fast, powerful, flexible ...", "NumPy is a Python library used for ...", "Machine learning is a subset of artificial..."]class SimpleRAG: def __init__(self, knowledge_base: List[str]): self.knowledge_base = knowledge_base # (...)