Phi3Vision<T>

Models & Types · AiDotNet.VisionLanguage.InstructionTuned

Phi-3-Vision: compact 4.2B parameter model with strong vision capabilities via curated data.

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

Implements: IInstructionTunedVLM<T>

For Beginners

Phi-3-Vision from Microsoft proves that you don’t need a massive model to get strong visual AI. At just 4.2 billion parameters, it’s small enough to run on a phone, yet achieves performance that rivals much larger models. The secret is high-quality training data — Microsoft carefully curated the training examples to maximize what the model learns from each one. It uses a CLIP-ViT vision encoder connected to the Phi-3 language model through an MLP projection, keeping the architecture simple while relying on data quality for performance. Default values follow the original paper settings.

How It Works

Phi-3-Vision (Abdin et al., 2024) is a compact multimodal model with 4.2B parameters that achieves strong performance through high-quality curated training data rather than model scale. It uses CLIP-ViT with MLP projection into the Phi-3 language model backbone.

References:

  • Paper: “Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phone” (Abdin et al., 2024)

Example

// Create a Phi-3-Vision model for compact on-device visual AI
// using CLIP-ViT with Phi-3 backbone at only 4.2B parameters
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 Phi3Vision<double>(architecture, "phi3vision.onnx");
            
// Training mode with native layers
var trainModel = new Phi3Vision<double>(architecture, new Phi3VisionOptions());

Constructors

Constructor Summary
Phi3Vision(NeuralNetworkArchitecture<T> architecture, Phi3VisionOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer)
Phi3Vision(NeuralNetworkArchitecture<T> architecture, string modelPath, Phi3VisionOptions 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-3-Vision’s compact data-centric architecture.