Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
5b93891
Initial integration of Omnivinci
lashahub Feb 18, 2026
ad39c78
Working stage in v5
lashahub Feb 18, 2026
8bbf21e
Initial converter
lashahub Feb 18, 2026
2037118
Flat converter
lashahub Feb 19, 2026
1af74c4
Whisper 128 features
lashahub Feb 19, 2026
9ebf8fd
Remove from_pretrained
lashahub Feb 19, 2026
01c91d7
Migrate
lashahub Feb 19, 2026
72d9068
Remove redundancy
lashahub Feb 19, 2026
2f5120c
Migrate
lashahub Feb 19, 2026
67aabd1
Cleanup the processor
lashahub Feb 19, 2026
47077f9
Simplify audio tower
lashahub Feb 19, 2026
05e08c2
make style
lashahub Feb 19, 2026
d77d738
Removed soft_cross_entropy
lashahub Feb 19, 2026
4f6d41f
Remove _build_model_from_config_mapping
lashahub Feb 19, 2026
8a54a07
Remove redundant configs for MM projectors
lashahub Feb 19, 2026
0f463d8
Move WhisperFeatureExtractor from modeling to processing
lashahub Feb 19, 2026
d95fd65
Remove DownSampleBlock
lashahub Feb 19, 2026
6dd0620
Removed extra vision tower classes
lashahub Feb 19, 2026
7da7270
Remove custom attn handler
lashahub Feb 19, 2026
28593ad
Simplify config loading
lashahub Feb 19, 2026
b1b2656
Cleanup media
lashahub Feb 22, 2026
3d0d671
Easier inference
lashahub Feb 22, 2026
6a6ddca
Move tokenizer to processor
lashahub Feb 22, 2026
b01cdae
Move apply_chat_template to processor
lashahub Feb 22, 2026
12caedb
Use native HF media loader
lashahub Feb 27, 2026
a9d3e81
Fix mismatch due to fp64 vs fp32
lashahub Feb 27, 2026
5ec0673
Cleaner inference
lashahub Feb 27, 2026
8324564
Embed in forward()
lashahub Feb 27, 2026
a5d7097
Use **inputs
lashahub Feb 27, 2026
cc1abae
Cleaner inference
lashahub Feb 27, 2026
dcc272a
AutoModel and AutoProcessor
lashahub Feb 28, 2026
4e4c6c4
Update converter
lashahub Feb 28, 2026
fc59394
Usable OmniVinci
lashahub Feb 28, 2026
e614a6e
Processor aligned with vLLM
lashahub Mar 9, 2026
feb38ee
Fix a processor bug
lashahub Mar 9, 2026
be4774b
OmniVinci -> AudioVisualFlamingo
lashahub Mar 10, 2026
545db6f
Fix converter
lashahub Mar 10, 2026
37c11f7
Clean up configs
lashahub Mar 10, 2026
5d46594
Clean up processor
lashahub Mar 10, 2026
5aeff1e
Clean up config
lashahub Mar 10, 2026
747bd6e
Clean up media loading
lashahub Mar 21, 2026
32864da
Clean up step #1
lashahub Mar 21, 2026
1f29ac8
Merge files
lashahub Mar 21, 2026
90ad719
Remove redundant deps
lashahub Mar 21, 2026
93393ef
Use modular
lashahub Apr 19, 2026
b142abc
Reuse modules
lashahub Apr 19, 2026
83a84c0
Merge origin/main into add_AudioVisualFlamingo
lashahub Apr 19, 2026
3531727
Fix legacy SigLIP AVF checkpoint loading
lashahub Apr 19, 2026
cc81ee1
Clean up #1
lashahub Apr 21, 2026
32296a7
Clean up #2
lashahub Apr 21, 2026
eaae06c
Clean up #3
lashahub Apr 21, 2026
064522c
Clean up #4
lashahub Apr 21, 2026
09bed97
Clean up #5
lashahub Apr 21, 2026
f035bc7
Add docs
lashahub Apr 22, 2026
e573b0e
Merge branch 'main' into add_AudioVisualFlamingo
lashahub Apr 22, 2026
46dc788
make fix-repo
lashahub Apr 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions c.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

