Skip to main content

Vector

vector holds an embedding, a list of numbers with a fixed number of dimensions.

ValueExample
list of exactly dimensions numbers[0.12, -0.5, 0.33]

Settings

SettingMeaning
dimensionsRequired, except for embeddings. The number of dimensions, a positive whole number.
elementTypefloat (default), byte (whole numbers from -128 to 127) or bit (8 dimensions per number, dimensions has to be a multiple of 8).
similaritycosine (default), dot_product, l2_norm or max_inner_product. bit vectors only use l2_norm.
embeddingOptional, top level properties only. Lets the API calculate the vector from a text, see embeddings.
visibilityhidden (default) or public. Hidden vectors are stored and searchable but not part of element responses, see visibility. The normalized definition always states it.

Values are lists of numbers with exactly dimensions entries. Vectors of the type bit store 8 dimensions in every integer (-128 to 127), so values have dimensions / 8 entries. A vector can be required like every property, but it can not be the items of a list. The index is described in vector indices, searching by vector similarity in the vector search example.

Embeddings

With embedding, the vector is calculated by the API instead of being written by clients:

SettingMeaning
providerRequired. The name of an embedding provider of the configuration.
sourceRequired. An Expr Lang expression which returns the text of the vector.
  • dimensions is taken from the provider and stored in the normalized definition, so the index always matches the vectors of the provider. It can be stated, but has to be the number of the provider. elementType is always float.
  • The source only sees the element itself: elementType, the node label or relation type, and document, the properties of the element like in rules, without internal properties and without the vectors of embeddings. A string is the text of the vector; null and empty strings mean that the element has no text.
  • Requests can not write the vector, 400 Bad Request names the provider. PUT keeps it.
  • When an element is written, its text is compared with the text before the write. A new or changed text announces the element to the background job cron:calculate-embeddings, which runs every 5 minutes, sends the texts to the provider and writes the vectors. Until then the previous vector stays, new elements have none. No text removes the vector right away.
  • Writing the vector changes updatedAt, but not updatedBy.
  • If the source fails or returns something else than a string or null, or the provider fails, the error is logged and the vector is not changed. A missing vector is calculated again on the next write of the element.
  • Changing the source of a schema does not calculate the vectors of existing elements again.
{
"type": "vector",
"embedding": {
"provider": "openai",
"source": "document.title != nil && document.description != nil ? document.title + \": \" + document.description : nil"
},
"index": "vector"
}

Storage

DatabaseStored asNotes
MongoDBarray of numbers(default)
Neo4jlist of numberswith "storage": "graph" or the placement role vector moved to Neo4j
Elasticsearchdense_vectorsearch copy, indexed for the intent vector

The search copy is written unless the property or the type sets "search": false. Where a property is stored is explained in placement.

Indices

vector, also inside objects, see the vector intent.

Limits

The API does not limit the number of dimensions. Elasticsearch accepts at most 4096 dimensions for dense_vector, see Elasticsearch.

Example

Schema:

{
"type": "vector",
"dimensions": 3,
"similarity": "cosine",
"index": "vector"
}

Input, the element response does not contain the hidden vector unless the schema sets "visibility": "public":

{
"data": {
"embedding": [
0.12,
-0.5,
0.33
]
}
}