Instructions to use BAAI/AREX-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BAAI/AREX-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="BAAI/AREX-2") 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("BAAI/AREX-2") model = AutoModelForMultimodalLM.from_pretrained("BAAI/AREX-2", 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 BAAI/AREX-2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BAAI/AREX-2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BAAI/AREX-2", "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/BAAI/AREX-2
- SGLang
How to use BAAI/AREX-2 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 "BAAI/AREX-2" \ --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": "BAAI/AREX-2", "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 "BAAI/AREX-2" \ --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": "BAAI/AREX-2", "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 BAAI/AREX-2 with Docker Model Runner:
docker model run hf.co/BAAI/AREX-2
Where is the MTP?
Should I use the existing qwen 3.8 27b MTP?
Seems to work fine using https://huggingface.co/unsloth/Qwen3.8-27B-GGUF/blob/main/MTP/mtp-Qwen3.8-27B-Q4_0.gguf, I see double token generation speed with --spec-type draft-mtp --spec-draft-n-max 3
Problem with external MTP head is size.
External: ~1.37 Gb of precious VRAM.
Embedded: ~250-300 Mb.
So MTP should go as a part of a model rather than external.
Problem with external MTP head is size.
External: ~1.37 Gb of precious VRAM.
Embedded: ~250-300 Mb.
The MTP head is a fixed size whether it is bundled or a separate GGUF sidecar. You don't save 1GB just by using the included MTP. For example, I made an external DFlash2 drafter that is only 561MB, which is smaller than most MTP heads.
Problem with external MTP head is size.
External: ~1.37 Gb of precious VRAM.
Embedded: ~250-300 Mb.The MTP head is a fixed size whether it is bundled or a separate GGUF sidecar. You don't save 1GB just by using the included MTP. For example, I made an external DFlash2 drafter that is only 561MB, which is smaller than most MTP heads.
Well, MTP head in my GGUF quants for Qwen3.8-27B is ~250-300 Mb. IQ4_XS quants. Somehow Unsloth gives Q4_0 (nearly same as IQ4_XS) standalone MTP that is 1.37 Gb. How is that possible?
UPD: Ah, now I see. Standalone MTP includes heavy embedding and output tensors. So not the same as using MTP as a part of a model, where it shares these tensors.
Problem with external MTP head is size.
External: ~1.37 Gb of precious VRAM.
Embedded: ~250-300 Mb.The MTP head is a fixed size whether it is bundled or a separate GGUF sidecar. You don't save 1GB just by using the included MTP. For example, I made an external DFlash2 drafter that is only 561MB, which is smaller than most MTP heads.
Well, MTP head in my GGUF quants for Qwen3.8-27B is ~250-300 Mb. IQ4_XS quants. Somehow Unsloth gives Q4_0 (nearly same as IQ4_XS) standalone MTP that is 1.37 Gb. How is that possible?
UPD: Ah, now I see. Standalone MTP includes heavy embedding and output tensors. So not the same as using MTP as a part of a model, where it shares these tensors.
hey, are you planning to provide quants for this model with mtp head in? it would be great, if not even without mtp head it would be appreciated
On Mac, the DFlash2 helper made for plain Qwen3.8-27B (incoai/Qwen3.8-27B-DFlash2) works with AREX-2 unchanged. With mlx-dspark it took the 8-bit MLX build from 8 to 19 tokens per second on an M4 Pro, keeping about 86% of the acceptance it gets on plain Qwen3.8-27B. Details: https://huggingface.co/mlx-community/AREX-2-8bit