Phi4Multimodal<T>

Models & Types · AiDotNet.VisionLanguage.InstructionTuned

Phi-4-Multimodal: unified vision + audio + text in a single framework.

Inheritance: NeuralNetworkBase<T> → VisionLanguageModelBase<T> → Phi4Multimodal<T>

Implements: IInstructionTunedVLM<T>

For Beginners

Phi-4-Multimodal from Microsoft extends the Phi-4 language model to natively handle images, audio, and text in a single unified framework. Rather than having separate models for different input types, Phi-4-Multimodal processes all modalities through one architecture. It uses a SigLIP vision encoder with MLP projection for images and adds audio understanding capabilities. This unified approach means a single model can answer questions about photos, transcribe and understand speech, and process text — all without switching between different specialized models. Default values follow the original paper settings.

How It Works

Phi-4-Multimodal (Microsoft, 2025) extends the Phi-4 language model with native support for vision and audio inputs in a single unified framework. It uses a SigLIP vision encoder with MLP projection to map visual features into the Phi-4 decoder space.

References:

  • Paper: “Phi-4-Multimodal Technical Report” (Microsoft, 2025)

Example

// Create a Phi-4-Multimodal model for unified vision + audio + text
// using SigLIP encoder with Phi-4 backbone
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.TwoDimensional,
    taskType: NeuralNetworkTaskType.ImageClassification,
    inputHeight: 224, inputWidth: 224, inputDepth: 3, outputSize: 512);
            
// ONNX inference mode with pre-trained model
var model = new Phi4Multimodal<double>(architecture, "phi4multimodal.onnx");
            
// Training mode with native layers
var trainModel = new Phi4Multimodal<double>(architecture, new Phi4MultimodalOptions());

Constructors

Constructor Summary
Phi4Multimodal(NeuralNetworkArchitecture<T> architecture, Phi4MultimodalOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer)
Phi4Multimodal(NeuralNetworkArchitecture<T> architecture, string modelPath, Phi4MultimodalOptions options)

Properties

Property Summary
int DecoderEmbeddingDim { get; }
int EmbeddingDimension { get; }
int MaxGenerationLength { get; }
string LanguageModelName { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
Tensor<T> Chat(Tensor<T> image, IEnumerable<ValueTuple<string, string>> conversationHistory, string userMessage)
Tensor<T> EncodeImage(Tensor<T> image)
Tensor<T> GenerateFromImage(Tensor<T> image, string prompt) Generates text using Phi-4-Multimodal’s unified multi-modal architecture.