Image-Text-to-Text
Transformers
Safetensors
English
xgenmm
feature-extraction
conversational
custom_code
Instructions to use Salesforce/xgen-mm-phi3-mini-instruct-r-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Salesforce/xgen-mm-phi3-mini-instruct-r-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Salesforce/xgen-mm-phi3-mini-instruct-r-v1", trust_remote_code=True) 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 AutoModelForVision2Seq model = AutoModelForVision2Seq.from_pretrained("Salesforce/xgen-mm-phi3-mini-instruct-r-v1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Salesforce/xgen-mm-phi3-mini-instruct-r-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Salesforce/xgen-mm-phi3-mini-instruct-r-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Salesforce/xgen-mm-phi3-mini-instruct-r-v1", "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/Salesforce/xgen-mm-phi3-mini-instruct-r-v1
- SGLang
How to use Salesforce/xgen-mm-phi3-mini-instruct-r-v1 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 "Salesforce/xgen-mm-phi3-mini-instruct-r-v1" \ --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": "Salesforce/xgen-mm-phi3-mini-instruct-r-v1", "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 "Salesforce/xgen-mm-phi3-mini-instruct-r-v1" \ --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": "Salesforce/xgen-mm-phi3-mini-instruct-r-v1", "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 Salesforce/xgen-mm-phi3-mini-instruct-r-v1 with Docker Model Runner:
docker model run hf.co/Salesforce/xgen-mm-phi3-mini-instruct-r-v1
Download config.json from Salesforce/xgen-mm-phi3-mini-instruct-r-v1: direct link, hf CLI and curl.
- Browser
- Download file 692 Bytes
-
https://huggingface.co/Salesforce/xgen-mm-phi3-mini-instruct-r-v1/resolve/main/config.json
- Command line
-
hf download hf://Salesforce/xgen-mm-phi3-mini-instruct-r-v1/config.json
-
curl -L -o config.json https://huggingface.co/Salesforce/xgen-mm-phi3-mini-instruct-r-v1/resolve/main/config.json
692 Bytes
| { | |
| "architectures": [ | |
| "XGenMMModelForConditionalGeneration" | |
| ], | |
| "auto_map": { | |
| "AutoConfig": "configuration_xgenmm.XGenMMConfig", | |
| "AutoModelForVision2Seq": "modeling_xgenmm.XGenMMModelForConditionalGeneration" | |
| }, | |
| "model_type": "xgenmm", | |
| "text_config": { | |
| "initial_tokenizer_len": 32012, | |
| "model_type": "phi3", | |
| "sliding_window": 2047, | |
| "torch_dtype": "bfloat16" | |
| }, | |
| "torch_dtype": "float32", | |
| "transformers_version": "4.41.1", | |
| "vision_encoder_config": { | |
| "anyres_patch_sampling": true, | |
| "image_aspect_ratio": "anyres", | |
| "model_type": "xgenmm_vision_encoder" | |
| }, | |
| "vision_tokenizer_config": { | |
| "model_type": "xgenmm_vision_tokenizer" | |
| } | |
| } | |