ViLT<T>

Models & Types · AiDotNet.VisionLanguage.Foundational

ViLT (Vision-and-Language Transformer) with minimal architecture using patch embeddings.

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

Implements: IVisionLanguageFusionModel<T>

For Beginners

ViLT is a vision-language model. Default values follow the original paper settings.

How It Works

ViLT (Kim et al., ICML 2021) removes the CNN/object detector entirely, linearly embedding raw image patches and concatenating them with text tokens in a single transformer. This makes it 60x faster than region-feature-based models at comparable accuracy. Pre-trained with ITM and MLM.

References:

  • Paper: “ViLT: Vision-and-Language Transformer Without Convolution or Region Supervision” (Kim et al., ICML 2021)

Example

// Create a ViLT model for lightweight vision-language processing
// with direct patch embeddings and no CNN/object detector overhead
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 ViLT<double>(architecture, "vilt.onnx");
            
// Training mode with native layers
var trainModel = new ViLT<double>(architecture, new ViLTOptions());

Constructors

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

Properties

Property Summary
int EmbeddingDimension { get; }
int FusionEmbeddingDim { get; }
int MaxSequenceLength { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
T ComputeMatchingScore(Tensor<T> image, string text)
Tensor<T> EncodeImage(Tensor<T> image)
Tensor<T> FuseImageText(Tensor<T> image, string text)