Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit 9d4d457

Browse files
committed
feat: Amazon Bedrock Embedding doc
1 parent ac84d29 commit 9d4d457

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

Diff for: docs/embeddings.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Chroma provides lightweight wrappers around popular embedding providers, making
2020
| [Instructor](/embeddings/instructor) |||
2121
| [Hugging Face Embedding Server](/embeddings/hugging-face-embedding-server) |||
2222
| [Jina AI](/embeddings/jinaai) |||
23+
| [Amazon Bedrock](/embeddings/amazon-bedrock) |||
2324

2425
We welcome pull requests to add new Embedding Functions to the community.
2526

Diff for: docs/embeddings/amazon-bedrock.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
---
3+
4+
# Amazon Bedrock
5+
6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
8+
9+
<div class="select-language">Select a language</div>
10+
11+
<Tabs queryString groupId="lang">
12+
<TabItem value="py" label="Python"></TabItem>
13+
<TabItem value="js" label="JavaScript"></TabItem>
14+
</Tabs>
15+
16+
17+
Chroma provides a convinient wrapper for [Amazon Bedrock](https://aws.amazon.com/bedrock/) embedding API. This embedding function runs remotely on Amazon's servers, and requires an Amazon client information.
18+
19+
<Tabs queryString groupId="lang" className="hideTabSwitcher">
20+
<TabItem value="py" label="Python">
21+
22+
To use Amazon Bedrock embedding API, you must have `boto3` Python package installed and create an instance of `boto3.Session` with your AWS credentials. To use:
23+
24+
```python
25+
import boto3
26+
import chromadb.utils.embedding_functions as embedding_functions
27+
28+
session = boto3.Session(
29+
aws_access_key_id=aws_access_key_id,
30+
aws_secret_access_key=aws_secret_access_key,
31+
region_name=region_name,
32+
)
33+
bedrock = embedding_functions.AmazonBedrockEmbeddingFunction(session=session)
34+
bedrock(["document1","document2"])
35+
```
36+
37+
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:
38+
39+
```python
40+
bedrock = embedding_functions.AmazonBedrockEmbeddingFunction(
41+
session=session, model_name="cohere.embed-multilingual-v3")
42+
bedrock(["こんにちは", "你们好"])
43+
```
44+
45+
</TabItem>
46+
<TabItem value="js" label="JavaScript">
47+
48+
To use Amazon Bedrock embedding API, you must have `@aws-sdk/client-bedrock-runtime` installed. To use:
49+
50+
```javascript
51+
import { AmazonBedrockEmbeddingFunction } from 'chromadb';
52+
import { fromSSO } = from '@aws-sdk/credential-providers';
53+
54+
const c = await fromSSO({profile: "my-profile"})
55+
const ef = new AmazonBedrockEmbeddingFunction({config: {credentials: c, region: "us-east-1"}})
56+
57+
// use directly
58+
const embeddings = await ef.generate(["foo"])
59+
60+
// pass documents to query for .add and .query
61+
const collection = await client.createCollection({name: "name", embeddingFunction: ef})
62+
const collection = await client.getCollection({name: "name", embeddingFunction: ef})
63+
```
64+
65+
</TabItem>
66+
</Tabs>

Diff for: sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const sidebars = {
9393
'embeddings/instructor',
9494
'embeddings/hugging-face-embedding-server',
9595
'embeddings/jinaai',
96+
'embeddings/amazon-bedrock',
9697
],
9798
},
9899
],

0 commit comments

Comments
 (0)