Table of Contents

Method GetEmbeddingsAsync

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

GetEmbeddingsAsync(IEnumerable<string>, CancellationToken)

Asynchronously generates embedding vectors for a batch of texts.

public abstract Task<float[][]> GetEmbeddingsAsync(IEnumerable<string> texts, CancellationToken cancellationToken = default)

Parameters

texts IEnumerable<string>

The texts to embed. Cannot be null or empty.

cancellationToken CancellationToken

Optional token to cancel the operation.

Returns

Task<float[][]>

A task whose result is an array of vectors, one per input text and in the same order.

Remarks

This is the single load-bearing operation of the contract. Remote providers should batch the request to amortize network cost; local providers may batch by token count.

GetEmbeddingsAsync(string, CancellationToken)

Asynchronously generates the embedding vector for a single text.

public virtual Task<float[]> GetEmbeddingsAsync(string text, CancellationToken cancellationToken = default)

Parameters

text string

The text to embed. Cannot be null or empty.

cancellationToken CancellationToken

Optional token to cancel the operation.

Returns

Task<float[]>

A task whose result is the embedding vector. Its length equals EmbeddingSize once the dimension is known.

Remarks

The default implementation forwards a single-element batch to GetEmbeddingsAsync(IEnumerable<string>, CancellationToken). Override it when a dedicated single-item call path is more efficient.

Share