The future of AI isn’t just about understanding text, it’s about seeing, hearing, and reasoning simultaneously. Enter Phi-4 Multimodal Instruct, Microsoft’s latest breakthrough in AI that fuses speech, vision, and language into a single, lightweight, yet powerful model. With just 5.6B parameters, it challenges industry giants, ranking #1 in ASR performance while excelling in document reasoning, chart interpretation, and multimodal understanding. Built for efficiency and speed, it delivers top-tier results without heavy infrastructure, making it a game-changer for AI-driven applications.
In this guide, we’ll show you how to install and set up Phi-4 Multimodal for ASR so you can start leveraging its cutting-edge capabilities today. Whether you’re working on voice assistants, automated transcription, or multimodal AI, this is a tool you don’t want to miss.
Performance Benchmarks
Speech Recognition (lower is better)
Speech Translation (higher is better)
Vision Benchmarks
Benchmarks | Phi-4-multimodal-instruct | InternOmni-7B | Gemini-2.0-Flash-Lite-prv-02-05 | Gemini-2.0-Flash | Gemini-1.5-Pro |
---|
s_AI2D | 68.9 | 53.9 | 62.0 | 69.4 | 67.7 |
s_ChartQA | 69.0 | 56.1 | 35.5 | 51.3 | 46.9 |
s_DocVQA | 87.3 | 79.9 | 76.0 | 80.3 | 78.2 |
s_InfoVQA | 63.7 | 60.3 | 59.4 | 63.6 | 66.1 |
Average | 72.2 | 62.6 | 58.2 | 66.2 | 64.7 |
Prerequisites
The minimum system requirements for this use case are:
- GPUs: RTX 4090 or RTX A6000 (for smooth execution).
- Disk Space: 200 GB
- RAM: At least 64 GB.
- Jupyter Notebook installed.
Note: The prerequisites for this are highly variable across use cases. A high-end configuration could be used for a large-scale deployment.
Step-by-step process to install & run Phi-4 Multimodal Instruct
For the purpose of this tutorial, we’ll use a GPU-powered Virtual Machine by NodeShift since it provides high compute Virtual Machines at a very affordable cost on a scale that meets GDPR, SOC2, and ISO27001 requirements. Also, it offers an intuitive and user-friendly interface, making it easier for beginners to get started with Cloud deployments. However, feel free to use any cloud provider of your choice and follow the same steps for the rest of the tutorial.
Step 1: Setting up a NodeShift Account
Visit app.nodeshift.com and create an account by filling in basic details, or continue signing up with your Google/GitHub account.
If you already have an account, login straight to your dashboard.
Step 2: Create a GPU Node
After accessing your account, you should see a dashboard (see image), now:
- Navigate to the menu on the left side.
- Click on the GPU Nodes option.
- Click on Start to start creating your very first GPU node.
These GPU nodes are GPU-powered virtual machines by NodeShift. These nodes are highly customizable and let you control different environmental configurations for GPUs ranging from H100s to A100s, CPUs, RAM, and storage, according to your needs.
Step 3: Selecting configuration for GPU (model, region, storage)
- For this tutorial, we’ll be using the RTX 4090 GPU; however, you can choose any GPU of your choice based on your needs.
- Similarly, we’ll opt for 200GB storage by sliding the bar. You can also select the region where you want your GPU to reside from the available ones.
Step 4: Choose GPU Configuration and Authentication method
- After selecting your required configuration options, you’ll see the available VMs in your region and according to (or very close to) your configuration. In our case, we’ll choose a 1x RTX 4090 GPU node with 12 vCPUs/96GB RAM/200 GB SSD.
2. Next, you’ll need to select an authentication method. Two methods are available: Password and SSH Key. We recommend using SSH keys, as they are a more secure option. To create one, head over to our official documentation.
Step 5: Choose an Image
The final step would be to choose an image for the VM, which in our case is Jupyter Notebook, where we’ll deploy and run the inference of our model.
That’s it! You are now ready to deploy the node. Finalize the configuration summary, and if it looks good, click Create to deploy the node.
Step 6: Connect to active Compute Node using SSH
- As soon as you create the node, it will be deployed in a few seconds or a minute. Once deployed, you will see a status Running in green, meaning that our Compute node is ready to use!
- Once your GPU shows this status, navigate to the three dots on the right and click on Connect with SSH. This will open a new tab with a Jupyter Notebook session in which we can run our model.
Step 7: Setting up Python Notebook
Start by creating a .ipynb notebook by clicking on Python 3 (ipykernel).
Next, If you want to check the GPU details, run the following command in the Jupyter Notebook cell:
!nvidia-smi
Output:
Step 8: Download model files with dependencies.
- Install Python dependencies to run the model.
pip install torch==2.6.0
pip install torchvision=0.21.0 torchaudio einops timm pillow=11.1.0
pip install git+https://github.com/huggingface/transformers
pip install git+https://github.com/huggingface/accelerate
pip install git+https://github.com/huggingface/diffusers
pip install huggingface_hub
pip install sentencepiece bitsandbytes protobuf decord numpy
pip install scipy=1.15.2
pip install backoff=2.2.1
pip install peft=0.13.2
pip install soundfile=0.13.1
Output:
2. Download flash attention if GPU doesn’t have it already.
pip install flash_attn --no-build-isolation
Output:
3. Download model files and import the model.
import requests
import torch
import os
import io
from PIL import Image
import soundfile as sf
from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig
from urllib.request import urlopen
# Define model path
model_path = "microsoft/Phi-4-multimodal-instruct"
# Load model and processor
processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_path,
device_map="cuda",
torch_dtype="auto",
trust_remote_code=True,
_attn_implementation='flash_attention_2',
).cuda()
# Load generation config
generation_config = GenerationConfig.from_pretrained(model_path)
# Define prompt structure
user_prompt = '<|user|>'
assistant_prompt = '<|assistant|>'
prompt_suffix = '<|end|>'
Output:
Step 9: Run and test the model
Finally, run and test the model using the following snippet.
In the below code snippet, the prompt we provide to the model is as follows:
Prompt: “Transcribe the audio to text, and then translate the audio to German. Use <sep> as a separator between the original transcript and the translation.”
Along with the prompt, we provide it a sample audio named harvard.mp3.
You may replace the language in prompt and the audio with your own.
speech_prompt = "Transcribe the audio to text, and then translate the audio to German. Use <sep> as a separator between the original transcript and the translation."
prompt = f'{user_prompt}<|audio_1|>{speech_prompt}{prompt_suffix}{assistant_prompt}'
print(f'>>> Prompt\n{prompt}')
# Downlowd and open audio file
audio_path="./harvard.mp3"
audio, samplerate = sf.read(audio_path)
# Process with the model
inputs = processor(text=prompt, audios=[(audio, samplerate)], return_tensors='pt').to('cuda:0')
num_logits_to_keep = 1
generate_ids = model.generate(
**inputs,
max_new_tokens=1000,
num_logits_to_keep=num_logits_to_keep
)
generate_ids = generate_ids[:, inputs['input_ids'].shape[1]:]
response = processor.batch_decode(
generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False
)[0]
print(f'>>> Response\n{response}')
Output:
Here’s the output generated by the model for the given audio:
Conclusion
With Phi-4 Multimodal Instruct, AI is stepping into a new era where speech, vision, and text work in harmony, enabling more intuitive and efficient applications. From state-of-the-art ASR performance to document reasoning and multimodal intelligence, this model proves that high performance doesn’t have to come at the cost of efficiency. But harnessing its full potential requires the right infrastructure, and that’s where NodeShift Cloud comes in. By providing a scalable, optimized environment, NodeShift ensures seamless deployment, efficient resource management, and low-latency execution for AI workloads. Whether you’re experimenting with multimodal AI or building production-grade applications, NodeShift empowers you to focus on innovation while it handles the complexity.