rm -rf /fs/nexus-projects/JSALT_workshop/lasha/Dev/audiovisualflamingo-hf
python src/transformers/models/audiovisualflamingo/convert_audiovisualflamingo_to_hf.py \
--model_dir /fs/nexus-projects/JSALT_workshop/lasha/Dev/audiovisualflamingo \
--output_dir /fs/nexus-projects/JSALT_workshop/lasha/Dev/audiovisualflamingo-hf \
--push_to_hub SreyanG-NVIDIA/audiovisualflamingo-hf
2 changes: 2 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,8 @@
title: Aria
- local: model_doc/audioflamingo3
title: AudioFlamingo3
- local: model_doc/audiovisualflamingo
title: AudioVisualFlamingo
- local: model_doc/aya_vision
title: AyaVision
- local: model_doc/blip
Expand Down
179 changes: 179 additions & 0 deletions docs/source/en/model_doc/audiovisualflamingo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<!--Copyright 2026 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->
*This model was released on {release_date} and added to Hugging Face Transformers on 2026-04-22.*

# Audio-Visual Flamingo

<div class="flex flex-wrap space-x-1">
<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&logo=pytorch&logoColor=white">
<img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat">
<img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white">
</div>

## Overview

Audio-Visual Flamingo (AVF) is a fully open audio-visual large language model for joint understanding and reasoning over
audio, images, and videos. In Transformers, AVF pairs a SigLIP vision tower with an AF-Whisper audio encoder and a
Qwen2.5-7B causal language model, with separate projectors for visual and audio features.

For video plus audio inputs, AVF does not simply concatenate visual and sound features. Instead, it aligns synchronized
visual and audio chunks, interleaves them along the time axis, applies Constrained Rotary Time Embeddings (CRTE), and
then feeds the fused sequence to the language model. In the Transformers interface, the processor prepares the required
media placeholder spans and the model replaces those token positions with projected multimodal embeddings during the
forward pass.

