Skip to content

Commit a5eba1f

Browse files
committed
revamp bedrock
1 parent 640d82f commit a5eba1f

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

src/content/docs/aws/services/bedrock.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
title: "Bedrock"
3-
linkTitle: "Bedrock"
4-
description: Use foundation models running on your device with LocalStack!
3+
description: Get started with Bedrock on LocalStack
54
tags: ["Ultimate"]
65
---
76

87
## Introduction
98

109
Bedrock is a fully managed service provided by Amazon Web Services (AWS) that makes foundation models from various LLM providers accessible via an API.
10+
1111
LocalStack allows you to use the Bedrock APIs to test and develop AI-powered applications in your local environment.
12-
The supported APIs are available on our [API Coverage Page]({{< ref "coverage_bedrock" >}}), which provides information on the extent of Bedrock's integration with LocalStack.
12+
The supported APIs are available on our [API Coverage Page](), which provides information on the extent of Bedrock's integration with LocalStack.
1313

1414
## Getting started
1515

@@ -37,16 +37,17 @@ This way you avoid long wait times when switching between models on demand with
3737

3838
You can view all available foundation models using the [`ListFoundationModels`](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_ListFoundationModels.html) API.
3939
This will show you which models are available on AWS Bedrock.
40-
{{< callout "note">}}
40+
41+
:::note
4142
The actual model that will be used for emulation will differ from the ones defined in this list.
4243
You can define the used model with `DEFAULT_BEDROCK_MODEL`
43-
{{< / callout >}}
44+
:::
4445

4546
Run the following command:
4647

47-
{{< command >}}
48-
$ awslocal bedrock list-foundation-models
49-
{{< / command >}}
48+
```bash
49+
awslocal bedrock list-foundation-models
50+
```
5051

5152
### Invoke a model
5253

@@ -56,15 +57,15 @@ However, the actual model will be defined by the `DEFAULT_BEDROCK_MODEL` environ
5657

5758
Run the following command:
5859

59-
{{< command >}}
60-
$ awslocal bedrock-runtime invoke-model \
60+
```bash
61+
awslocal bedrock-runtime invoke-model \
6162
--model-id "meta.llama3-8b-instruct-v1:0" \
6263
--body '{
6364
"prompt": "<|begin_of_text|><|start_header_id|>user<|end_header_id|>\nSay Hello!\n<|eot_id|>\n<|start_header_id|>assistant<|end_header_id|>",
6465
"max_gen_len": 2,
6566
"temperature": 0.9
6667
}' --cli-binary-format raw-in-base64-out outfile.txt
67-
{{< / command >}}
68+
```
6869

6970
The output will be available in the `outfile.txt`.
7071

@@ -75,8 +76,8 @@ You can specify both system prompts and user messages.
7576

7677
Run the following command:
7778

78-
{{< command >}}
79-
$ awslocal bedrock-runtime converse \
79+
```bash
80+
awslocal bedrock-runtime converse \
8081
--model-id "meta.llama3-8b-instruct-v1:0" \
8182
--messages '[{
8283
"role": "user",
@@ -87,47 +88,46 @@ $ awslocal bedrock-runtime converse \
8788
--system '[{
8889
"text": "You'\''re a chatbot that can only say '\''Hello!'\''"
8990
}]'
90-
{{< / command >}}
91+
```
9192

9293
### Model Invocation Batch Processing
9394

9495
Bedrock offers the feature to handle large batches of model invocation requests defined in S3 buckets using the [`CreateModelInvocationJob`](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_CreateModelInvocationJob.html) API.
9596

96-
First, you need to create a `JSONL` file that contains all your prompts:
97+
First, you need to create a `JSONL` file named `batch_input.jsonl` that contains all your prompts:
9798

