Table of Contents

Class BedrockEmbedder

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

An IEmbedder backed by Amazon Bedrock, so Bedrock-hosted embedding models (Amazon Titan Text Embeddings and Cohere Embed) can be used anywhere LMKit consumes embeddings, including RagEngine.

public sealed class BedrockEmbedder : EmbedderBase, IEmbedder, IQueryEmbedder
Inheritance
BedrockEmbedder
Implements
Inherited Members

Remarks

The request and response shape differs per model family; this class detects the family from the model id (or an explicit override) and formats each call accordingly:

  • Amazon Titan (for example amazon.titan-embed-text-v2:0) embeds a single text per request, so a batch is issued as sequential calls. The optional output dimension and normalization flag are forwarded when supported.
  • Cohere (for example cohere.embed-english-v3) embeds a batch in one request and distinguishes queries from passages via input_type, which this class sets when IQueryEmbedder is used.

Credentials and region are resolved by the AWS SDK. Pass an IAmazonBedrockRuntime you have configured, or use the region-based constructor, which relies on the default AWS credential provider chain (environment variables, shared profile, or an IAM role).

Constructors

BedrockEmbedder(IAmazonBedrockRuntime, string, ModelFamily?, int?, bool)

Initializes a new instance of the BedrockEmbedder class with an already-configured Bedrock runtime client.

BedrockEmbedder(string, RegionEndpoint, ModelFamily?, int?, bool)

Initializes a new instance of the BedrockEmbedder class, creating a Bedrock runtime client for the given region using the default AWS credential provider chain.

Properties

EmbeddingSize

Gets the dimension of the vectors this embedder produces.

ModelId

Gets a stable identifier for the underlying model or deployment.

Methods

GetEmbeddingsAsync(IEnumerable<string>, CancellationToken)

Asynchronously generates embedding vectors for a batch of texts.

GetQueryEmbeddingsAsync(string, CancellationToken)

Asynchronously generates the embedding vector for a search query, applying any query-specific instruction the model supports.

Share