Method GetEmbeddingsAsync
- Namespace
- LMKit.Embeddings
- Assembly
- LM-Kit.NET.dll
GetEmbeddingsAsync(string, CancellationToken)
Generates the embedding vector for a given text string.
This vector represents the text in a high-dimensional space, enabling various natural language processing tasks by capturing semantic meaning.
public Task<float[]> GetEmbeddingsAsync(string text, CancellationToken cancellationToken = default)
Parameters
text
stringThe text string to be converted into an embedding vector. Cannot be null or empty.
cancellationToken
CancellationTokenOptional. A CancellationToken for handling cancellation requests.
Returns
- Task<float[]>
An array of floats representing the embedding vector of the input text. Each element in the array contributes to the multidimensional representation of the text's semantic meaning.
Remarks
The dimension of the array is specified by the EmbeddingSize property.
Exceptions
- ArgumentNullException
Thrown when the input text is null or an empty string, as an embedding vector cannot be generated from an empty input.
GetEmbeddingsAsync(IList<int>, CancellationToken)
Generates the embedding vector for a given tokenized text.
This vector represents the text in a high-dimensional space, enabling various natural language processing tasks by capturing semantic meaning.
public Task<float[]> GetEmbeddingsAsync(IList<int> tokens, CancellationToken cancellationToken = default)
Parameters
tokens
IList<int>The array of tokens to be converted into an embedding vector. Cannot be null or empty.
cancellationToken
CancellationTokenOptional. A CancellationToken for handling cancellation requests.
Returns
- Task<float[]>
An array of floats representing the embedding vector of the input text. Each element in the array contributes to the multidimensional representation of the text's semantic meaning.
Remarks
The dimension of the array is specified by the EmbeddingSize property.
Exceptions
- ArgumentNullException
Thrown when the input array of tokens is null or empty, as an embedding vector cannot be generated from an empty input.