Instructions to use mistral-experimental/pixtral-12b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mistral-experimental/pixtral-12b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="mistral-experimental/pixtral-12b") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("mistral-experimental/pixtral-12b") model = AutoModelForMultimodalLM.from_pretrained("mistral-experimental/pixtral-12b", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mistral-experimental/pixtral-12b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mistral-experimental/pixtral-12b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mistral-experimental/pixtral-12b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/mistral-experimental/pixtral-12b
- SGLang
How to use mistral-experimental/pixtral-12b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mistral-experimental/pixtral-12b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mistral-experimental/pixtral-12b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mistral-experimental/pixtral-12b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mistral-experimental/pixtral-12b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use mistral-experimental/pixtral-12b with Docker Model Runner:
docker model run hf.co/mistral-experimental/pixtral-12b
Commit History
-
add updated chat template example
Verified signaturec2756cb
-
Update chat_template.json
Verified signatureAdded one more if so assistant can also get content as a list of dicts with keys "content"/"text"ae30a20
-
Update chat_template.json
Verified signature207188f
-
Update README.md (#21)
Verified signature- Update README.md (a2850af35fee0f47b1b29ba58befc90f1f09d74d)703075a
-
Update hidden_act to silu (#14)
Verified signature- Update hidden_act to silu (5810cf583c76cc8bd62aa0fc5667560657388de0)1742abe
-
Add processor chat template (#7)
Verified signature- Upload processor (0dbc5f3c38ee0f0909e1b208376615dc36f87389) - Update README.md (a23b0b5dcca5a68ba421f24c9b2388c95e401b2d) - Update README.md (ff8295e63aaaeb52212a5b072d5c11729c40896e) - Update README.md (7f5b217b4a111b6bedb69d3e54fa8d89b5d3cbc7) - Update README.md (460ee72562823640acf40dc3d849a9d15622e5bf)54521e8
-
Update README.md
Verified signature046a989 -
Update README.md
Verified signature57cbee8
-
Update config.json
Verified signaturec67706c -
Upload LlavaForConditionalGeneration
Verified signaturecb1ea9f
-
Update README.md
Verified signatured04b7a5 -
Update README.md
Verified signature4d53906 -
Update tokenizer_config.json
Verified signature8dc42df -
Update config.json
Verified signature0205667 -
Update README.md
Verified signatured890576 -
Update README.md
Verified signature0452fad -
Update README.md
Verified signature77ed10f -
Update README.md
Verified signature1eaae60 -
Update README.md
Verified signaturee32103d -
Upload LlavaForConditionalGeneration
Verified signature4434ab1 -
Update README.md
Verified signaturef3dbad2 -
Upload processor
Verified signaturec242c38 -
initial commit
Verified signaturea25dd59