PaLI<T>

Models & Types · AiDotNet.VisionLanguage.Generative

PaLI (Pathways Language and Image model): large-scale ViT-e vision encoder + mT5 text decoder.

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

Implements: IGenerativeVisionLanguageModel<T>

For Beginners

PaLI (Pathways Language and Image model) from Google combines the largest dense ViT encoder (ViT-e with 4 billion parameters) with a multilingual mT5 text encoder-decoder. Visual tokens are linearly projected and prepended to text input, then the mT5 model processes the combined sequence. Its multilingual training enables vision-language tasks across 100+ languages. Default values follow the original paper settings.

How It Works

PaLI (Chen et al., ICLR 2023) combines a ViT-e vision encoder with an mT5 text encoder-decoder. Visual tokens from the ViT are linearly projected and prepended to the text input tokens. The mT5 encoder-decoder then processes the mixed visual-text sequence to generate text output.

References:

  • Paper: “PaLI: A Jointly-Scaled Multilingual Language-Image Model” (Chen et al., ICLR 2023)

Example

// Create a PaLI model for multilingual vision-language understanding
// using ViT-e encoder + mT5 encoder-decoder across 100+ languages
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 PaLI<double>(architecture, "pali.onnx");
            
// Training mode with native layers
var trainModel = new PaLI<double>(architecture, new PaLIOptions());

Constructors

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

Properties

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

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
Tensor<T> EncodeImage(Tensor<T> image)
Tensor<T> GenerateFromImage(Tensor<T> image, string prompt) Generates text using PaLI’s visual-token prepending architecture.