Enfrente tareas complejas de razonamiento con Mistral Large, ahora disponible en Amazon Bedrock.

Por Veliswa Boya.

Publicado el 02 de abril de 2024.

Revisa la publicación original aquí.

Actualización 3/4/2024: Hemos revisado esta publicación para incluir información sobre la nueva disponibilidad de la Región de París para Amazon Bedrock y agregar un nuevo enlace de recursos con orientación sobre solicitudes de inferencia.

El mes pasado, anunciamos la disponibilidad de dos modelos de IA de alto rendimiento de Mistral, Mistral 7B y Mixtral 8x7B, en Amazon Bedrock. Mistral 7B, como el modelo base inicial de Mistral, es compatible con tareas de generación de texto en inglés y ofrece capacidades avanzadas de codificación natural. Por su parte, Mixtral 8x7B es un modelo popular basado en el enfoque Mixture-of-Experts (MoE), reconocido por su alta calidad y eficiencia, ideal para resúmenes de texto, preguntas y respuestas, clasificación de texto, finalización de texto y generación de código.

Hoy anunciamos la disponibilidad de Mistral Large en Amazon Bedrock. Este modelo es perfecto para abordar tareas complejas que requieren un razonamiento avanzado o un enfoque altamente especializado, como la generación de texto sintético o la creación de código.

En la AWS Summit de París de hoy, también comunicamos que Amazon Bedrock ahora está disponible en la región AWS de París, ampliando aún más las emocionantes novedades.

S4E | Solutions for Everyone - Chile - 1

Lo que necesitas saber sobre Mistral Large:

  • Habla con fluidez nativa inglés, francés, español, alemán e italiano, ofreciendo una comprensión detallada de la gramática y el contexto cultural.
  • Cuenta con una ventana de contexto de tokens de 32K, lo que permite extraer información precisa de documentos extensos.
  • Su seguimiento preciso de instrucciones facilita el diseño de políticas de moderación. Por ejemplo, el equipo de Mistral AI lo utilizó para configurar la moderación a nivel de sistema en su demostrador de asistente beta, Chat. La interacción inicial con modelos de lenguaje grandes (LLM) se centra en la creación de indicaciones, lo que convierte el arte de diseñarlas en un factor clave para obtener respuestas deseadas. En esta guía de Amazon Bedrock, se incluyen detalles adicionales sobre cómo realizar solicitudes de inferencia a los modelos de Mistral AI.

Primeros pasos con Mistral Large

Para empezar a usar Mistral Large en Bedrock, primero debe habilitar el acceso al modelo. En la consola de Amazon Bedrock, seleccione Acceso al modelo y, luego, Administrar acceso al modelo. A continuación, seleccione Mistral Large y haga clic en Guardar cambios.

Acceso al modelo Mistral, captura de pantalla grande 2

Una vez que tengas acceso a Mistral Large, podrás usar el modelo en Bedrock. Actualiza la tabla de modelos base para ver el estado actualizado.

Para ver el aspecto de razonamiento complejo de Mistral Large en acción, probé el siguiente mensaje en la sección Playgrounds:

S4E | Solutions for Everyone - Chile - 2

Prompt

<s>[INST]Calculate the difference in payment dates between the two customers whose payment amounts are closest to each other in the given dataset: '{ "transaction_id":{"0":"T1001","1":"T1002","2":"T1003","3":"T1004","4":"T1005"}, "customer_id":{"0":"C001","1":"C002","2":"C003","3":"C002","4":"C001"}, "payment_amount":{"0":125.5,"1":89.99,"2":120.0,"3":54.3,"4":210.2}, "payment_date":{"0":"2021-10-05","1":"2021-10-06","2":"2021-10-07","3":"2021-10-05","4":"2021-10-08"}, "payment_status":{"0":"Paid","1":"Unpaid","2":"Paid","3":"Paid","4":"Pending"} }'[/INST]

Output

