Skip to main content

Module vector

Module vector 

Source
Expand description

Vector indexes over embeddings stored as RDF literals (backends with vector functions: Turso).

An index is described in the system graph <oxilite:vectors> by the resource <oxilite:vector/NAME> (see VectorIndex::to_quads) — the definition is data, queryable and versioned like any other. It is realised as a table vec_name of (s, o, g, e) rows, one per embedding literal of the indexed property, kept current by triggers on quads in the same transaction as every write, and back-filled when it is created. A fingerprint in oxilite_meta (vector:name) records how the table was built, so sync_statements can tell a missing, stale or orphaned table from a current one.

knn_sql is the one nearest-neighbour statement: the SPARQL compiler (SERVICE <oxilite:vector/NAME>), the Datalog built-in nearest and the store API all use it.

Modules§

vocab
IRIs of the vector vocabulary (in the oxl: namespace).

Structs§

VectorIndex
A vector index definition.

Enums§

ElementType
How vector elements are stored.
Metric
How distance is measured.
QueryVector
What a search is near.

Constants§

DEFAULT_GRAPH
The id of the default graph, for callers building their own statements.
DEFAULT_K
Default number of results.
INDEX_PREFIX
The IRI prefix of an index: <oxilite:vector/NAME> names it, and is the SERVICE IRI that searches it.
MAX_K
Most results a search may ask for.
VECTORS_GRAPH
The system graph holding vector index definitions.

Functions§

built_from_meta
Built fingerprints by lower-case index name, from oxilite_meta rows (key, value).
definitions_from_quads
Definitions read from quads of <oxilite:vectors> (other quads are ignored).
definitions_from_rows
Definitions read from the rows of definitions_statement: the valid ones, and a message for each description that is not one.
definitions_statement
The statement reading the definitions: every quad of <oxilite:vectors> with the text of its terms (see definitions_from_rows).
drop_statements
Statements dropping an index’s table, triggers and fingerprint (by lower-case name).
find
Finds a definition by exact name, else ignoring case.
index_iri
<oxilite:vector/NAME>.
is_built
Is name’s table built from this exact definition?
knn_ranked_sql
knn_sql with a 1-based rank column r (ties broken by id), for relational frontends that carry term ids rather than computed values.
knn_sql
The nearest-neighbour statement: rows (s, d) — at most k distinct nodes (term ids), each at its smallest distance, by increasing distance then id.
parse_vector
Parses a JSON array of numbers, the lexical form of an embedding.
service_index
The index a SERVICE IRI names.
sync_statements
Statements making the built tables match the definitions: orphans and stale tables are dropped, missing and stale ones created. Empty when everything is current.
update_touches_vectors
Can this update change a vector index definition? Any triple written to <oxilite:vectors> counts; with a variable graph, a triple counts when it could be a definition triple (a variable predicate, an oxl: predicate, or rdf:type with a variable or oxl: class). LOAD, CLEAR and DROP always count: re-checking is one read when nothing changed.