Embedding
Last updated
Last updated
static async availability(options) =>
Get the availability of the on-device language model.
Returns the availability
static async compatibility(options) =>
Get the availability of the on-device language model.
Returns the compatibility
static async create(options) =>
Creates a new embedding session
Returns a new Embedding session that can be prompted with the pre-provided configuration
boolean
number
async (input, options) => number[] | number[][]
Creates a new vector from the provided input
A string
or strings[]
to generate a vector(s) from
signal optional AbortSignal
Returns the vector or vectors from the language model
(vectorA, vectorB) => number
Calculates the cosine similarity between two embeddings. Only compare embeddings created by the same model
A number[]
vector to compare
A number[]
vector to compare
Returns a value between 0 and 1 representing the similarity. 1 being the most similar
(embeddings, target) => any[]
Finds and sorts similar vectors
An Array<{ id: any, vector: number[] }>
array of objects, each with id and vector
A number[]
vector to use as the search target
Returns a list of ids, sorted by the most similar to the least similar
options optional
options optional
options optional