OpenFlamingo<T>
Models & Types · AiDotNet.VisionLanguage.Generative
OpenFlamingo: open-source reproduction of Flamingo with perceiver resampler.
Inheritance: NeuralNetworkBase<T> → VisionLanguageModelBase<T> → OpenFlamingo<T>
Implements: IGenerativeVisionLanguageModel<T>
For Beginners
OpenFlamingo is an open-source reproduction of DeepMind’s proprietary Flamingo model. It uses a perceiver resampler to compress visual features into a fixed number of latent tokens, then injects them into an LLM decoder (LLaMA or MPT) via gated cross-attention layers. This architecture excels at few-shot visual tasks — given a few image-text examples, it can generalize to new queries. Default values follow the original paper settings.
How It Works
OpenFlamingo (Awadalla et al., 2023) replicates DeepMind’s Flamingo architecture in an open-source setting. It uses a CLIP ViT vision encoder, a perceiver resampler to compress visual features into a fixed number of latent tokens, and gated cross-attention layers interleaved within an LLM decoder (e.g., LLaMA, MPT) to condition text generation on visual information.
References:
- Paper: “OpenFlamingo: An Open-Source Framework for Training Large Autoregressive Vision-Language Models” (Awadalla et al., 2023)
Example
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.TwoDimensional,
taskType: NeuralNetworkTaskType.ImageClassification,
inputHeight: 224, inputWidth: 224, inputDepth: 3, outputSize: 512);
var trainModel = new OpenFlamingo<double>(architecture, new OpenFlamingoOptions());
Constructors
| Constructor | Summary |
|---|---|
OpenFlamingo(NeuralNetworkArchitecture<T> architecture, OpenFlamingoOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer) |
|
OpenFlamingo(NeuralNetworkArchitecture<T> architecture, string modelPath, OpenFlamingoOptions 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 OpenFlamingo’s open-source Flamingo architecture. |