- [+] expand all

- GETTING STARTED
- Introduction
- Vespa Overview
- Getting Started
- Quick Start
- Vespa CLI
- Vespa API and Interfaces
- Use case: Shopping
- Use case: Question-Answering

- DOCUMENTS AND SCHEMAS
- Documents
- Schemas
- Parent/Child
- Annotations API

- READS AND WRITES
- Reads and Writes
- /document/v1
- Visiting
- Vespa Feed Client
- Feed using Hadoop, Pig, Oozie
- Indexing
- Document API
- Document Processing

- QUERIES
- Query API
- Vespa Query Language
- Grouping Information in Results
- Federation
- Query Profiles
- Geo Search
- Predicate Fields
- Streaming Search

- RANKING AND ML MODELS
- Ranking Introduction
- Rank Features and Expressions
- Multivalue Query Operators
- Tensor User Guide
- Phased Ranking
- Ranking With TensorFlow Models
- Ranking With ONNX Models
- Ranking With XGBoost Models
- Ranking With LightGBM Models
- Stateless model evaluation
- Text Ranking
- Ranking With BM25
- Ranking With nativeRank

- LINGUISTICS AND TEXT PROCESSING
- Linguistics in Vespa
- Query Rewriting
- Embedding text

- DEVELOPING APPLICATIONS AND PLUGINS
- Developer Guide
- Application Packages
- Application Testing
- Java Serving Container
- Container Components
- Container Component Types
- Request-Response Processing
- Searcher Development
- Document Processor Development
- Developing Web Service Applications
- Component Injection
- Chained Components
- Building OSGi Bundles
- OSGi Bundle Maven Plugin
- Versioning in the Container
- Using ZooKeeper

- CONFIGURATION
- Configuration Intro
- Deploy API
- HTTP Config API
- Config API
- Developing Config Model Plugins

- RESULT FORMATS
- Document Summaries
- Search Result Renderers
- Page Templates

- THE CONTENT LAYER
- Elastic Vespa
- Proton
- Content Nodes and States
- Consistency Model
- Distribution Algorithm
- Buckets
- State API

- PERFORMANCE AND TUNING
- Serving Sizing Guide
- Feed Sizing Guide
- Sizing Examples
- Document Attributes
- Benchmarking
- Profiling the Search Container
- Container Tuning
- Rate-Limiting Search Requests
- HTTP/2

- OPERATIONS AND PROCEDURES
- Live Vespa upgrade procedure
- Administrative Procedures
- Vespa Command-line Tools
- Vespa Metrics
- Log Files
- Files, Processes and Ports
- Inspecting Vespa Java Services
- Docker Containers in Production
- Securing a Vespa installation

- CONFIGURATION REFERENCE
- Application Package Reference
- Schema Reference
- Services Configuration (services.xml)
- Indexing Language
- Custom Configuration File Reference

- RANKING REFERENCE
- Ranking Expressions
- Tensor Evaluation Reference
- nativeRank Reference
- Rank Feature Reference
- String Segment Match
- Rank Feature Configuration
- Rank Types
- Stateless Model Reference

- QUERIES AND RESULTS REFERENCE
- Query API Reference
- Query Language Reference
- Simple Query Language Reference
- Select Reference
- Grouping Reference
- Sorting Reference
- Query Profile Reference
- Semantic Rule Language Reference
- Default JSON Result Format
- Page Templates Syntax

- DOCUMENT FORMAT AND LANGUAGES REFERENCE
- Document JSON Format
- Document Field Path Syntax
- Document Selector Language

- ABOUT THIS SITE
- Documentation Conventions
- Contributing to Vespa

A tensor is a set of named *dimensions* defining its *order*
and a set of values located in the space of those dimensions:

*Cell*: A value located in the dimension space. Consists of a cell address and the value at that address.*Address*: A set of key-values where each key is a*dimension*from the set of dimensions of the tensor, and each value is a*label*(integer or string) determining the cells location in that dimension.

`[0,N>`

(like an array), where N is the size of the dimension.
Contained in `constant`

or `tensor field type`

.
The dimensions of a tensor and the cell type defines its type.
A tensor type contains a list of dimensions on the format:

