Skip to main content

Amazon Bedrock

Select a language

Chroma provides a convinient wrapper for Amazon Bedrock embedding API. This embedding function runs remotely on Amazon's servers, and requires an Amazon client information.

To use Amazon Bedrock embedding API, you must have boto3 Python package installed.

pip install boto3

To pass AWS credential, create an instance of boto3.Session with your AWS credentials.

Here is the example:

import boto3
import chromadb.utils.embedding_functions as embedding_functions

session = boto3.Session(
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key,
region_name=region_name,
)
bedrock = embedding_functions.AmazonBedrockEmbeddingFunction(session=session)
bedrock(["document1","document2"])

By default, the embedding function uses the amazon.titan-embed-text-v1 for the model, but you can specify a different model name with model_name parameter. For example:

bedrock = embedding_functions.AmazonBedrockEmbeddingFunction(
session=session, model_name="cohere.embed-multilingual-v3")
bedrock(["こんにちは", "你们好"])