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)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("mistral-experimental/pixtral-12b") model = AutoModelForImageTextToText.from_pretrained("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?"} ] }, ] 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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- 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
LoRA Finetuning and Merging
1
#35 opened 10 months ago
by
JVal123
Error with transformers 4.51.3: RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.cuda.HalfTensor) should be the same
2
#34 opened about 1 year ago
by
david-crynge
How do I load the model quantized?
4
#33 opened about 1 year ago
by
treehugg3
[Question] How to use system prompt?
2
#32 opened about 1 year ago
by
jankinf
Cannot apply chat template from tokenizer
2
#31 opened about 1 year ago
by
DarkLight1337
pixtral-12b video support
#30 opened over 1 year ago
by
NmTamil2
Fastest way for inference?
3
#28 opened over 1 year ago
by
psycy
Left side padding
🚀 1
1
#27 opened over 1 year ago
by
asarvazyan
Add pad token to tokenizer_config.json
#26 opened over 1 year ago
by
asarvazyan
Getting shape mismatch while loading saved Pixtral model
4
#24 opened over 1 year ago
by
ss007
Quantized Model config file
#23 opened over 1 year ago
by
endeavorXx
Is the chat template correct? (issue for vLLM)
7
#22 opened over 1 year ago
by
MichaelAI23
Does the licensing for this model incorporate or depend on the licenses for LLaVA and LLaMA?
#20 opened over 1 year ago
by
Skylark
Include user license
#19 opened over 1 year ago
by
singhami
Fine tuning scripts for pixtral-12b
#18 opened over 1 year ago
by
2U1
Find solution to use this version with text and image : fake_image ;)
#17 opened over 1 year ago
by
martossien
Estimation of hardware requirements to finetune Pixtral models
1
#16 opened over 1 year ago
by deleted
Ask for guilding batch inference
5
#15 opened over 1 year ago
by
nguyen-brat
Update model weight
8
#13 opened over 1 year ago
by
nguyen-brat
Any leads on how to fine-tune Pixtral on custom dataset for reference?
3
#12 opened over 1 year ago
by deleted
Update tokenizer_config.json with chat_template
3
#11 opened over 1 year ago
by
mgoin
Multiple local images
1
#9 opened over 1 year ago
by
chiauho
How can i use the full 24GB model instead of this separated safetensors files?
1
#8 opened over 1 year ago
by
Valadaro
Converting back to Mistral/vLLM format
➕🤝 6
3
#4 opened over 1 year ago
by
RonanMcGovern
How to use safetensors?
1
#3 opened over 1 year ago
by
prathi1729
lamma cpp ht to gguf not working
4
#2 opened over 1 year ago
by
RameshRajamani
Local image input?
1
#1 opened over 1 year ago
by
ruiqiw