IEmbeddingModel<T>

Interfaces · AiDotNet.Interfaces

Defines the contract for embedding models that convert text into vector representations.

Known implementations: CacheBackedEmbeddings<T>, EmbeddingModelBase<T>, FastText<T>, GloVe<T>, SiameseNeuralNetwork<T>, TransformerEmbeddingNetwork<T>, Word2Vec<T>

For Beginners

An embedding model is like a translator that converts words into numbers.

Think of it like a coordinate system for meaning:

  • Each word or sentence becomes a point in high-dimensional space
  • Similar meanings end up close together (like “happy” near “joyful”)
  • Different meanings are far apart (like “happy” far from “sad”)
  • This lets computers understand and compare text by measuring distances

For example, the embedding for “cat” might be close to “kitten” and “feline”, but far from “democracy” or “algorithm”.

How It Works

An embedding model transforms text into dense numerical vectors that capture semantic meaning. These vectors enable similarity comparisons and are fundamental to retrieval-augmented generation. The interface supports both single and batch embeddings with configurable dimensions.

Properties

Property Summary
int EmbeddingDimension { get; } Gets the dimensionality of the embedding vectors produced by this model.
int MaxTokens { get; } Gets the maximum length of text (in tokens) that this model can process.

Methods

Method Summary
Matrix<T> EmbedBatch(IEnumerable<string> texts) Embeds multiple text strings into vector representations in a single batch operation.
Task<Matrix<T>> EmbedBatchAsync(IEnumerable<string> texts) Asynchronously embeds multiple text strings into vector representations in a single batch operation.
Task<Vector<T>> EmbedAsync(string text) Asynchronously embeds a single text string into a vector representation.
Vector<T> Embed(string text) Embeds a single text string into a vector representation.