DeepSeekVL2<T>
Models & Types · AiDotNet.VisionLanguage.InstructionTuned
DeepSeek-VL2: MoE vision-language model with dynamic tiling and multi-head latent attention.
Inheritance: NeuralNetworkBase<T> → VisionLanguageModelBase<T> → DeepSeekVL2<T>
Implements: IInstructionTunedVLM<T>
For Beginners
DeepSeek-VL2 is a major upgrade that combines Mixture-of-Experts with dynamic image tiling. It has 64 total experts but only activates 6 per token, making it efficient despite its large capacity. Dynamic tiling lets it handle images at variable resolutions by splitting them into appropriately-sized tiles. It also uses multi-head latent attention (MLA) to compress the key-value cache, reducing memory usage during inference. Available in 1.8B, 4.5B, and 27B sizes for different compute budgets. Default values follow the original paper settings.
How It Works
DeepSeek-VL2 (Wu et al., 2024) advances multimodal understanding with Mixture-of-Experts (MoE) architecture, dynamic image tiling for variable resolution input, and multi-head latent attention for efficient KV cache compression. It uses 64 experts with 6 active per token.
References:
- Paper: “DeepSeek-VL2: Mixture-of-Experts Vision-Language Models for Advanced Multimodal Understanding” (Wu et al., 2024)
Example
// Create a DeepSeek-VL2 model for advanced multimodal understanding
// using MoE architecture with dynamic tiling and MLA attention
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 DeepSeekVL2<double>(architecture, "deepseekvl2.onnx");
// Training mode with native layers
var trainModel = new DeepSeekVL2<double>(architecture, new DeepSeekVL2Options());
Constructors
| Constructor | Summary |
|---|---|
DeepSeekVL2(NeuralNetworkArchitecture<T> architecture, DeepSeekVL2Options options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer) |
|
DeepSeekVL2(NeuralNetworkArchitecture<T> architecture, string modelPath, DeepSeekVL2Options 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 DeepSeek-VL2’s MoE + dynamic tiling architecture. |