跳到正文
Mistral AI:News·· 2024-09-17精选AI 评分73

Mistral 发布开源多模态模型 Pixtral 12B,采用 Apache 2.0 许可

Research Announcing Pixtral 12B September 17, 2024 By Mistral team

AI 导读

Mistral 发布开源多模态模型 Pixtral 12B,以 Apache 2.0 许可提供,可作为 Mistral Nemo 12B 的直接替换。

推荐理由

官方发布开源多模态模型,给出了架构细节、MMMU 分数和统一评测对比,可作为同规模开源模型选型的参考。

正文 · 原文

Pixtral 12B is no longer maintained and has been replaced by our latest, more powerful vision and multimodal models.

Explore our current vision capabilities

Pixtral 12B in short:

Natively multimodal, trained with interleaved image and text data

Strong performance on multimodal tasks, excels in instruction following

Maintains state-of-the-art performance on text-only benchmarks

Architecture:

New 400M parameter vision encoder trained from scratch

12B parameter multimodal decoder based on Mistral Nemo

Supports variable image sizes and aspect ratios

Supports multiple images in the long context window of 128k tokens

Use:

License: Apache 2.0

Try iton La Plateformeoron Le Chat

Pixtral is trained to understand both natural images and documents, achieving 52.5% on the MMMU reasoning benchmark, surpassing a number of larger models. The model shows strong abilities in tasks such as chart and figure understanding, document question answering, multimodal reasoning and instruction following. Pixtral is able to ingest images at their natural resolution and aspect ratio, giving the user flexibility on the number of tokens used to process an image. Pixtral is also able to process any number of images in its long context window of 128K tokens. Unlike previous open-source models, Pixtral does not compromise on text benchmark performance to excel in multimodal tasks.

Pixtral was trained to be adrop-in replacement for Mistral Nemo 12B. Its key distinguishing factor from existing open-source models is the delivery ofbest-in-class multimodal reasoningwithout compromising on key text capabilitiessuch as instruction following, coding, and math.

Evaluation protocol

We re-evaluate a range of open and closed models through the same evaluation harness. For each dataset, the prompt was chosen such that we could reproduce the results of leading multimodal models (GPT-4o and Claude-3.5-Sonnet). All models were then evaluated with this same prompt. Overall, Pixtral substantially outperforms all open models around its scale and, in many cases, outperforms closed models such as Claude 3 Haiku. Pixtral even outperforms or matches the performance of much larger models like LLaVa OneVision 72B on multimodal benchmarks.All prompts will be open-sourced.

Performance of Pixtral compared to closed and larger multimodal models. [All models were benchmarked through the same evaluation harness and with the same prompt. We verify that prompts reproduce the performance reported for GPT-4o and Claude 3.5 Sonnet (prompts will be provided in technical report)].

Instruction following

Pixtral particularly excels at both multimodal and text-only instruction following as compared to other open multimodal models. It substantially outperforms Qwen2-VL 7B, LLaVa-OneVision 7B and Phi-3.5 Vision in instruction following, with a 20% relative improvement in text IF-Eval and MT-Bench over the nearest OSS model. To further evaluate this ability for multimodal use cases, we create multimodal versions of these benchmarks:MM-IF-Eval and MM-MT-Bench. Pixtral outperforms open-source alternatives on multimodal instruction following benchmarks as well. We will open-source MM-MT-Bench to the community.

Performance of Pixtral compared to open multimodal models. All models were benchmarked through the same evaluation harness and with the same prompt.

Architecture

Variable image size:Pixtral is designed to optimize for both speed and performance. We trained a new vision encoder that natively supports variable image sizes:

We simply pass images through the vision encoder at their native resolution and aspect ratio, converting them into image tokens for each 16x16 patch in the image

These tokens are then flattened to create a sequence, with[IMG BREAK]and[IMG END]tokens added between rows and at the end of the image.

[IMG BREAK]tokens let the model distinguish between images of different aspect ratios with the same number of tokens.

In this way, Pixtral can be used to accurately understand complex diagrams, charts and documents in high resolution, while providing fast inference speeds on small images like icons, clipart, and equations.

Pixtral uses a new vision encoder trained from scratch that natively supports variable image sizes.

Final architecture: Pixtral has two components: the Vision Encoder, which tokenizes images, and a Multimodal Transformer Decoder, which predicts the next text token given a sequence of text and images. The model is trained to predict the next text token on interleaved image and text data. This architecture allows Pixtral to process any number of images with arbitrary sizes in its large context window of 128K tokens.

