View Source SqliteVec.Ecto.Query (SqliteVec v0.1.0)
Macros for Ecto
Summary
Functions
Adds every element in vector a with vector b, returning a new vector c. Both vectors must be of the same type and same length. Only float32 and int8 vectors are supported.
Creates a bit vector
Calculates the cosine distance between vectors a and b. Only valid for float32 or int8 vectors.
Calculates the hamming distance between two bitvectors a and b. Only valid for bitvectors.
Calculates the L2 euclidian distance between vectors a and b. Only valid for float32 or int8 vectors.
Creates a float32 vector
Creates an int8 vector
Returns the number of elements in the given vector
Performs L2 normalization on the given vector. Only float32 vectors are currently supported.
Quantize a float32 or int8 vector into a bitvector. For every element in the vector, a 1 is assigned to positive numbers and a 0 is assigned to negative numbers. These values are then packed into a bit vector.
Extract a subset of vector from the start element (inclusive) to the end element (exclusive).
Subtracts every element in vector a with vector b, returning a new vector c. Both vectors must be of the same type and same length. Only float32 and int8 vectors are supported.
Represents a vector as JSON text. The input vector can be a vector BLOB or JSON text.
Returns the name of the type of vector
as text
Functions
Adds every element in vector a with vector b, returning a new vector c. Both vectors must be of the same type and same length. Only float32 and int8 vectors are supported.
An error is raised if either a or b are invalid, or if they are not the same type or same length.
Creates a bit vector
Calculates the cosine distance between vectors a and b. Only valid for float32 or int8 vectors.
Returns an error under the following conditions:
- a or b are invalid vectors
- a or b do not share the same vector element types (ex float32 or int8)
- a or b are bit vectors. Use vec_distance_hamming() for distance calculations between two bitvectors.
- a or b do not have the same length
Calculates the hamming distance between two bitvectors a and b. Only valid for bitvectors.
Returns an error under the following conditions:
- a or b are not bitvectors
- a and b do not share the same length
- Memory cannot be allocated
Calculates the L2 euclidian distance between vectors a and b. Only valid for float32 or int8 vectors.
Returns an error under the following conditions:
- a or b are invalid vectors
- a or b do not share the same vector element types (ex float32 or int8)
- a or b are bit vectors. Use vec_distance_hamming() for distance calculations between two bitvectors.
- a or b do not have the same length.
Creates a float32 vector
Creates an int8 vector
Returns the number of elements in the given vector
Performs L2 normalization on the given vector. Only float32 vectors are currently supported.
Returns an error if the input is an invalid vector or not a float32 vector.
Quantize a float32 or int8 vector into a bitvector. For every element in the vector, a 1 is assigned to positive numbers and a 0 is assigned to negative numbers. These values are then packed into a bit vector.
Returns an error if vector is invalid, or if vector is not a float32 or int8 vector.
Extract a subset of vector from the start element (inclusive) to the end element (exclusive).
This is especially useful for Matryoshka embeddings, also known as "adaptive length" embeddings. Use with vec_normalize() to get proper results.
Returns an error in the following conditions:
- If vector is not a valid vector
- If start is less than zero or greater than or equal to end
- If end is greater than the length of vector, or less than or equal to start.
- If vector is a bitvector, start and end must be divisible by 8.
Subtracts every element in vector a with vector b, returning a new vector c. Both vectors must be of the same type and same length. Only float32 and int8 vectors are supported.
An error is raised if either a or b are invalid, or if they are not the same type or same length.
Represents a vector as JSON text. The input vector can be a vector BLOB or JSON text.
Returns an error if vector is an invalid vector, or when memory cannot be allocated.
Returns the name of the type of vector
as text