ViLBERT<T>
Models & Types · AiDotNet.VisionLanguage.Foundational
ViLBERT (Vision-and-Language BERT) with co-attention between parallel vision and language streams.
Inheritance: NeuralNetworkBase<T> → VisionLanguageModelBase<T> → ViLBERT<T>
Implements: IVisionLanguageFusionModel<T>
For Beginners
ViLBERT is a vision-language model. Default values follow the original paper settings.
How It Works
ViLBERT (Lu et al., NeurIPS 2019) extends BERT to a dual-stream architecture where separate vision and language transformers interact through co-attention layers. Each co-attention layer computes attention from one modality’s queries to the other modality’s keys/values.
References:
- Paper: “ViLBERT: Pretraining Task-Agnostic Visiolinguistic Representations for Vision-and-Language Tasks” (Lu et al., NeurIPS 2019)
Example
// Create a ViLBERT model for vision-and-language representation
// with dual-stream co-attention between vision and language transformers
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 ViLBERT<double>(architecture, "vilbert.onnx");
// Training mode with native layers
var trainModel = new ViLBERT<double>(architecture, new ViLBERTOptions());
Constructors
| Constructor | Summary |
|---|---|
ViLBERT(NeuralNetworkArchitecture<T> architecture, ViLBERTOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer) |
|
ViLBERT(NeuralNetworkArchitecture<T> architecture, string modelPath, ViLBERTOptions options) |
Properties
| Property | Summary |
|---|---|
int EmbeddingDimension { get; } |
|
int FusionEmbeddingDim { get; } |
|
int MaxSequenceLength { get; } |
Methods
| Method | Summary |
|---|---|
Dictionary<string, Tensor<T>> GetNamedLayerActivations(Tensor<T> input) |
|
ModelMetadata<T> GetModelMetadata() |
|
T ComputeMatchingScore(Tensor<T> image, string text) |
|
Tensor<T> EncodeImage(Tensor<T> image) |
|
Tensor<T> ForwardForTraining(Tensor<T> input) |
Same dual-stream routing as Predict, applied to the tape-recorded forward pass used by TrainWithTape. |
Tensor<T> FuseImageText(Tensor<T> image, string text) |