Gemma3<T>

Models & Types · AiDotNet.VisionLanguage.InstructionTuned

Gemma 3: Google’s 3B-72B VLM with Native Dynamic Resolution ViT and 128k context.

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

Implements: IInstructionTunedVLM<T>

For Beginners

Gemma 3 from Google is a family of open vision-language models ranging from 3 billion to 72 billion parameters. It can process images at their native resolution using Dynamic Resolution ViT, meaning it adapts to each image’s actual size rather than forcing all images to a fixed size. With a 128K token context window, it can handle very long conversations and documents. It supports 29 languages and uses a SigLIP-based vision encoder with an MLP projection to connect visual features to the language model. Default values follow the original paper settings.

How It Works

Gemma 3 (Google, 2025) is a family of vision-language models ranging from 3B to 72B parameters. It features Native Dynamic Resolution ViT for flexible image processing, 128k token context window, and support for 29 languages. Uses SigLIP-based vision encoder with MLP projection.

References:

  • Paper: “Gemma 3 Technical Report” (Google, 2025)

Example

// Create a Gemma 3 model for multilingual visual understanding
// with dynamic resolution ViT and 128K context window
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 Gemma3<double>(architecture, "gemma3.onnx");
            
// Training mode with native layers
var trainModel = new Gemma3<double>(architecture, new Gemma3Options());

Constructors

Constructor Summary
Gemma3(NeuralNetworkArchitecture<T> architecture, Gemma3Options options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer)
Gemma3(NeuralNetworkArchitecture<T> architecture, string modelPath, Gemma3Options 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 Gemma 3’s Native Dynamic Resolution architecture.