ITokenEmbeddingModel<T>
Interfaces · AiDotNet.Interfaces
Defines the contract for a model that produces per-token (contextual) embeddings for a text.
Known implementations: EmbeddingModelTokenAdapter<T>
For Beginners
Think of this as describing a sentence word-by-word instead of summarising the whole sentence in one number-list.
- Single-vector model: “The quick brown fox” -> one vector.
- Token embedding model: “The quick brown fox” -> four vectors (one for each word).
Keeping a vector per word lets a reranker ask, for every word in your question, “which word in this document matches me best?” - a much finer-grained comparison than a single overall vector.
How It Works
Unlike a single-vector embedding model (IEmbeddingModel) which collapses an
entire text into one dense vector, a token embedding model returns one vector per token.
This is the representation required by late-interaction retrievers and rerankers such as
ColBERT (Khattab & Zaharia 2020), where the relevance of a (query, document) pair is scored
by matching individual query tokens against individual document tokens rather than comparing
two pooled vectors.
Properties
| Property | Summary |
|---|---|
int EmbeddingDimension { get; } |
Gets the dimensionality of each per-token embedding vector. |
Methods
| Method | Summary |
|---|---|
Vector<T>[] EmbedTokens(string text) |
Produces one embedding vector for each token in the supplied text. |