Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 2ea8b28

Browse files
committed
Add batch processing
1 parent a49c2fc commit 2ea8b28

File tree

1 file changed

+45
-1
lines changed
  • content/en/user-guide/aws/bedrock

1 file changed

+45
-1
lines changed

content/en/user-guide/aws/bedrock/index.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ We will demonstrate how to use Bedrock by following these steps:
2121
1. Listing available foundation models
2222
2. Invoking a model for inference
2323
3. Using the conversation API
24+
4. Using batch processing
2425

2526
### Pre-warming the Bedrock engine
2627

@@ -84,7 +85,50 @@ $ awslocal bedrock-runtime converse \
8485
}]'
8586
{{< / command >}}
8687

88+
### Model Invocation Batch Processing
89+
90+
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.
91+
92+
First, you need to create a `JSONL` file that contains all your prompts:
93+
94+
{{< command >}}
95+
$ cat batch_input.jsonl
96+
{"prompt": "Tell me a quick fact about Vienna.", "max_tokens": 50, "temperature": 0.5}
97+
{"prompt": "Tell me a quick fact about Zurich.", "max_tokens": 50, "temperature": 0.5}
98+
{"prompt": "Tell me a quick fact about Las Vegas.", "max_tokens": 50, "temperature": 0.5}
99+
{{< / command >}}
100+
101+
Then, you need to define buckets for the input as well as the output and upload the file in the input bucket:
102+
103+
{{< command >}}
104+
$ awslocal s3 mb s3://in-bucket
105+
make_bucket: in-bucket
106+
107+
$ awslocal s3 cp batch_input.jsonl s3://in-bucket
108+
upload: ./batch_input.jsonl to s3://in-bucket/batch_input.jsonl
109+
110+
$ awslocal s3 mb s3://out-bucket
111+
make_bucket: out-bucket
112+
{{< / command >}}
113+
114+
Afterwards you can run the invocation job like this:
115+
116+
{{< command >}}
117+
$ awslocal bedrock create-model-invocation-job \
118+
--job-name "my-batch-job" \
119+
--model-id "mistral.mistral-small-2402-v1:0" \
120+
--role-arn "arn:aws:iam::123456789012:role/MyBatchInferenceRole" \
121+
--input-data-config '{"s3InputDataConfig": {"s3Uri": "s3://in-bucket"}}' \
122+
--output-data-config '{"s3OutputDataConfig": {"s3Uri": "s3://out-bucket"}}'
123+
{
124+
"jobArn": "arn:aws:bedrock:us-east-1:000000000000:model-invocation-job/12345678"
125+
}
126+
{{< / command >}}
127+
128+
The results will be at the S3 URL `s3://out-bucket/12345678/batch_input.jsonl.out`
129+
87130
## Limitations
88131

89-
* LocalStack Bedrock currently only officially supports text-based models.
132+
* At this point, we have only tested text-based models in LocalStack.
133+
Other models available with Ollama might also work, but are not officially supported by the Bedrock implementation.
90134
* Currently, GPU models are not supported by the LocalStack Bedrock implementation.

0 commit comments

Comments
 (0)