Skip to content

< Back


LLamaEmbedder

Namespace: LLama

Generate high dimensional embedding vectors from text

1
public sealed class LLamaEmbedder : System.IDisposable, Microsoft.Extensions.AI.IEmbeddingGenerator`2[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Extensions.AI.Embedding`1[[System.Single, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Microsoft.Extensions.AI.Abstractions, Version=9.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], Microsoft.Extensions.AI.IEmbeddingGenerator

Inheritance ObjectLLamaEmbedder
Implements IDisposable, IEmbeddingGenerator<String, Embedding<Single>>, IEmbeddingGenerator
Attributes NullableContextAttribute, NullableAttribute

Properties

EmbeddingSize

Dimension of embedding vectors

1
public int EmbeddingSize { get; private set; }

Property Value

Int32

Context

LLama Context

1
public LLamaContext Context { get; private set; }

Property Value

LLamaContext

Constructors

LLamaEmbedder(LLamaWeights, IContextParams, ILogger)

Create a new embedder, using the given LLamaWeights

1
public LLamaEmbedder(LLamaWeights weights, IContextParams params, ILogger logger)

Parameters

weights LLamaWeights

params IContextParams

logger ILogger

Methods

Dispose()

1
public void Dispose()

GetEmbeddings(String, CancellationToken)

Get high dimensional embedding vectors for the given text. Depending on the pooling type used when constructing this LLamaEmbedder this may return an embedding vector per token, or one single embedding vector for the entire string.

1
public Task<IReadOnlyList<Single[]>> GetEmbeddings(string input, CancellationToken cancellationToken)

Parameters

input String

cancellationToken CancellationToken

Returns

Task<IReadOnlyList<Single[]>>

Exceptions

RuntimeError

NotSupportedException

Remarks:

Embedding vectors are not normalized, consider using one of the extensions in SpanNormalizationExtensions.


< Back