Table of Contents

Method GetQueryEmbeddingsAsync

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

GetQueryEmbeddingsAsync(string, CancellationToken)

Asynchronously generates the embedding vector for a query string, applying the model's query instruction prefix when available. Use this for search/retrieval queries to improve recall with models that support asymmetric query/passage embedding (e.g., Qwen3 Embedding, Nomic Embed, BGE v1.5). For passage/document embedding, use GetEmbeddingsAsync(string, CancellationToken) instead.

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

Parameters

text string

The query text to be converted into an embedding vector. Cannot be null or empty.

cancellationToken CancellationToken

Optional. A CancellationToken for handling cancellation requests.

Returns

Task<float[]>

A task that represents the asynchronous operation. The task result contains an array of floats representing the embedding vector of the query text.

Remarks

The dimension of the array is specified by the EmbeddingSize property.

Exceptions

ArgumentNullException

Thrown when the input text is null or empty.

Share