Domain Guide — Vector Search, Hybrid Retrieval, and RAG
Vespa natively combines lexical retrieval (BM25 / WAND), approximate nearest-neighbor (HNSW) vector
search, structured metadata filtering, and in-cluster model inference for Retrieval-Augmented
Generation (RAG).
Core AI and Vector Capabilities
- HNSW Vector Indexing (
vespa/searchlib):- Tensor attribute fields with
index { hnsw { max-links-per-node: 16 neighbors-to-explore-at-insert: 200 } }
maintain a real-time HNSW graph insideproton(vespa/searchlib/src/vespa/searchlib/tensor/). - Queries combine exact pre-filtering with
nearestNeighbor(embedding, q_vec)in a single pass
(see querying-yql).
- Tensor attribute fields with
- In-Container Embedders and Inference (
vespa/container-onnxruntime,vespa/container-llama):- Stateless container components in container-jdisc convert raw text into dense/sparse tensors
during both feeding (indexing: input text | embed | attribute | index) and querying (embed(q)). - Cross-encoders and GBDT/ONNX models execute during second-phase or global-phase ranking
(see search-ranking).
- Stateless container components in container-jdisc convert raw text into dense/sparse tensors
- Hybrid Fusion and ColBERT / Multi-Vector Tensors (
vespa/eval):- Mixed tensors (
tensor<float>(token{}, x[128])ortensor<int8>(token{}, x[16])) enable
late-interaction MaxSim scoring (reduce(sum(q * d, x), max, token)) directly in C++ tensor
expressions, backed by utility-libs (vespajlibandvespalib).
- Mixed tensors (
- Python and Agent Workflows (
pyvespa/):pyvespa(covered in work-areas) provides declarative schema/ranking builders and evaluation
harnesses for hybrid RAG pipelines.