Qualitative Examples

Reasoning over complex figures

This table combines the data from both tables, ensuring that all models and their respective scores from each benchmark are included in a single, cohesive format.

Prompt:

List the top 5 countries in Europe with the highest GDP

Response:

The top 5 countries in Europe with the highest GDP, based on the image, are:

1. Germany

2. GDP: $3.99 trillion

Percentage: 4.65%

3. United Kingdom

4. GDP: $2.82 trillion

Percentage: 3.29%

5. France

6. GDP: $2.78 trillion

Percentage: 3.24%

7. Italy

8. GDP: $2.07 trillion

Percentage: 2.42%

9. Spain

10. GDP: $1.43 trillion

Percentage: 1.66%

These countries are highlighted in green on the diagram.

Chart Understanding and Analysis

Image:

Prompt:

When did things start to go wrong for dark dragon?

Response:

The image is a line graph titled 'train/loss' that shows the training loss over steps for four different models: dark-dragon-50, dainty-sunset-49, different-haze-34, and morning-field-33. The x-axis represents the steps, ranging from 0 to 60k, and the y-axis represents the loss on a logarithmic scale from 1e-5 to 1e+5.

To determine when things started to go wrong for the dark-dragon-50 model, we need to look at the red line representing this model. Initially, the loss decreases, indicating that the model is learning effectively. However, around the 10k step mark, the loss starts to spike significantly. This spike indicates that the model's performance is deteriorating. The loss continues to spike and fluctuate, reaching very high values, which suggests that the model is not learning effectively and is likely overfitting or encountering other issues.

Therefore, the critical point where things started to go wrong for the dark-dragon-50 model is around the 10k step mark.

Multi-image instruction following

Images:

Prompt:

Combine information in both the tables into a single markdown table

Response:

To combine the information from both tables into a single table, we need to align the models and their corresponding scores from each benchmark. Here is the combined table:

| Model | MMMU (CoT) | Mathvista (CoT) | ChartQA (CoT) | DocVQA (ANLS) | VQAv2 (VQA Match) ||------------------------|------------|-----------------|---------------|---------------|-------------------|| Pixtral 12B | 52.5 | 58.0 | 81.8 | 90.7 | 78.6 || Claude-3 Haiku | 50.4 | 44.8 | 69.6 | 74.6 | 68.4 || Gemini-1.5 Flash 8B (0827) | 50.7 | 56.9 | 78.0 | 79.5 | 65.5 || LLaVA-OV 72B | 54.4 | 57.2 | 66.9 | 91.6 | 83.8 || GPT-4o | 68.6 | 64.6 | 85.1 | 88.9 | 77.8 || Claude-3.5 Sonnet | 68.0 | 64.4 | 87.6 | 90.3 | 70.7 || Qwen2-VL 7B | 47.6 | 54.4 | 38.6 | 94.5 | 75.9 || LLaVA-OV 7B | 45.1 | 36.1 | 67.1 | 90.5 | 78.3 || Phi-3 Vision | 40.3 | 36.4 | 72.0 | 84.9 | 42.4 || Phi-3.5 Vision | 38.3 | 39.3 | 67.7 | 74.4 | 56.1 |

This table combines the data from both tables, ensuring that all models and their respective scores from each benchmark are included in a single, cohesive format.

Image to Code

Image:

Prompt:

Write HTML code to create a website like this

Response:

Certainly! Below is an example of HTML code to create a simple webpage that allows users to pick an ice cream flavor. This example includes a dropdown menu for selecting the flavor and a "Next" button.

