Audio Flamingo 3: Advancing Audio Intelligence with Fully Open Large Audio-Language Models
Description:
Audio Flamingo 3 (AF3) is a fully open, state-of-the-art Large Audio-Language Model (LALM) that advances reasoning and understanding across speech, sounds, and music. AF3 builds on previous work with innovations in:
1from transformers import AudioFlamingo3ForConditionalGeneration, AutoProcessor
23model_id ="nvidia/audio-flamingo-3-hf"4processor = AutoProcessor.from_pretrained(model_id)5model = AudioFlamingo3ForConditionalGeneration.from_pretrained(model_id, device_map="auto")67conversation =[8{9"role":"user",10"content":[11{12"type":"text",13"text":"Instruction: How does the tone of female speech change throughout the audio? Choose the correct option among the options below: (A) Sad to happy (B) Happy to sad (C) Neutral to happy (D) Happy to neutral.",14},15{"type":"audio","path":"https://huggingface.co/datasets/nvidia/AudioSkills/resolve/main/assets/000000786159.31.wav"},16],17},18{19"role":"assistant",20"content":[{"type":"text","text":"(A) Sad to happy"}],21},22{23"role":"user",24"content":[25{"type":"text","text":"Why do you think so?"},26],27},28]2930inputs = processor.apply_chat_template(31 conversation,32 tokenize=True,33 add_generation_prompt=True,34 return_dict=True,35).to(model.device)3637outputs = model.generate(**inputs, max_new_tokens=500)3839decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)40print(decoded_outputs)
Batch multiple conversations
python
1from transformers import AudioFlamingo3ForConditionalGeneration, AutoProcessor
23model_id ="nvidia/audio-flamingo-3-hf"4processor = AutoProcessor.from_pretrained(model_id)5model = AudioFlamingo3ForConditionalGeneration.from_pretrained(model_id, device_map="auto")67conversations =[8[9{10"role":"user",11"content":[12{"type":"text","text":"Transcribe the input speech."},13{14"type":"audio",15"path":"https://huggingface.co/datasets/nvidia/AudioSkills/resolve/main/assets/t_837b89f2-26aa-4ee2-bdf6-f73f0dd59b26.wav",16},17],18}19],20[21{22"role":"user",23"content":[24{25"type":"text",26"text":"This track feels really peaceful and introspective. What elements make it feel so calming and meditative?",27},28{"type":"audio","path":"https://huggingface.co/datasets/nvidia/AudioSkills/resolve/main/assets/FPSbCAANfbJLVSwD.mp3"},29],30}31],32]3334inputs = processor.apply_chat_template(35 conversations,36 tokenize=True,37 add_generation_prompt=True,38 return_dict=True,39).to(model.device)4041outputs = model.generate(**inputs, max_new_tokens=500)4243decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)44print(decoded_outputs)
Text-only and audio-only prompts
python
1# text-only2conv =[{"role":"user","content":[{"type":"text","text":"What is the capital of France?"}]}]3batch = processor.apply_chat_template(conv, tokenize=True, add_generation_prompt=True, return_dict=True).to(device)4print(processor.batch_decode(model.generate(**batch)[:, batch["input_ids"].shape[1]:], skip_special_tokens=True)[0])56# audio-only7conv =[{"role":"user","content":[{"type":"audio","path":"https://.../sample.wav"}]}]8batch = processor.apply_chat_template(conv, tokenize=True, add_generation_prompt=True, return_dict=True).to(device)9print(processor.batch_decode(model.generate(**batch)[:, batch["input_ids"].shape[1]:], skip_special_tokens=True)[0])
AF3 transcription checkpoints prepend answers with fixed assistant phrasing such as The spoken content of the audio is "<text>".. Passing strip_prefix=True removes that canned prefix and the surrounding quotes so you only keep the transcription.
1import os
23import torch
4from huggingface_hub import snapshot_download
5from peft import PeftModel
67from transformers import AudioFlamingo3ForConditionalGeneration, AutoProcessor
8910model_id ="nvidia/audio-flamingo-3-hf"11local_id = snapshot_download(model_id)1213processor = AutoProcessor.from_pretrained(local_id)14model = AudioFlamingo3ForConditionalGeneration.from_pretrained(local_id, device_map="auto")1516non_lora_path = os.path.join(local_id,"think","non_lora_trainables.bin")17non_lora_trainables = torch.load(non_lora_path)18model.load_state_dict(non_lora_trainables, strict=False)1920model = PeftModel.from_pretrained(model, local_id, subfolder="think")2122conversation =[23{24"role":"user",25"content":[26{27"type":"text",28"text":"Generate a detailed caption for the input audio, describing all notable speech, sound, and musical events comprehensively. In the caption, transcribe all spoken content by all speakers in the audio precisely.\nPlease think and reason about the input music before you respond.",29},30{31"type":"audio",32"path":"https://huggingface.co/datasets/nvidia/AudioSkills/resolve/main/assets/videoplayback_superman.wav",33},34],35}36]3738inputs = processor.apply_chat_template(39 conversation,40 tokenize=True,41 add_generation_prompt=True,42 return_dict=True,43).to(model.device)4445outputs = model.generate(**inputs, max_new_tokens=1024)4647decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)48print(decoded_outputs)
Training / Fine-tuning
python
1from transformers import AudioFlamingo3ForConditionalGeneration, AutoProcessor
23model_id ="nvidia/audio-flamingo-3-hf"4processor = AutoProcessor.from_pretrained(model_id)5model = AudioFlamingo3ForConditionalGeneration.from_pretrained(model_id, device_map="auto")6model.train()78conversation =[9[10{11"role":"user",12"content":[13{"type":"text","text":"Transcribe the input speech."},14{"type":"audio","path":"https://huggingface.co/datasets/nvidia/AudioSkills/resolve/main/assets/WhDJDIviAOg_120_10.mp3"},15],16},17{18"role":"assistant",19"content":[{"type":"text","text":"The transcription of the audio is 'summer follows spring the days grow longer and the nights are warm'."}],20}21],22[23{24"role":"user",25"content":[26{27"type":"text",28"text":"This track feels really peaceful and introspective. What elements make it feel so calming and meditative?",29},30{"type":"audio","path":"https://huggingface.co/datasets/nvidia/AudioSkills/resolve/main/assets/FPSbCAANfbJLVSwD.mp3"},31],32},33{34"role":"assistant",35"content":[{"type":"text","text":"The transcription of the audio is 'some transcription of the audio'."}],36}3738]39]4041inputs = processor.apply_chat_template(42 conversation,43 tokenize=True,44 add_generation_prompt=True,45 return_dict=True,46 output_labels=True,47).to(model.device)4849loss = model(**inputs).loss
50loss.backward()
Generation options
You can tune decoding similar to other text-generation models:
torch.compile is not compatible with Flash Attention 2 at the same time.
PyTorch SDPA
If Flash-Attention isn’t available, AF3 will use PyTorch scaled-dot product attention (SDPA) by default on supported PyTorch versions. You can set it explicitly:
Audio Flamingo 3 uses AF-Whisper unified audio encoder, MLP-based audio adaptor, Decoder-only LLM backbone (Qwen2.5-7B), and Streaming TTS module (AF3-Chat). Audio Flamingo 3 can take up to 10 minutes of audio inputs.
License / Terms of Use
The model is released under the NVIDIA OneWay Noncommercial License. Portions of the dataset generation are also subject to the Qwen Research License and OpenAI’s Terms of Use.
Deployment Geography
Global.
Use Case
Intended for researchers and developers to explore:
Our AI models are designed and/or optimized to run on NVIDIA GPU-accelerated systems (A100/H100). By leveraging NVIDIA’s hardware (e.g. GPU cores) and software frameworks (e.g., CUDA libraries), the model achieves faster training and inference times compared to CPU-only solutions.
AF3 is trained entirely on open-source audio data, organized into four novel, large-scale collections. For each dataset, we mention whether the dataset annotations are collected by Human or they are Automated i.e. generated using AI models.
The data collection method noted below applies for all datasets used for training and testing:
Data Collection Method: Human
Labeling Collection Method: Please see below:
Engine: HuggingFace Transformers Test Hardware: NVIDIA A100 80 GB
Ethical Considerations:
NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
Please report security vulnerabilities or NVIDIA AI Concerns here.
Acknowledgements
Built with Qwen, NVILA and the open audio-ML community.