Similarity retrieval
Convert a single document, query, or phrase into a vector for similarity search.
AI Tools · Function
Generates an embedding for one value with an embedding model. The returned object includes the original value and its numeric embedding vector.
embed sends one value to the selected embedding model and asynchronously returns both the original value and its numeric embedding vector. The value's type depends on the model, while the returned embedding can be used for similarity retrieval or downstream processing.
embed({ model, value })】【。| Name | Type | Description |
|---|---|---|
model | EmbeddingModel | The embedding model to use. |
value | VALUE | The value to embed. The type depends on the model. |
An object containing value (the embedded input) and embedding (number[]), the embedding vector.
embed when one input value must be converted into an embedding.model parameter.value parameter.embedding property.value type is model-dependent, so pass the kind of input supported by the chosen embedding model.import { embed } from 'ai';
const { embedding } = await embed({
model: 'openai/text-embedding-3-small',
value: 'sunny day at the beach',
});
console.log(embedding);Creates a numeric embedding for one text value and prints the resulting vector.
Convert a single document, query, or phrase into a vector for similarity search.
Create vectors for one-off inputs before storing or comparing them.
Pass an embedding into a downstream ranking, clustering, or classification workflow.
embedManyEmbeddingModelembeddingModel