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