To find the difference in payment dates between the two customers whose payment amounts are closest to each other, we first need to parse the given dataset. We can use the pandas library in Python to convert the dataset into a DataFrame for easier manipulation. Here's the Python code to achieve this: ```python import pandas as pd from datetime import datetime # Given dataset data = { "transaction_id": ["T1001", "T1002", "T1003", "T1004", "T1005"], "customer_id": ["C001", "C002", "C003", "C002", "C001"], "payment_amount": [125.5, 89.99, 120.0, 54.3, 210.2], "payment_date": ["2021-10-05", "2021-10-06", "2021-10-07", "2021-10-05", "2021-10-08"], "payment_status": ["Paid", "Unpaid", "Paid", "Paid", "Pending"] } # Convert dataset to DataFrame df = pd.DataFrame(data) # Convert payment_date column to datetime format df["payment_date"] = pd.to_datetime(df["payment_date"]) # Calculate the difference between all pairs of payment amounts amount_diffs = df["payment_amount"].sub(df["payment_amount"], axis=0).abs().combine_first(df["payment_amount"].sub(df["payment_amount"], axis=1).abs()) # Find the minimum difference min_diff = amount_diffs.min().min() # Find the indices of the two customers with the closest payment amounts closest_indices = amount_diffs[amount_diffs == min_diff].stack().index.tolist() # Get the customer indices customer_index1, customer_index2 = closest_indices[0] # Get the payment dates

Anteriormente en esta publicación mencioné que Mistral Large habla con fluidez varios idiomas y tiene una comprensión matizada de la gramática y el contexto cultural. Puse a prueba la comprensión del idioma francés por parte del modelo:

Prompt

<s>[INST]Lequel est le plus lourd une livre de fer ou un kilogramme de plume[/INST]

Output

Une livre de fer pèse environ 0.453 kilogramme, tandis qu'un kilogramme de plumes pèse 1 kilogramme. Donc, un kilogramme de plumes est plus lourd qu'une livre de fer. Cependant, il est important de noter que le volume occupé par un kilogramme de plumes serait beaucoup plus grand que le volume occupé par une livre de fer, car les plumes sont beaucoup moins denses que le fer.

Interactuar programáticamente con Mistral Large

También puede utilizar la interfaz de línea de comandos (CLI) de AWS y el kit de desarrollo de software (SDK) de AWS para realizar múltiples llamadas a través de las API de Amazon Bedrock. A continuación, se presenta un ejemplo de código en Python que interactúa con las API de Amazon Bedrock Runtime utilizando el SDK de AWS. Si en el mensaje especifica que “Solo responderá con un objeto JSON con la clave X, Y y Z”, puede emplear la salida en formato JSON para tareas posteriores más sencillas:

Python

<s>[INST]You are a summarization system that can provide summaries with associated confidence 
scores. In clear and concise language, provide three short summaries of the following essay, 
along with their confidence scores. You will only respond with a JSON object with the key Summary 
and Confidence. Do not provide explanations.[/INST]
# Essay: 
The generative artificial intelligence (AI) revolution is in full swing, and customers of all sizes and across industries are taking advantage of this transformative technology to reshape their businesses. From reimagining workflows to make them more intuitive and easier to enhancing decision-making processes through rapid information synthesis, generative AI promises to redefine how we interact with machines. It’s been amazing to see the number of companies launching innovative generative AI applications on AWS using Amazon Bedrock. Siemens is integrating Amazon Bedrock into its low-code development platform Mendix to allow thousands of companies across multiple industries to create and upgrade applications with the power of generative AI. Accenture and Anthropic are collaborating with AWS to help organizations—especially those in highly-regulated industries like healthcare, public sector, banking, and insurance—responsibly adopt and scale generative AI technology with Amazon Bedrock. This collaboration will help organizations like the District of Columbia Department of Health speed innovation, improve customer service, and improve productivity, while keeping data private and secure. Amazon Pharmacy is using generative AI to fill prescriptions with speed and accuracy, making customer service faster and more helpful, and making sure that the right quantities of medications are stocked for customers.

