IEmbeddingGenerator<TInput,TEmbedding> Interface

Definition

Represents a generator of embeddings.

C#
public interface IEmbeddingGenerator<in TInput,TEmbedding> : IDisposable where TEmbedding : Embedding

Type Parameters

TInput

The type from which embeddings will be generated.

This type parameter is contravariant. That is, you can use either the type you specified or any type that is less derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
TEmbedding

The type of embeddings to generate.

Derived
Implements

Remarks

Unless otherwise specified, all members of IEmbeddingGenerator<TInput,TEmbedding> are thread-safe for concurrent use. It is expected that all implementations of IEmbeddingGenerator<TInput,TEmbedding> support being used by multiple requests concurrently.

However, implementations of IEmbeddingGenerator<TInput,TEmbedding> may mutate the arguments supplied to GenerateAsync(IEnumerable<TInput>, EmbeddingGenerationOptions, CancellationToken), such as by adding additional values to the values list or configuring the options instance. Thus, consumers of the interface either should avoid using shared instances of these arguments for concurrent invocations or should otherwise ensure by construction that no IEmbeddingGenerator<TInput,TEmbedding> instances are used which might employ such mutation.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(Inherited from IDisposable)
GenerateAsync(IEnumerable<TInput>, EmbeddingGenerationOptions, CancellationToken)

Generates embeddings for each of the supplied values.

GetService(Type, Object)

Asks the IEmbeddingGenerator<TInput,TEmbedding> for an object of the specified type serviceType.

Extension Methods

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)