Bedrock
Unstable API
0.8.0
@project-lakechain/bedrock-embedding-processors
This package enables developers to use embedding models hosted on Amazon Bedrock to create vector embeddings for text and image documents within their pipelines. It exposes different constructs that you can integrate as part of your pipelines, including Amazon Titan, and Cohere embedding processors.
đ Embedding Documents
To use the Bedrock embedding processors, you import the Titan or Cohere constructs in your CDK stack and specify the embedding model you want to use.
Titan Text
âšī¸ The below example demonstrates how to use the Amazon Titan embedding processor to create vector embeddings for text documents.
Titan Multimodal
âšī¸ The below example demonstrates how to use the Amazon Titan embedding processor to create vector embeddings for images.
Embedding Size
When using the Amazon Titan multimodal embedding model, you can specify the size of the embeddings generated for the images using the .withEmbeddingSize
API.
đ The default embedding size is set to 1024, and valid sizes are 256, 512, and 1024. Note that embedding size customization is only available for Amazon Titan multimodal models.
Cohere
âšī¸ The below example uses one of the supported Cohere embedding models.
đ Region Selection
You can specify the AWS region in which you want to invoke Amazon Bedrock using the .withRegion
API. This can be helpful if Amazon Bedrock is not yet available in your deployment region.
đ By default, the middleware will use the current region in which it is deployed.
đ Output
The Bedrock embedding processor does not modify or alter source documents in any way. It instead enriches the metadata of the documents with a pointer to the vector embeddings that were created for the document.
đ Click to expand example
âšī¸ Limits
Both the Titan and Cohere embedding models have limits on the number of input tokens they can process. For more information, you can consult the Amazon Bedrock documentation to understand these limits.
đ To limit the size of upstream text documents, we recommend to use a text splitter to chunk text documents before they are passed to this middleware, such as the Recursive Character Text Splitter.
Furthermore, this middleware applies a throttling of 10 concurrently processed documents from its input queue to ensure that it does not exceed the limits of the embedding models it uses â see Bedrock Quotas for more information.
đī¸ Architecture
The middlewares part of this package are based on a Lambda compute running on an ARM64 architecture, and integrate with Amazon Bedrock to generate embeddings for text documents.
đˇī¸ Properties
Supported Inputs
The supported inputs depend on the selected model.
Mime Type | Description | Model |
---|---|---|
text/plain | UTF-8 text documents. | Amazon Titan Text, Cohere |
text/markdown | UTF-8 markdown documents. | Amazon Titan Text, Cohere |
image/jpeg | JPEG image documents. | Amazon Titan Multimodal |
image/png | PNG image documents. | Amazon Titan Multimodal |
Supported Outputs
The supported outputs depend on the selected model.
Mime Type | Description | Model |
---|---|---|
text/plain | UTF-8 text documents. | Amazon Titan Text, Cohere |
text/markdown | UTF-8 markdown documents. | Amazon Titan Text, Cohere |
image/jpeg | JPEG image documents. | Amazon Titan Multimodal |
image/png | PNG image documents. | Amazon Titan Multimodal |
Supported Compute Types
Type | Description |
---|---|
CPU | This middleware only supports CPU compute. |
đ Examples
- Bedrock OpenSearch Pipeline - An example showcasing an embedding pipeline using Amazon Bedrock and OpenSearch.
- Cohere OpenSearch Pipeline - An example showcasing an embedding pipeline using Cohere models on Bedrock and OpenSearch.
- Bedrock Multimodal Pipeline - An example showcasing an embedding pipeline using the Titan multimodal embedding model.