5 mins read

Mistral AI models now available on Amazon Bedrock

Spoken by Polly

We announced this last week Mistral AI models come to Amazon Bedrock. In this post, we’ve explained some reasons why Mistral AI models could be a good fit for you. Mistral AI offers a balance of cost and performance, fast inference speed, transparency and trust, and is accessible to a wide range of users.

Today we are pleased to announce the availability of two powerful Mistral AI models, Mistral 7B and Mixtral 8x7B Amazon bedrock. Mistral AI is the seventh base model provider to offer state-of-the-art models in Amazon Bedrock, joining other leading AI companies such as AI21 Labs, Anthropocene, connections, Meta, Stability AIAnd Amazon. This integration gives you the flexibility to select optimal, high-performance foundation models in Amazon Bedrock.

Mistral 7B is the first base model of Mistral AI that supports English text generation tasks with natural coding capabilities. It is optimized for low latency with low memory footprint and high throughput for its size. Mixtral 8x7B is a popular, high-quality, sparse Mixture of Experts (MoE) model that is ideal for text summarization, Q&A, text classification, text completion, and code generation.

Here’s a quick look at Mistral AI models on Amazon Bedrock:

Getting started with Mistral AI models
To get started with Mistral AI models in Amazon Bedrock, you first need to get access to the models. On the Amazon Bedrock console, select model access, and then select Manage model access. Next, select Mistral AI Models and then Request model access.

Once you have access to select Mistral AI models, you can test the models using your prompts Chat or text in the playgrounds Section.

Programmatically interacting with Mistral AI models
You can also use AWS Command Line Interface (CLI) And AWS Software Development Kit (SDK) to make various calls via Amazon Bedrock APIs. Below is sample code in Python that interacts with Amazon Bedrock Runtime APIs with AWS SDK:

import boto3
import json

bedrock = boto3.client(service_name="bedrock-runtime")

prompt = "<s>[INST] INSERT YOUR PROMPT HERE [/INST]"

body = json.dumps({
    "prompt": prompt,
    "max_tokens": 512,
    "top_p": 0.8,
    "temperature": 0.5,
})

modelId = "mistral.mistral-7b-instruct-v0:2"

accept = "application/json"
contentType = "application/json"

response = bedrock.invoke_model(
    body=body,
    modelId=modelId,
    accept=accept,
    contentType=contentType
)

print(json.loads(response.get('body').read()))

Mistral AI models in action
By integrating your application with the AWS SDK to call Mistral AI models using Amazon Bedrock, you can unlock opportunities to implement various use cases. Here are some of my personal favorite use cases with Mistral AI models with example prompts. Further examples can be found on Prompt features from the Mistral AI documentation page.

Text summary — Mistral AI models extract the essence of long articles so you can quickly grasp important ideas and key messages.

You are a summarization system. In clear and concise language, provide three short summaries in bullet points of the following essay.

# Essay:
{insert essay text here}

personalization — The core AI capabilities of language understanding, reasoning and learning enable Mistral AI models to personalize responses with more human-quality text. The accuracy, explanatory capabilities and versatility of Mistral AI models make them useful in personalization tasks as they can deliver content that is precisely tailored to individual users.

You are a mortgage lender customer service bot, and your task is to create personalized email responses to address customer questions. Answer the customer's inquiry using the provided facts below. Ensure that your response is clear, concise, and directly addresses the customer's question. Address the customer in a friendly and professional manner. Sign the email with "Lender Customer Support."

# Facts
<INSERT FACTS AND INFORMATION HERE>

# Email
{insert customer email here}

Code completion — Mistral AI models have exceptional understanding of natural language and code-related tasks, which is critical for projects that need to balance computer code and regular language. Mistral AI models can help generate code snippets, suggest bug fixes, and optimize existing code, speeding up your development process.

[INST] You are a code assistant. Your task is to generate a 5 valid JSON object based on the following properties:
name: 
lastname: 
address: 
Just generate the JSON object without explanations:
[/INST]

Things you need to know
Here is some additional information for you:

  • Availability – Mistral AI’s Mixtral 8x7B and Mistral 7B models on Amazon Bedrock are available in the US West (Oregon) region.
  • Dive Deep into Mistral 7B and Mixtral 8x7B – If you would like to learn more about Mistral AI models on Amazon Bedrock, you might also like this article titled “Mistral AI – Winds of Change” prepared by my colleague, Mike.

Available now
Mistral AI models are available today in Amazon Bedrock and we can’t wait to see what you’ll build. Start with a visit Mistral AI on Amazon Bedrock.

Have fun building,
Donny