Table of Contents

Class EmbedderBase

Namespace
LMKit.Abstractions
Assembly
LM-Kit.NET.dll

Convenience base class for implementing a custom embedding provider with minimal effort.

public abstract class EmbedderBase : IEmbedder, IQueryEmbedder
Inheritance
EmbedderBase
Implements
Derived
Inherited Members

Remarks

Derive from this class and override the single batch method GetEmbeddingsAsync(IEnumerable<string>, CancellationToken) plus the ModelId and EmbeddingSize properties. The single-text overload, the query path (which defaults to the passage path), and the synchronous wrappers are all supplied for you. This is the recommended way to plug a remote service or an in-house endpoint into LM-Kit.

Providers that support asymmetric query embedding should override GetQueryEmbeddingsAsync(string, CancellationToken). Providers with additional capabilities (image embedding, pre-tokenized input) may also implement IImageEmbedder or ITokenizingEmbedder directly.

public sealed class MyHttpEmbedder : EmbedderBase
{
    public override string ModelId => "my-service/text-embed-v1";
    public override int EmbeddingSize => 1024;
public override async Task<float[][]> GetEmbeddingsAsync(
    IEnumerable<string> texts, CancellationToken cancellationToken = default)
{
    // POST texts to your endpoint and return one vector per input.
}

}

Properties

EmbeddingSize

Gets the dimension of the vectors this embedder produces.

ModelId

Gets a stable identifier for the underlying model or deployment.

Methods

GetEmbeddings(IEnumerable<string>, CancellationToken)

Synchronously generates embedding vectors for a batch of texts.

GetEmbeddings(string, CancellationToken)

Synchronously generates the embedding vector for a single text.

GetEmbeddingsAsync(IEnumerable<string>, CancellationToken)

Asynchronously generates embedding vectors for a batch of texts.

GetEmbeddingsAsync(string, CancellationToken)

Asynchronously generates the embedding vector for a single text.

GetQueryEmbeddings(string, CancellationToken)

Synchronously generates the embedding vector for a search query.

GetQueryEmbeddingsAsync(string, CancellationToken)

Asynchronously generates the embedding vector for a search query, applying any query-specific instruction the model supports.

Share