Skip to content

Commit ceab1db

Browse files
authored
Update the list of models in Amazon Bedrock (#322)
1 parent 6e74153 commit ceab1db

File tree

1 file changed

+35
-33
lines changed

1 file changed

+35
-33
lines changed

integrations/amazon-bedrock.md

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,64 +36,66 @@ pip install amazon-bedrock-haystack
3636

3737
## Usage
3838

39-
Once installed, you will have access to [AmazonBedrockGenerator](https://docs.haystack.deepset.ai/docs/amazonbedrockgenerator) and [AmazonBedrockChatGenerator](https://docs.haystack.deepset.ai/docs/amazonbedrockchatgenerator) components that support generative language models on Amazon Bedrock.
39+
Once installed, you will have access to [AmazonBedrockChatGenerator](https://docs.haystack.deepset.ai/docs/amazonbedrockchatgenerator) and [AmazonBedrockGenerator](https://docs.haystack.deepset.ai/docs/amazonbedrockgenerator) components that support generative language models on Amazon Bedrock.
4040
You will also have access to the [AmazonBedrockTextEmbedder](https://docs.haystack.deepset.ai/docs/amazonbedrocktextembedder) and [AmazonBedrockDocumentEmbedder](https://docs.haystack.deepset.ai/docs/amazonbedrockdocumentembedder), which can be used to compute embeddings.
4141

42-
### AmazonBedrockGenerator
42+
To use this integration, set the AWS credentials (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`) as environment variables or passed as [Secret](https://docs.haystack.deepset.ai/docs/secret-management) arguments.
4343

44-
To use this integration for text generation, initialize an `AmazonBedrockGenerator` with the model name, the AWS credentials (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`) should be set as environment variables or passed as [Secret](https://docs.haystack.deepset.ai/docs/secret-management) arguments.
45-
Note, make sure the region you set supports Amazon Bedrock.
46-
47-
Currently, the following models are supported:
48-
49-
- AI21 Labs' Jurassic-2
50-
- Amazon Titan language models
51-
- Anthropic's Claude
52-
- Cohere's Command
53-
- Meta's Llama 2
54-
55-
```python
56-
from haystack_integrations.components.generators.amazon_bedrock import AmazonBedrockGenerator
57-
58-
generator = AmazonBedrockGenerator(model="anthropic.claude-v2")
59-
result = generator.run("Who is the best American actor?")
60-
for reply in result["replies"]:
61-
print(reply)
62-
```
63-
Output:
64-
```shell
65-
'There is no definitive "best" American actor, as acting skill and talent a# re subjective. However, some of the most acclaimed and influential American act# ors include Tom Hanks, Daniel Day-Lewis, Denzel Washington, Meryl Streep, Rober# t De Niro, Al Pacino, Marlon Brando, Jack Nicholson, Leonardo DiCaprio and John# ny Depp. Choosing a single "best" actor comes down to personal preference.'
66-
```
44+
> Note: Make sure the region you set supports Amazon Bedrock.
6745
6846
### AmazonBedrockChatGenerator
6947

70-
To use this integration for chat models, initialize an `AmazonBedrockChatGenerator` with the model name and AWS credentials:
48+
To use this integration for chat models, initialize an `AmazonBedrockChatGenerator` with the model name:
7149

72-
Currently, the following models are supported:
73-
- Anthropic's Claude 2, Claude 3 Sonnet
74-
- Meta's Llama 2
50+
Some supported models are:
51+
- **AI21 Labs'** Jamba 1.5 Large, Jamba 1.5 Mini
52+
- **Amazon's** Nova Canvas, Nova Lite, Nova Pro
53+
- **Amazon's** Titan Text G1 - Express, Titan Text G1 - Lite
54+
- **Anthropic's** Claude chat models
55+
- **Cohere's** Command, Command Light and other Command models
56+
- **DeepSeek's** DeepSeek-R1
57+
- **Meta's** Llama models
58+
- **Mistral AI's**
59+
60+
Get the complete list of models in [Supported foundation models in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html)
7561

7662
```python
7763
from haystack_integrations.components.generators.amazon_bedrock import AmazonBedrockChatGenerator
7864
from haystack.dataclasses import ChatMessage
7965

80-
generator = AmazonBedrockChatGenerator(model="meta.llama2-70b-chat-v1")
66+
generator = AmazonBedrockChatGenerator(model="amazon.nova-pro-v1:0")
8167
messages = [ChatMessage.from_system("You are a helpful assistant that answers question in Spanish only"),
8268
ChatMessage.from_user("What's Natural Language Processing? Be brief.")]
8369

8470
response = generator.run(messages)
8571
print(response)
8672

73+
```
74+
Output:
75+
```js
76+
{'replies': [ChatMessage(_role=<ChatRole.ASSISTANT: 'assistant'>, _content=[TextContent(text='El procesamiento del lenguaje natural (PLN) es una rama de la inteligencia artificial que permite a las computadoras comprender, interpretar y generar lenguaje humano.')], _name=None, _meta={'model': 'amazon.nova-pro-v1:0', 'index': 0, 'finish_reason': 'end_turn', 'usage': {'prompt_tokens': 21, 'completion_tokens': 31, 'total_tokens': 52}})]}
77+
```
78+
79+
### AmazonBedrockGenerator
80+
81+
Most [supported models](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) can be used with `AmazonBedrockGenerator`, but we highly recommend using the `AmazonBedrockChatGenerator` instead.
82+
83+
```python
84+
from haystack_integrations.components.generators.amazon_bedrock import AmazonBedrockGenerator
85+
86+
generator = AmazonBedrockGenerator(model="mistral.mixtral-8x7b-instruct-v0:1")
87+
result = generator.run("Who is the best American actor?")
88+
print(result)
8789
```
8890
Output:
8991
```shell
90-
{'replies': [ChatMessage(content=' Procesamiento del Lenguaje Natural (PLN) es una rama de la inteligencia artificial que se enfoca en el desarrollo de algoritmos y modelos que permiten a las computadoras comprender y procesar el lenguaje natural, como el hablado o escrito por los humanos.', role=<ChatRole.ASSISTANT: 'assistant'>, name=None, meta={'stop_reason': 'stop', 'usage': {'prompt_tokens': 44, 'completion_tokens': 71}})]}
92+
{'replies': ['It\'s subjective to determine the "best" American actor as it depends on personal preferences, critical acclaim, and the impact of their work. However, some of the most renowned and influential American actors include:\n\n1. Daniel Day-Lewis - Known for his versatility and commitment to his roles, Day-Lewis is a three-time Academy Award winner for Best Actor.\n2. Meryl Streep - With a record 21 Academy Award nominations and three wins, Streep is widely regarded as one of the greatest actresses in American film history.\n3. Jack Nicholson - A three-time Academy Award winner and 12-time nominee, Nicholson is known for his iconic roles in films like "One Flew Over the Cuckoo\'s Nest," "Terms of Endearment," and "As Good as It Gets."\n4. Robert De Niro - A two-time Academy Award winner, De Niro is known for his collaborations with Martin Scorsese and his memorable roles in films like "Taxi Driver," "Raging Bull," and "The Godfather: Part II."\n5. Leonardo DiCaprio - A four-time Academy Award nominee and one-time winner, DiCaprio has had a successful career in both blockbusters and independent films.\n\nThese are just a few examples of highly acclaimed American actors, and there are many other talented actors who could be considered for this title.'], 'meta': {'RequestId': 'ed9c8566-0b13-4c08-ba72-c88be1aecd02', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Mon, 28 Apr 2025 11:00:15 GMT', 'content-type': 'application/json', 'content-length': '1322', 'connection': 'keep-alive', 'x-amzn-requestid': 'ed9c8566-0b13-4c08-ba72-c88be1aecd02', 'x-amzn-bedrock-invocation-latency': '7065', 'x-amzn-bedrock-output-token-count': '323', 'x-amzn-bedrock-input-token-count': '16'}, 'RetryAttempts': 0}}
9193
```
9294

9395
### AmazonBedrockTextEmbedder and AmazonBedrockDocumentEmbedder
9496

95-
These two components can be used to compute embeddings for text and Documents respectively.
96-
Supported models are "amazon.titan-embed-text-v1", "cohere.embed-english-v3" and "cohere.embed-multilingual-v3".
97+
These two components can compute embeddings for text and Documents, respectively.
98+
The supported models are "amazon.titan-embed-text-v1", "amazon.titan-embed-text-v2:0", "cohere.embed-english-v3," and "cohere.embed-multilingual-v3."
9799

98100
See them in action:
99101

0 commit comments

Comments
 (0)