Definition
In RAG pipelines and AI agents, space complexity refers to the memory and storage footprint required to persist high-dimensional vector embeddings, navigate hierarchical indices (like HNSW), and maintain the KV cache during LLM inference. It represents the primary bottleneck for scaling knowledge bases and managing long-context agent reasoning cycles.
Focuses on VRAM for model weights/cache and disk/RAM for vector databases, rather than just algorithmic temporary variables.
"A physical library warehouse: the space complexity is determined by the total number of books (data), the number of shelves (embeddings), and the size of the reading desk required to hold open chapters during a search (KV cache)."
- Vector Dimensionality(Prerequisite)
- Quantization(Optimization Technique)
- KV Cache(Component)
- HNSW (Hierarchical Navigable Small World)(Component)
Conceptual Overview
In RAG pipelines and AI agents, space complexity refers to the memory and storage footprint required to persist high-dimensional vector embeddings, navigate hierarchical indices (like HNSW), and maintain the KV cache during LLM inference. It represents the primary bottleneck for scaling knowledge bases and managing long-context agent reasoning cycles.
Disambiguation
Focuses on VRAM for model weights/cache and disk/RAM for vector databases, rather than just algorithmic temporary variables.
Visual Analog
A physical library warehouse: the space complexity is determined by the total number of books (data), the number of shelves (embeddings), and the size of the reading desk required to hold open chapters during a search (KV cache).