tensor<value-type>(dimension-1,dimension-2,...,dimension-N)The value-type is one of:

float | 32-bit IEEE 754 floating point |

double | 64-bit IEEE 754 floating point |

int8 | signed 8-bit integer - see performance considerations |

bfloat16 | first 16 bits of 32-bit IEEE 754 floating point - see performance considerations |

`dimension-name{}`

- a mapped dimension`dimension-name[size]`

- an indexed dimension

tensor<float>(x{},y{})Example tensor with this type:

{{x:a,y:b}:10.0, {x:c,y:d}:20.1}The tensor type for a tensor<float> with two indexed dimensions

tensor<float>(x[3],y[2])Example tensor with this type (representing a matrix):

{{x:0,y:0}:1, {x:0,y:1}:2.1, {x:1,y:0}:3, {x:1,y:1}:5, {x:2,y:0}:7, {x:2,y:1}:11}Note that the labels are indexes in the range

A tensor<double> with both mapped and indexed dimensions is *mixed*:

tensor<double>(key{},x[2])Example:

{{key:a,x:0}:10, {key:b,x:0}:2.7, {key:a,x:1}:5.3, {key:b,x:1}:-7 }

The tensor literal form is used in:

- Tensors in queries, see defining query feature types
- Constant tensors in stateless model evaluation
- Building tensors using the Java Tensor API

The general literal form can represent any tensor and is as follows (EBNF):

literal tensor = ( tensor-type-spec ":" )? "{" cells "}" ; cells = | cell , { "," cell } ; cell = "{" address "}:" scalar ; address = | element, { "," element } ; element = dimension ":" label ; dimension = integer | identifier ; label = integer | identifier | 'string' | "string" ; identifier = ["A"-"Z","a"-"z","0"-"9","_","@"](["A"-"Z","a"-"z","0"-"9","_","@","$"])*If no type spec is included the type is inferred from cells.

An empty tensor:

{}A single value tensor with a single mapped dimension

{ {x:foo}:5.0 }A tensor with multiple values and mapped dimensions

{ {x:foo, y:bar}:5.0, {x:foo, y:baz}:7.0 }A tensor where type is specified explicitly with a single indexed dimension

tensor<float>(x[3]):{ {x:0}:3.0, {x:1}:5.0, {x:2}:7.0 }A tensor with a type using the default value type (double) and quoted labels:

tensor(key{}):{ {key:'key.1'}:3.0, {key:'key 2'}:5.0, {key:"key's"}:7.0 }

Tensors where all dimensions are indexed can be written as numbers wrapped in square brackets in
*right dimension adjacent* order. This form requires an explicit tensor type.

Brackets must either be nested according to the structure of the type, where values in dimensions to the right are closer than dimensions on the left, or alternatively all values may be given (in the same order) as a flat array (the latter not supported in expressions).

A float 1d tensor in indexed form:

tensor<float>(x[3]):[3.0, 5.0, 7.0]A matrix in indexed form. Since the values for the right-most dimension (y) are adjacent, the value 3 is here assigned to the cell {x:0,y:2}:

tensor<float>(x[2],y[3]):[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]The dimension order here is given by the order in which the dimensions are specified, not in the natural (alphabetic) order inherent in the tensor type. Since inner brackets can be omitted, the above is equivalent to

tensor<float>(x[2],y[3]):[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]

Tensors with a single mapped dimension can be written by specifying just the label in that implicit dimension instead of a full address map. This form requires a type to be specified.

tensor<float>(key{}):{ key1:1.0, key2:2.0 }

Tensors with a single mapped dimension and one or more indexed dimensions can be written by specifying the mapped dimension in the map short form and the values of each dense subspace on the indexed short form. This form requires a type to be specified.

A map of matrixes:

tensor<float>(key{},x[2],y[3]):{ key1:[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], key2:[[1.1, 2.1, 3.1], [4.1, 5.1, 6.1]] }

The following rank features can be used to refer to or create tensors in ranking expressions. The tensors can come from the document, the query or a constant in the application package:

Use the following reference documentation on how use tensors in documents: