AWS Bedrock
You can deploy the following Mistral AI models on the AWS Bedrock service:
- Mistral 7B Instruct
- Mixtral 8x7B Instruct
- Mistral Small
- Mistral Large
This page provides a straightforward guide on how to get started on using Mistral Large as an AWS Bedrock foundational model.
Pre-requisites
In order to query the model you will need:
- Access to an AWS account within a region that supports the AWS Bedrock service and offers access to Mistral Large: see the AWS documentation for model availability per region.
- An AWS IAM principal (user, role) with sufficient permissions, see the AWS documentation for more details.
- Access to the Mistral AI models enabled from the AWS Bedrock home page, see the AWS documentation for more details.
- A local code environment set up with the relevant AWS SDK components, namely:
- the AWS CLI: see the AWS documentation for the installation procedure.
- the
boto3
Python library: see the AWS documentation for the installation procedure.
Querying the model
Before starting, make sure to properly configure the authentication credentials for your development environment. The AWS documentation provides an in-depth explanation on the required steps.
- Python
- CLI
import boto3
MISTRAL_LARGE_BEDROCK_ID = "mistral.mistral-large-2402-v1:0"
AWS_REGION = "eu-west-3"
bedrock_client = boto3.client(service_name='bedrock-runtime', region_name=AWS_REGION)
messages = [{"role": "user", "content": [{"text": "What is the best French cheese?"}]}]
temperature = 0.0
max_tokens = 1024
params = {"modelId": MISTRAL_LARGE_BEDROCK_ID,
"messages": messages,
"inferenceConfig": {"temperature": temperature,
"maxTokens": max_tokens}}
resp = bedrock_client.converse(**params)
print(resp["output"]["message"]["content"][0]["text"])
aws bedrock-runtime invoke-model \
--model-id "mistral.mistral-large-2402-v1:0" \
--body '{"prompt": "What is the best French cheese?", "max_tokens": 512, "top_p": 0.8, "temperature": 0.5}' \
resp.json \
--cli-binary-format raw-in-base64-out
Going further
You can find a more detailed user guide on the AWS documentation on inference requests for Mistral models.
For more advanced examples, you can also check out the following notebooks:
- Bedrock function calling with Mistral models
- Advanced RAG pipeline for Mistral models with Q&A Automation and Model Evaluation using LlamaIndex and Ragas
- Transitioning from OpenAI to Mistral: a guide
- Abstract document summarization with Langchain using Mistral Large on Bedrock
- Advanced multi-chain routing with Langchain and Mistral models
- Mistral Large prompting: getting started
- Getting started with Mistral Tool Use and the Converse API