Concept — Vespa Unified Tensor Type System (Indexed, Mapped, and Mixed)

Vespa defines a single first-class tensor type grammar tensor<cell-type>(dimensions...) shared identically across schema declarations (schemas/*.sd), the Java container (vespa/vespajlib), the C++ ranking engine (vespa/eval), and Python client builders (pyvespa).

Dimension Kinds & Cell Types

  1. Indexed (Dense) Dimensions — x[N]:
    • Bound integer coordinates stored contiguously in row-major memory for SIMD-accelerated dot products and matrix multiplications (e.g., tensor<float>(x[384])).
  2. Mapped (Sparse) Dimensions — cat{}:
    • Arbitrary string labels mapped via hash tables, generalizing weighted sets and sparse lexical vectors (e.g., tensor<bfloat16>(token{})).
  3. Mixed Tensors — tensor<int8>(patch{}, x[16]):
    • Combine sparse outer dimensions (token{} or patch{}) with dense inner subspaces (x[128]), enabling multi-vector ColBERT MaxSim and ColPali visual-document scoring without custom plugins.
  4. Precision Tiers:
    • Supports double (64-bit), float (32-bit), bfloat16 (16-bit brain float), and int8 (8-bit scalar or binary-packed hamming vectors).

Functional Tensor Algebra

Every ranking expression reduces to six primitive functional operators in vespa/eval/src/vespa/eval/eval/tensor_function.h:

  • reduce(t, aggr, dims...), map(t, f(x)), join(t1, t2, f(x,y)), merge(t1, t2, f(x,y)), rename(t, from, to), and concat(t1, t2, dim).
  • Higher-level expressions (sum, matmul, cosine_similarity, hamming, l2_normalize) lower deterministically onto these primitives (see bridge-java-cpp-tensor-serialization and search-ranking).