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
- 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 +1 -3
- model.safetensors +2 -2
README.md
CHANGED
|
@@ -182,9 +182,7 @@ with open(Path(save_folder, 'phi4mm/vision_siglip_navit.py'), 'w') as f:
|
|
| 182 |
sys.path.append(str(Path(save_folder)))
|
| 183 |
from phi4mm.modeling_phi4mm import Phi4MMForCausalLM
|
| 184 |
print(Phi4MMForCausalLM) # ensure imported
|
| 185 |
-
|
| 186 |
-
model = Phi4MMForCausalLM(config)
|
| 187 |
-
torch.set_default_dtype(torch.float32)
|
| 188 |
|
| 189 |
set_seed(42)
|
| 190 |
with torch.no_grad():
|
|
|
|
| 182 |
sys.path.append(str(Path(save_folder)))
|
| 183 |
from phi4mm.modeling_phi4mm import Phi4MMForCausalLM
|
| 184 |
print(Phi4MMForCausalLM) # ensure imported
|
| 185 |
+
model = Phi4MMForCausalLM(config).to(torch.bfloat16)
|
|
|
|
|
|
|
| 186 |
|
| 187 |
set_seed(42)
|
| 188 |
with torch.no_grad():
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a47f5caa9957c85df39e16d6c7e781fdd3db271bf7f36872eeaa4c51864dca3e
|
| 3 |
+
size 6551432
|