The model checkpoint is available at: [nvidia/audio-visual-flamingo-hf](https://huggingface.co/nvidia/audio-visual-flamingo-hf)

Highlights:

- Unified prompting across image, video, and audio inputs.
- Joint video plus audio understanding from a single container when `load_audio_in_video=True`.
- Dynamic-S2 visual preprocessing for high-resolution images and sampled video frames.
- Temporal audio-visual interleaving with CRTE before the Qwen2.5-7B backbone.
- Replace-in-place multimodal fusion through processor-prepared media spans and projected media embeddings.

This model was contributed by [Lasha Koroshinadze](https://huggingface.co/lashahub) and [Eric Bezzam](https://huggingface.co/bezzam).

### Paper

Audio-Visual Flamingo: Open Audio-Visual Intelligence for Long and Complex Videos
S. Ghosh, A. Goel, K. Jayakumar, L. Koroshinadze, N. Anand, Z. Kong, S. Gururani, S. Lee, J. Kim, A. Aljafari, C.-H. H. Yang, S. Kim, R. Duraiswami, D. Manocha, M. Shoeybi, B. Catanzaro, M.-Y. Liu, W. Ping
NVIDIA and University of Maryland

The paper presents AVF as a fully open audio-visual model trained for long and complex real-world videos. It introduces
AVF-Skills, a three-stage training curriculum, and Temporal Audio-Visual Interleaved Chain-of-Thought (TAVIT) for
temporally grounded reasoning. The paper also discusses a streaming TTS component; this page focuses on the public
conditional-generation checkpoint for multimodal understanding and text generation.

## Usage

### Audio-Visual Instruct Mode

The model supports chat-template conversations mixing text, images, videos, and audio. When
`load_audio_in_video=True`, a `video` content item can contribute both sampled frames and audio from the same
container.

➡️ video + audio from a single container

```python
from transformers import AudioVisualFlamingoForConditionalGeneration, AutoProcessor

model_id = "nvidia/audio-visual-flamingo-hf"

model = AudioVisualFlamingoForConditionalGeneration.from_pretrained(
model_id,
device_map="auto",
load_audio_in_video=True,
).eval()
processor = AutoProcessor.from_pretrained(
model_id,
padding_side="left",
use_fast=False,
load_audio_in_video=True,
num_video_frames=128,
audio_chunk_length="max_3600",
)

conversation = [
{
"role": "user",
"content": [
{"type": "video", "video": "/path/to/video.mp4"},
{
"type": "text",
"text": "Describe both the visual scene and the spoken or environmental audio content.",
},
],
}
]

inputs = processor.apply_chat_template(
conversation,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
).to(model.device)

generated_ids = model.generate(
**inputs,
max_new_tokens=512,
do_sample=False,
)

new_tokens = generated_ids[:, inputs.input_ids.shape[1] :]
print(processor.batch_decode(new_tokens, skip_special_tokens=True)[0])
```

### Prompt format

AVF uses chat-template content items with media placeholders:

- `{"type": "image", "image": "/path/to/image.jpg"}`
- `{"type": "video", "video": "/path/to/video.mp4"}`
- `{"type": "audio", "path": "/path/to/audio.wav"}`
- `{"type": "text", "text": "Describe the media."}`

You can mix these items within the same turn. When `load_audio_in_video=True`, a `video` content item can contribute
both visual frames and audio features from the same container.

## How the model works

### Architecture

* **Vision tower**
SigLIP encodes images and sampled video frames. AVF uses Dynamic-S2 preprocessing to preserve fine-grained detail in
high-resolution visual inputs while keeping the visual token sequence compact.

* **Audio tower**
AVF uses AF-Whisper, the Audio Flamingo series' Whisper-based audio encoder. Audio is resampled to 16 kHz mono,
converted to 128-bin log-mel spectrograms, and encoded in non-overlapping 30-second windows for long-form audio.

* **Multimodal projectors**
Two 2-layer MLP projectors map visual and audio encoder features into the shared language-model hidden size.

* **Temporal interleaving + CRTE**
After projection, synchronized visual and audio chunks are interleaved along the time axis rather than naively
concatenated. AVF then applies Constrained Rotary Time Embeddings (CRTE) to the interleaved sequence so the language
model can preserve absolute temporal structure while attending across co-occurring visual and auditory events.

* **Language model**
A decoder-only multimodal language model built on a Qwen2.5-7B text backbone. In the Transformers interface, the
processor expands the required media spans and the model replaces those token positions with projected multimodal
embeddings during the forward pass; subsequent decode steps reuse the language-model cache.

### Processor-level alignment

1. The processor loads images, sampled video frames, and audio waveforms from the chat-template content items.
2. For `video` inputs, it can also decode the container audio stream when `load_audio_in_video=True`, so a single
video item yields synchronized visual and audio features.
3. Visual inputs go through the Dynamic-S2 preprocessing path, while audio inputs are converted into AF-Whisper
features with temporal chunk metadata for later alignment.
4. During the forward pass, the model projects the visual and audio features, interleaves synchronized chunks along the
time axis, applies CRTE, and replaces the prepared media spans with the fused multimodal embeddings.

## AudioVisualFlamingoConfig

[[autodoc]] AudioVisualFlamingoConfig

## AudioVisualFlamingoProcessor

[[autodoc]] AudioVisualFlamingoProcessor
- __call__

## AudioVisualFlamingoForConditionalGeneration

[[autodoc]] AudioVisualFlamingoForConditionalGeneration
- forward
48 changes: 48 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from transformers import AutoModel, AutoProcessor


model_path = "nvidia/audio-visual-flamingo-hf"
model_kwargs = {
"load_audio_in_video": True,
}
processor_kwargs = {
"load_audio_in_video": True,
"num_video_frames": 128,
"audio_chunk_length": "max_3600",
}

model = AutoModel.from_pretrained(
model_path,
device_map="auto",
**model_kwargs,
).eval()
processor = AutoProcessor.from_pretrained(model_path, padding_side="left", use_fast=False, **processor_kwargs)

conversation = [
{
"role": "user",
"content": [
{"type": "video", "video": "nvidia.mp4"},
{
"type": "text",
"text": "Assess the video, followed by a detailed description of it's video and audio contents.",
},
],
}
]

inputs = processor.apply_chat_template(
conversation,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
).to(model.device)

output_ids = model.generate(
**inputs,
max_new_tokens=1024,
do_sample=False,
)

generated_ids = output_ids[:, inputs["input_ids"].shape[1] :]
print(processor.batch_decode(generated_ids, skip_special_tokens=True)[0])
Binary file added nvidia.mp4
Binary file not shown.
1 change: 1 addition & 0 deletions src/transformers/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from .aria import *
from .audio_spectrogram_transformer import *
from .audioflamingo3 import *
from .audiovisualflamingo import *
from .auto import *
from .autoformer import *
from .aya_vision import *
Expand Down
29 changes: 29 additions & 0 deletions src/transformers/models/audiovisualflamingo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2026 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING

from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure


if TYPE_CHECKING:
from .configuration_audiovisualflamingo import *
from .modeling_audiovisualflamingo import *
from .processing_audiovisualflamingo import *
else:
import sys

_file = globals()["__file__"]
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
Loading
Loading