html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Pick an Ice Cream Flavor</title> <style> body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f0f0f0; } .container { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h1 { text-align: center; } select { width: 100%; padding: 10px; margin-top: 10px; margin-bottom: 20px; } button { width: 100%; padding: 10px; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; } button:hover { background-color: #45a049; } </style></head><body> <div class="container"> <h1>Pick An Ice Cream Flavor</h1> <select id="flavorSelect"> <option value="vanilla">Vanilla</option> <option value="chocolate">Chocolate</option> <option value="strawberry">Strawberry</option> <option value="cookiedough">Cookie Dough</option> <option value="mintchocolate">Mint Chocolate</option> </select> <button onclick="next()">Next</button> </div> <footer style="position: fixed; bottom: 0; width: 100%; text-align: center; font-size: 12px;"> &copy; copyright MistralAI </footer> <script> function next() { const selectedFlavor = document.getElementById('flavorSelect').value; alert('You selected: ' + selectedFlavor); } </script></body></html>

Explanation:

HTML Structure: The webpage consists of a container div that holds the heading, a dropdown menu, and a button.

CSS Styling: Basic styling is applied to center the content and style the elements.

JavaScript Function: The next function is called when the "Next" button is clicked. It retrieves the selected flavor from the dropdown menu and displays an alert with the chosen flavor.

You can copy and paste this code into an HTML file and open it in a web browser to see the result.

Website Generated:

Natural scene understanding

Prompt: Is this person really big, or is this building just super small?

Response:

The image shows a person holding their thumb in front of the Leaning Tower of Pisa, making it appear as if the thumb is much larger than the tower. This creates an optical illusion, making the tower seem smaller than it actually is. In reality, the Leaning Tower of Pisa is a large and iconic structure, and the person's thumb is not nearly as large as it appears in the image. The purpose of this photo is to demonstrate the impressive height and size of the tower by comparing it to a familiar object, such as a thumb.

How to run Pixtral?

Le Chat

You can try Pixtral easily and freely via Le Chat, our user-friendly conversational chat interface. You can choose Pixtral in the model list, upload an image, and start asking questions about the image.

La Plateforme

Pixtral is also available on La Plateforme. You can leverage Pixtral's capabilities through API calls, enabling seamless integration with various applications and workflows. Below is a simple example. Please find more details in our docs.

curl https://api.mistral.ai/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $MISTRALAPIKEY" \ -d '{ "model": "pixtral-12b-2409", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "What’s in this image?" }, { "type": "imageurl", "imageurl": "https://tripfixers.com/wp-content/uploads/2019/11/eiffel-tower-with-snow.jpeg" } ] } ], "maxtokens": 300 }'

mistral-inference

The easiest way to run Pixtral locally is to use mistral-inference. After installing mistralinference, you can download the model, load the model, and run the model using the code below. For detailed information, please see here.

download the modelfrom huggingfacehub import snapshotdownloadfrom pathlib import Path mistralmodelspath = Path.home().joinpath('mistralmodels', 'Pixtral')mistralmodelspath.mkdir(parents=True, existok=True) snapshotdownload(repoid="mistralai/Pixtral-12B-2409", allowpatterns=["params.json", "consolidated.safetensors", "tekken.json"], localdir=mistralmodelspath) load the modelfrom mistralinference.transformer import Transformerfrom mistralinference.generate import generate from mistralcommon.tokens.tokenizers.mistral import MistralTokenizerfrom mistralcommon.protocol.instruct.messages import UserMessage, TextChunk, ImageURLChunkfrom mistralcommon.protocol.instruct.request import ChatCompletionRequest tokenizer = MistralTokenizer.fromfile(f"{mistralmodelspath}/tekken.json")model = Transformer.fromfolder(mistralmodelspath) Run the modelurl = "https://huggingface.co/datasets/patrickvonplaten/randomimg/resolve/main/yosemite.png"prompt = "Describe the image." completionrequest = ChatCompletionRequest(messages=[UserMessage(content=[ImageURLChunk(imageurl=url), TextChunk(text=prompt)])]) encoded = tokenizer.encodechatcompletion(completionrequest) images = encoded.imagestokens = encoded.tokens outtokens, = generate([tokens], model, images=[images], maxtokens=256, temperature=0.35, eosid=tokenizer.instructtokenizer.tokenizer.eosid)result = tokenizer.decode(outtokens[0]) print(result)

vLLM

If you choose to serve Pixtral locally, we also recommend using Pixtral with the vLLM library as a fantastic option to reach higher serving throughput. We thank the vLLM team for their support to integrate Pixtral quickly. Below is a simple usage example. Please find more information here.

from vllm import LLMfrom vllm.samplingparams import SamplingParams modelname = "mistralai/Pixtral-12B-2409" samplingparams = SamplingParams(maxtokens=8192) llm = LLM(model=modelname, tokenizermode="mistral") prompt = "Describe this image in one sentence."imageurl = "https://picsum.photos/id/237/200/300" messages = [ { "role": "user", "content": [{"type": "text", "text": prompt}, {"type": "imageurl", "imageurl": {"url": imageurl}}] },] outputs = vllmmodel.model.chat(messages, samplingparams=samplingparams) print(outputs[0].outputs[0].text)

来源:Mistral AI:News · mistral.ai