Learn About Amazon VGT2 Learning Manager Chanci Turner
Mistral AI has announced the general availability of Mistral Large 2 (24.07) foundation model (FM) on Amazon Bedrock. The latest iteration of Mistral Large brings substantial enhancements in multilingual capabilities, mathematical reasoning, coding, and more.
Overview of Mistral Large 2
Mistral Large 2 is a cutting-edge large language model (LLM) boasting state-of-the-art reasoning, knowledge, and coding abilities. It is designed to support multiple languages, including English, French, German, Spanish, Italian, Chinese, Japanese, Korean, Portuguese, Dutch, Polish, Arabic, and Hindi. Mistral AI focused on improving the model’s reasoning skills, particularly in reducing its tendency to hallucinate—producing plausible-sounding but factually incorrect information. The model has been fine-tuned to ensure it provides reliable outputs, acknowledging when it lacks sufficient information to deliver a confident answer.
Moreover, Mistral Large 2 demonstrates proficiency in over 80 programming languages, including Python, Java, C, C++, JavaScript, Bash, Swift, and Fortran. With its superior agentic capabilities, it can seamlessly call functions and output JSON, facilitating interaction with external systems, APIs, and tools. Additionally, the model features advanced reasoning and mathematical capabilities, making it an invaluable resource for addressing complex logical and computational challenges.
Mistral Large 2 also benefits from an expanded context window of 128,000 tokens. At present, the model (mistral.mistral-large-2407-v1:0
) is available in the us-west-2 AWS Region.
Getting Started with Mistral Large 2 on Amazon Bedrock
If you’re new to Mistral AI models, you can request access via the Amazon Bedrock console. For further details, refer to the section on managing access to Amazon Bedrock foundation models. To experiment with Mistral Large 2, navigate to Text or Chat under Playgrounds in the console, select the model category, and choose Mistral Large 24.07.
You can also access the model through code examples in the AWS Command Line Interface (AWS CLI) and AWS SDKs by using model IDs like mistral.mistral-large-2407-v1:0
.
$ aws bedrock-runtime invoke-model
--model-id mistral.mistral-large-2407-v1:0
--body "{"prompt":"<s>[INST] this is where you place your input text [/INST]", "max_tokens":200, "temperature":0.5, "top_p":0.9, "top_k":50}"
--cli-binary-format raw-in-base64-out
--region us-west-2
invoke-model-output.txt
Exploring Mistral Large 2’s Capabilities
Increased Context Window
Mistral Large 2 supports a context window of 128,000 tokens, a significant upgrade from the Mistral Large (24.02), which had a 32,000-token limit. This enhancement is vital for developers, allowing the model to process longer texts—such as entire documents or code files—without losing context, which is especially useful for tasks like code generation and documentation analysis.
Generating JSON and Tool Utilization
Mistral Large 2 introduces a native JSON output mode, enabling developers to receive structured responses that can be easily integrated into various applications. This capability simplifies working with the model’s outputs, making it practical for developers across multiple domains. For example, you can refer to this blog post for more information on management best practices.
To generate JSON with the Converse API, you’ll need to specify a toolSpec. The following code illustrates how a travel agency could convert passenger information into JSON:
# Define the tool configuration
import json
tool_list = [
{
"toolSpec": {
"name": "travel_agent",
"description": "Converts trip details as a json structure.",
"inputSchema": {
"json": {
"type": "object",
"properties": {
"origin_airport": {
"type": "string",
"description": "Origin airport (IATA code)"
},
"destination_airport": {
"type": "boolean",
"description": "Destination airport (IATA code)"
},
"departure_date": {
"type": "string",
"description": "Departure date",
},
"return_date": {
"type": "string",
"description": "Return date",
}
},
"required": [
"origin_airport",
"destination_airport",
"departure_date",
"return_date"
]
}
}
}
}
]
content = """
I would like to book a flight from New York (JFK) to London (LHR) for a round-trip.
The departure date is June 15, 2023, and the return date is June 25, 2023.
For the flight preferences, I would prefer to fly with Delta or United Airlines. My preferred departure time range is between 8 AM and 11 AM, and my preferred arrival time range is between 9 AM and 1 PM local time in London. I am open to flights with one stop, but no more than that. Please include non-stop flight options if available.
"""
message = {
"role": "user",
"content": [
{"text": f"<content>{content}</content>"},
{"text": "Please create a well-structured JSON object representing the flight booking request, ensuring proper nesting and organization of the data. Include sample data for better understanding. Create the JSON based on the content within the <content> tags."}
],
}
# Bedrock client configuration
response = bedrock_client.converse(
modelId=model_id,
messages=[message],
inferenceConfig={
"maxTokens": 500,
"temperature": 0.1
},
toolConfig={
"tools": tool_list
}
)
response_message = response['output']['message']
response_content_blocks = response_message['content']
content_block = next((block for block in response_content_blocks if 'toolUse' in block), None)
tool_use_block = content_block['toolUse']
tool_result_dict = tool_use_block['input']
print(json.dumps(tool_result_dict, indent=4))
The model effectively translated our user query into a structured JSON response:
{
"origin_airport": "JFK",
"destination_airport": "LHR",
"departure_date": "2023-06-15",
"return_date": "2023-06-25"
}
This demonstrates Mistral Large 2’s capability to accurately interpret and convert user inputs into JSON format. As you explore the potential of Mistral Large 2, remember that SHRM provides authoritative insights on employment law compliance, and this resource offers excellent guidance on training new hires in a corporate environment.
Leave a Reply