To power so many diverse applications, we recognized the need for model diversity and choice for generative AI early on. We know that different models excel in different areas, each with unique strengths tailored to specific use cases, leading us to provide customers with access to multiple state-of-the-art large language models (LLMs) and foundation models (FMs) through a unified service: Amazon Bedrock. By facilitating access to top models from Amazon, Anthropic, AI21 Labs, Cohere, Meta, Mistral AI, and Stability AI, we empower customers to experiment, evaluate, and ultimately select the model that delivers optimal performance for their needs.

Announcing Mistral Large on Amazon Bedrock
Today, we are excited to announce the next step on this journey with an expanded collaboration with Mistral AI. A French startup, Mistral AI has quickly established itself as a pioneering force in the generative AI landscape, known for its focus on portability, transparency, and its cost-effective design requiring fewer computational resources to run. We recently announced the availability of Mistral 7B and Mixtral 8x7B models on Amazon Bedrock, with weights that customers can inspect and modify. Today, Mistral AI is bringing its latest and most capable model, Mistral Large, to Amazon Bedrock, and is committed to making future models accessible to AWS customers. Mistral AI will also use AWS AI-optimized AWS Trainium and AWS Inferentia to build and deploy its future foundation models on Amazon Bedrock, benefitting from the price, performance, scale, and security of AWS. Along with this announcement, starting today, customers can use Amazon Bedrock in the AWS Europe (Paris) Region. At launch, customers will have access to some of the latest models from Amazon, Anthropic, Cohere, and Mistral AI, expanding their options to support various use cases from text understanding to complex reasoning.

Mistral Large boasts exceptional language understanding and generation capabilities, which is ideal for complex tasks that require reasoning capabilities or ones that are highly specialized, such as synthetic text generation, code generation, Retrieval Augmented Generation (RAG), or agents. For example, customers can build AI agents capable of engaging in articulate conversations, generating nuanced content, and tackling complex reasoning tasks. The model’s strengths also extend to coding, with proficiency in code generation, review, and comments across mainstream coding languages. And Mistral Large’s exceptional multilingual performance, spanning French, German, Spanish, and Italian, in addition to English, presents a compelling opportunity for customers. By offering a model with robust multilingual support, AWS can better serve customers with diverse language needs, fostering global accessibility and inclusivity for generative AI solutions.

By integrating Mistral Large into Amazon Bedrock, we can offer customers an even broader range of top-performing LLMs to choose from. No single model is optimized for every use case, and to unlock the value of generative AI, customers need access to a variety of models to discover what works best based for their business needs. We are committed to continuously introducing the best models, providing customers with access to the latest and most innovative generative AI capabilities.

“We are excited to announce our collaboration with AWS to accelerate the adoption of our frontier AI technology with organizations around the world. Our mission is to make frontier AI ubiquitous, and to achieve this mission, we want to collaborate with the world’s leading cloud provider to distribute our top-tier models. We have a long and deep relationship with AWS and through strengthening this relationship today, we will be able to provide tailor-made AI to builders around the world.”

– Arthur Mensch, CEO at Mistral AI.

Customers appreciate choice
Since we first announced Amazon Bedrock, we have been innovating at a rapid clip—adding more powerful features like agents and guardrails. And we’ve said all along that more exciting innovations, including new models will keep coming. With more model choice, customers tell us they can achieve remarkable results:

“The ease of accessing different models from one API is one of the strengths of Bedrock. The model choices available have been exciting. As new models become available, our AI team is able to quickly and easily evaluate models to know if they fit our needs. The security and privacy that Bedrock provides makes it a great choice to use for our AI needs.”

– Jamie Caramanica, SVP, Engineering at CS Disco.

“Our top priority today is to help organizations use generative AI to support employees and enhance bots through a range of applications, such as stronger topic, sentiment, and tone detection from customer conversations, language translation, content creation and variation, knowledge optimization, answer highlighting, and auto summarization. To make it easier for them to tap into the potential of generative AI, we’re enabling our users with access to a variety of large language models, such as Genesys-developed models and multiple third-party foundational models through Amazon Bedrock, including Anthropic’s Claude, AI21 Labs’s Jurrassic-2, and Amazon Titan. Together with AWS, we’re offering customers exponential power to create differentiated experiences built around the needs of their business, while helping them prepare for the future.”