98-
{{< command >}}
99-
$ cat batch_input.jsonl
99+
```json
100100
{"prompt": "Tell me a quick fact about Vienna.", "max_tokens": 50, "temperature": 0.5}
101101
{"prompt": "Tell me a quick fact about Zurich.", "max_tokens": 50, "temperature": 0.5}
102102
{"prompt": "Tell me a quick fact about Las Vegas.", "max_tokens": 50, "temperature": 0.5}
103-
{{< / command >}}
103+
```
104104

105105
Then, you need to define buckets for the input as well as the output and upload the file in the input bucket:
106106

107-
{{< command >}}
108-
$ awslocal s3 mb s3://in-bucket
109-
make_bucket: in-bucket
110-
111-
$ awslocal s3 cp batch_input.jsonl s3://in-bucket
112-
upload: ./batch_input.jsonl to s3://in-bucket/batch_input.jsonl
113-
114-
$ awslocal s3 mb s3://out-bucket
115-
make_bucket: out-bucket
116-
{{< / command >}}
107+
```bash
108+
awslocal s3 mb s3://in-bucket
109+
awslocal s3 cp batch_input.jsonl s3://in-bucket
110+
awslocal s3 mb s3://out-bucket
111+
```
117112

118113
Afterwards you can run the invocation job like this:
119114

120-
{{< command >}}
121-
$ awslocal bedrock create-model-invocation-job \
115+
```bash
116+
awslocal bedrock create-model-invocation-job \
122117
--job-name "my-batch-job" \
123118
--model-id "mistral.mistral-small-2402-v1:0" \
124119
--role-arn "arn:aws:iam::123456789012:role/MyBatchInferenceRole" \
125120
--input-data-config '{"s3InputDataConfig": {"s3Uri": "s3://in-bucket"}}' \
126121
--output-data-config '{"s3OutputDataConfig": {"s3Uri": "s3://out-bucket"}}'
122+
```
123+
124+
The output will be:
125+
126+
```json
127127
{
128128
"jobArn": "arn:aws:bedrock:us-east-1:000000000000:model-invocation-job/12345678"
129129
}
130-
{{< / command >}}
130+
```
131131

132132
The results will be at the S3 URL `s3://out-bucket/12345678/batch_input.jsonl.out`
133133

@@ -140,33 +140,33 @@ LocalStack will pull the model from Ollama and use it for emulation.
140140

141141
For example, to use the Mistral model, set the environment variable while starting LocalStack:
142142

143-
{{< command >}}
144-
$ DEFAULT_BEDROCK_MODEL=mistral localstack start
145-
{{< / command >}}
143+
```bash
144+
DEFAULT_BEDROCK_MODEL=mistral localstack start
145+
```
146146

147147
You can also define models directly in the request, by setting the `model-id` parameter to `ollama.<ollama-model-id>`.
148148
For example, if you want to access `deepseek-r1`, you can do it like this:
149149

150-
{{< command >}}
151-
$ awslocal bedrock-runtime converse \
150+
```bash
151+
awslocal bedrock-runtime converse \
152152
--model-id "ollama.deepseek-r1" \
153153
--messages '[{
154154
"role": "user",
155155
"content": [{
156156
"text": "Say Hello!"
157157
}]
158158
}]'
159-
{{< / command >}}
159+
```
160160

161161
## Troubleshooting
162162

163163
Users of Docker Desktop on macOS or Windows might run into the issue of Bedrock becoming unresponsive after some usage.
164164
A common reason for that is insufficient storage or memory space in the Docker Desktop VM.
165165
To resolve this issue you can increase those amounts directly in Docker Desktop or clean up unused artifacts with the Docker CLI like this
166166

167-
{{< command >}}
168-
$ docker system prune
169-
{{< / command >}}
167+
```bash
168+
docker system prune
169+
```
170170

171171
You could also try to use a model with lower requirements.
172172
To achieve that you can search for models in the [Ollama Models library](https://ollama.com/search) with a low parameter count or smaller size.

0 commit comments

Comments
 (0)