亚马逊AWS官方博客

Mistral AI 模型现已在 Amazon Bedrock 上推出



上周,我们宣布了 Mistral AI 模型即将登陆 Amazon Bedrock 的消息。在那篇文章中,我们详细阐述了 Mistral AI 模型是您的理想之选的几个原因。Mistral AI 在成本和性能、快速推理速度、透明度和可信度之间取得了平衡,并且可供广泛的用户使用。

今天,我们很高兴地宣布,两款高性能的 Mistral AI 模型,即 Mistral 7B 和 Mixtral 8x7B,现已在 Amazon Bedrock 上推出。Mistral AI 是第七家在 Amazon Bedrock 中提供尖端模型的基础模型提供商,与 AI21 LabsAnthropicCohereMetaStability AIAmazon 这些领先的 AI 公司并肩。这一集成使您可以灵活地在 Amazon Bedrock 中选择最佳的高性能基础模型。

Mistral 7B 是 Mistral AI 推出的首个基础模型,支持英语文本生成任务并具备自然编码能力。它为实现低延迟进行过优化,并且相对其规模,该模型对内存的要求较低,可提供高吞吐量。Mixtral 8x7B 是一种受欢迎的优质稀疏专家混合(MoE)模型,非常适用于文本摘要、问题解答、文本分类、文本完善和代码补全。

下面,我们来简单了解一下 Amazon Bedrock 上的 Mistral AI 模型:

Mistral AI 模型入门
要开始在 Amazon Bedrock 中使用 Mistral AI 模型,首先需要访问这些模型。在 Amazon Bedrock 控制台上,选择模型访问权限,然后选择管理模型访问权限。接下来,选择 Mistral AI 模型,然后选择请求模型访问权限

获得选定 Mistral AI 模型的访问权限后,您可以在 Playgrounds 部分使用聊天文本根据提示测试模型。

以编程方式与 Mistral AI 模型交互
您还可以通过 AWS 命令行界面(CLI)AWS 软件开发工具包(SDK) 使用 Amazon Bedrock API 进行各种调用。以下是使用 AWS 开发工具包与 Amazon Bedrock 运行时系统 API 交互的 Python 示例代码:

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 模型的实际应用
通过将您的应用程序与 AWS 开发工具包集成,从而使用 Amazon Bedrock 来调用 Mistral AI 模型,您可以开启实施各种用例的可能性。以下是我个人最喜欢的一些使用带有示例提示的 Mistral AI 模型的用例。您可以从 Mistral AI 文档页面查看更多关于提示功能的示例。

文本摘要 — Mistral AI 模型可以从长篇文章中提取要点,让您可以快速理解关键思想和核心信息。

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}

个性化 — Mistral AI 模型的核心 AI 功能(理解语言、推理和学习)使其能够使用更加人性化的文本提供个性化的回答。Mistral AI 模型的准确性、解释能力和多功能性使其适用于个性化任务,因为它们可以提供与个体用户密切相关的内容。

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}

代码补全 — Mistral AI 模型对自然语言和与代码相关的任务有出色的理解能力,这对于需要同时处理计算机代码和常规语言的项目来说至关重要。Mistral AI 模型可以帮助生成代码片段、提供 bug 修复建议和优化现有代码,从而加快开发过程。

[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]

您必须了解的一些事项
以下是一些其他信息供您参考:

  • 可用性 — Amazon Bedrock 中的 Mistral AI Mixtral 8x7B 和 Mistral 7B 型号现已在美国西部(俄勒冈州)区域推出。
  • 深入了解 Mistral 7B 和 Mixtral 8x7B — 如果您想进一步了解 Amazon Bedrock 上的 Mistral AI 模型,还可以参阅我的同事 Mike 撰写的这篇题为 Mistral AI – Winds of Change(Mistral AI – 变革之风)的文章。

现已推出
Mistral AI 模型现已在 Amazon Bedrock 中推出,我们热切期待您通过该模型构建内容。立即访问 Amazon Bedrock 上的 Mistral AI 开始构建吧!

祝大家构建顺利。
Donnie