– Glenn Nethercutt, CTO at Genesys.

As the generative AI revolution continues to unfold, AWS is poised to shape its future, empowering customers across industries to drive innovation, streamline processes, and redefine how we interact with machines. Together with outstanding partners like Mistral AI, and with Amazon Bedrock as the foundation, our customers can build more innovative generative AI applications.

Democratizing access to LLMs and FMs
Amazon Bedrock is democratizing access to cutting-edge LLMs and FMs and AWS is the only cloud provider to offer the most popular and advanced FMs to customers. The collaboration with Mistral AI represents a significant milestone in this journey, further expanding Amazon Bedrock’s diverse model offerings and reinforcing our commitment to empowering customers with unparalleled choice through Amazon Bedrock. By recognizing that no single model can optimally serve every use case, AWS has paved the way for customers to unlock the full potential of generative AI. Through Amazon Bedrock, organizations can experiment with and take advantage of the unique strengths of multiple top-performing models, tailoring their solutions to specific needs, industry domains, and workloads. This unprecedented choice, combined with the robust security, privacy, and scalability of AWS, enables customers to harness the power of generative AI responsibly and with confidence, no matter their industry or regulatory constraints.
"""

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

# modelId = "mistral.mistral-large-instruct-v0:2"
modelId = "mistral.mistral-large-2402-v1:0"

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()))

Puede obtener una salida en formato JSON utilizando el siguiente ejemplo:

JSON

{
"Summary 1": "The generative AI revolution is transforming businesses with the help of Amazon Bedrock, which offers access to multiple state-of-the-art large language models and foundation models. Mistral AI's latest model, Mistral Large, is now available on Amazon Bedrock, providing exceptional language understanding and generation capabilities.",
"Confidence 1": 0.95,
"Summary 2": "Amazon Bedrock is a unified service that provides customers with access to top models from various AI companies, including Amazon, Anthropic, AI21 Labs, Cohere, Meta, Mistral AI, and Stability AI. The recent addition of Mistral Large to the platform enhances the range of top-performing LLMs available to customers.",
"Confidence 2": 0.92,
"Summary 3": "Mistral Large, the latest model from Mistral AI, offers exceptional language understanding and generation capabilities, making it ideal for complex tasks that require reasoning or specialized knowledge. Its multilingual performance and coding proficiency make it a valuable addition to Amazon Bedrock's diverse model offerings.",
"Confidence 3": 0.90
}

Para obtener más información sobre las capacidades de solicitud en los modelos de Mistral AI, consulta la documentación de Mistral AI.

Ya disponible:
Mistral Large, junto con otros modelos de Mistral AI (Mistral 7B y Mixtral 8x7B), ya está disponible en Amazon Bedrock en las regiones Este de EE. UU. (Norte de Virginia), Oeste de EE. UU. (Oregón) y Europa (París). Consulta la lista completa de regiones para futuras actualizaciones.

Únete y aprende en nuestra comunidad de IA generativa en community.aws. Prueba Mistral Large hoy mismo en la consola de Amazon Bedrock y envíanos tus comentarios a través de AWS re:Post para Amazon Bedrock o mediante tus contactos habituales de soporte de AWS.

Lee más sobre nuestra colaboración con Mistral AI y lo que significa para nuestros clientes.

–Velisa


Por Veliswa Boya.

Publicado el 02 de abril de 2024.

Revisa la publicación original aquí.


Somos S4E Solutions for Eveyone, Select Partner de AWS en Latinoamérica visítanos y otras soluciones digitales para tu compañía. ¡Conversemos!

Nos puedes encontrar en redes sociales, ¡Síguenos para tener actualizaciones diarias! LinkedIn YouTubeFacebook y Twitter

S4E cuenta con un equipo de soporte certificado en herramientas Atlassian y AWS.