EmbeddingsModel<TOptions extends EmbeddingsModelOptions> class abstract

Embeddings model base class.

Constructors

EmbeddingsModel({required String name, required TOptions defaultOptions, int? dimensions, int? batchSize})
Creates a new embeddings model instance.

Properties

batchSize int?
The maximum number of texts to embed in a single request.
final
defaultOptions → TOptions
The default options for the embeddings model.
final
dimensions int?
The number of dimensions the resulting output embeddings should have.
final
hashCode int
The hash code for this object.
no setterinherited
name String
The model name to use.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Disposes the embeddings model.
embedDocuments(List<String> texts, {TOptions? options}) Future<BatchEmbeddingsResult>
Embed texts and return results with usage data.
embedQuery(String query, {TOptions? options}) Future<EmbeddingsResult>
Embed query text and return result with usage data.
getIndexesMostSimilarEmbeddings(List<double> embedding, List<List<double>> embeddings, {double similarityFunction(List<double> a, List<double> b) = cosineSimilarity}) List<int>
Returns a sorted list of indexes of embeddings that are most similar to the provided embedding (in descending order, most similar first).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

calculateSimilarity(List<double> embedding, List<List<double>> embeddings, {double similarityFunction(List<double> a, List<double> b) = cosineSimilarity}) List<double>
Calculates the similarity between an embedding and a list of embeddings.
cosineSimilarity(List<double> a, List<double> b) double
Measures the cosine of the angle between two vectors in a vector space. It ranges from -1 to 1, where 1 represents identical vectors, 0 represents orthogonal vectors, and -1 represents vectors that are diametrically opposed.