Instructions to use tiny-random/phi-4-multimodal with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/phi-4-multimodal with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/phi-4-multimodal", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("tiny-random/phi-4-multimodal", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/phi-4-multimodal with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/phi-4-multimodal" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/phi-4-multimodal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tiny-random/phi-4-multimodal
- SGLang
How to use tiny-random/phi-4-multimodal 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 "tiny-random/phi-4-multimodal" \ --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": "tiny-random/phi-4-multimodal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "tiny-random/phi-4-multimodal" \ --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": "tiny-random/phi-4-multimodal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tiny-random/phi-4-multimodal with Docker Model Runner:
docker model run hf.co/tiny-random/phi-4-multimodal
Upload folder using huggingface_hub
Browse files- README.md +2 -2
- config.json +1 -1
README.md
CHANGED
|
@@ -25,7 +25,7 @@ from PIL import Image
|
|
| 25 |
from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig
|
| 26 |
|
| 27 |
# Define model path
|
| 28 |
-
model_id = "
|
| 29 |
|
| 30 |
# Load model and processor
|
| 31 |
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
|
@@ -114,7 +114,7 @@ from transformers import (
|
|
| 114 |
)
|
| 115 |
|
| 116 |
source_model_id = "microsoft/Phi-4-multimodal-instruct"
|
| 117 |
-
save_folder = "/tmp/
|
| 118 |
Path(save_folder).mkdir(exist_ok=True)
|
| 119 |
AutoTokenizer.from_pretrained(source_model_id).save_pretrained(save_folder)
|
| 120 |
|
|
|
|
| 25 |
from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig
|
| 26 |
|
| 27 |
# Define model path
|
| 28 |
+
model_id = "tiny-random/phi-4-multimodal"
|
| 29 |
|
| 30 |
# Load model and processor
|
| 31 |
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
|
|
|
| 114 |
)
|
| 115 |
|
| 116 |
source_model_id = "microsoft/Phi-4-multimodal-instruct"
|
| 117 |
+
save_folder = "/tmp/tiny-random/phi-4-multimodal"
|
| 118 |
Path(save_folder).mkdir(exist_ok=True)
|
| 119 |
AutoTokenizer.from_pretrained(source_model_id).save_pretrained(save_folder)
|
| 120 |
|
config.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"_name_or_path": "./tmp/
|
| 3 |
"architectures": [
|
| 4 |
"Phi4MMForCausalLM"
|
| 5 |
],
|
|
|
|
| 1 |
{
|
| 2 |
+
"_name_or_path": "./tmp/tiny-random/phi-4-multimodal",
|
| 3 |
"architectures": [
|
| 4 |
"Phi4MMForCausalLM"
|
| 5 |
],
|