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

  1. 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 inside proton (vespa/searchlib/src/vespa/searchlib/tensor/).
    • Queries combine exact pre-filtering with nearestNeighbor(embedding, q_vec) in a single pass
      (see querying-yql).
  2. 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).
  3. Hybrid Fusion and ColBERT / Multi-Vector Tensors (vespa/eval):
    • Mixed tensors (tensor<float>(token{}, x[128]) or tensor<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 (vespajlib and vespalib).
  4. Python and Agent Workflows (pyvespa/):
    • pyvespa (covered in work-areas) provides declarative schema/ranking builders and evaluation
      harnesses for hybrid RAG pipelines.