Audio-Text-to-Text
PEFT
Safetensors
audio
audio-reasoning
reinforcement-learning
grpo
self-supervised-learning
lora
Instructions to use NearAndDear98/Audio-R1-AF-Next-Think with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use NearAndDear98/Audio-R1-AF-Next-Think with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("nvidia/audio-flamingo-next-think-hf") model = PeftModel.from_pretrained(base_model, "NearAndDear98/Audio-R1-AF-Next-Think") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- README.md +77 -0
- adapter_config.json +40 -0
- adapter_model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: nvidia-oneway-noncommercial
|
| 4 |
+
license_link: https://huggingface.co/nvidia/audio-flamingo-next-think-hf
|
| 5 |
+
base_model: nvidia/audio-flamingo-next-think-hf
|
| 6 |
+
library_name: peft
|
| 7 |
+
pipeline_tag: audio-text-to-text
|
| 8 |
+
tags:
|
| 9 |
+
- audio
|
| 10 |
+
- audio-reasoning
|
| 11 |
+
- reinforcement-learning
|
| 12 |
+
- grpo
|
| 13 |
+
- self-supervised-learning
|
| 14 |
+
- lora
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# Audio-R1 — Audio Flamingo Next Think (LoRA)
|
| 18 |
+
|
| 19 |
+
LoRA adapter for [nvidia/audio-flamingo-next-think-hf](https://huggingface.co/nvidia/audio-flamingo-next-think-hf) trained with **Audio-R1**, an RL post-training framework that uses audio self-supervised tasks as a source of verifiable rewards.
|
| 20 |
+
|
| 21 |
+
- **Paper:** [Audio-R1: Audio Reasoning through Reinforcement Learning on Self-Supervised Tasks](https://arxiv.org/abs/2610.34609)
|
| 22 |
+
- **Project page:** https://ijihoon98.github.io/Audio-R1/
|
| 23 |
+
|
| 24 |
+
## Training
|
| 25 |
+
|
| 26 |
+
| | |
|
| 27 |
+
|---|---|
|
| 28 |
+
| Method | GRPO (ms-swift), 8 rollouts per prompt, temperature 0.8, β = 0.04 |
|
| 29 |
+
| Tasks | Identity Detection + Region Inpainting (joint, 2 tasks; Temporal Ordering is left out for this backbone, see the paper's appendix) |
|
| 30 |
+
| Rewards | think-format guard + answer-letter correctness |
|
| 31 |
+
| Audio sources | LibriSpeech, VoxCeleb2, MELD, CoVoST2 (en/zh), multi-speaker mixtures, AF-Think |
|
| 32 |
+
| LoRA | r = 8, α = 32, dropout 0.05, language model + audio projector; audio encoder frozen |
|
| 33 |
+
| Optimization | lr 5e-6, 1 epoch, 1,906 steps, effective batch 32 prompts |
|
| 34 |
+
|
| 35 |
+
## Usage
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
import librosa, torch
|
| 39 |
+
from peft import PeftModel
|
| 40 |
+
from transformers import AutoProcessor, MusicFlamingoForConditionalGeneration
|
| 41 |
+
|
| 42 |
+
base = "nvidia/audio-flamingo-next-think-hf"
|
| 43 |
+
processor = AutoProcessor.from_pretrained(base)
|
| 44 |
+
model = MusicFlamingoForConditionalGeneration.from_pretrained(base, dtype=torch.float32, device_map="auto")
|
| 45 |
+
model = PeftModel.from_pretrained(model, "NearAndDear98/Audio-R1-AF-Next-Think").eval()
|
| 46 |
+
|
| 47 |
+
SYSTEM = (
|
| 48 |
+
"Your response MUST contain two parts in this exact order: "
|
| 49 |
+
"1. Your reasoning enclosed within <think> </think> tags. "
|
| 50 |
+
"2. The final answer — a single letter for the correct option — enclosed "
|
| 51 |
+
"within <answer> </answer> tags."
|
| 52 |
+
)
|
| 53 |
+
question = "<sound>\nQuestion ...\n(A) ...\n(B) ...\n(C) ...\n(D) ..." # one <sound> per audio
|
| 54 |
+
prompt = processor.apply_chat_template(
|
| 55 |
+
[{"role": "system", "content": SYSTEM}, {"role": "user", "content": question}],
|
| 56 |
+
tokenize=False, add_generation_prompt=True,
|
| 57 |
+
)
|
| 58 |
+
audios = [librosa.load("example.wav", sr=16000, mono=True)[0]]
|
| 59 |
+
inputs = processor(text=[prompt], audio=audios, return_tensors="pt").to(model.device)
|
| 60 |
+
out = model.generate(**inputs, max_new_tokens=512, do_sample=False)
|
| 61 |
+
print(processor.batch_decode(out[:, inputs["input_ids"].shape[-1]:], skip_special_tokens=True)[0])
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
## License
|
| 65 |
+
|
| 66 |
+
The base model is released under the NVIDIA OneWay Noncommercial License; this adapter inherits those terms and is for **non-commercial research use only**.
|
| 67 |
+
|
| 68 |
+
## Citation
|
| 69 |
+
|
| 70 |
+
```bibtex
|
| 71 |
+
@article{jeong2026audior1,
|
| 72 |
+
title = {Audio-R1: Audio Reasoning through Reinforcement Learning on Self-Supervised Tasks},
|
| 73 |
+
author = {Jeong, Jihoon and Ravanelli, Mirco and Wang, Zhepei and Subakan, Cem},
|
| 74 |
+
journal = {arXiv preprint arXiv:2610.34609},
|
| 75 |
+
year = {2026}
|
| 76 |
+
}
|
| 77 |
+
```
|
adapter_config.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "nvidia/audio-flamingo-next-think-hf",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 32,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.05,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": [],
|
| 26 |
+
"peft_type": "LORA",
|
| 27 |
+
"peft_version": "0.19.1",
|
| 28 |
+
"qalora_group_size": 16,
|
| 29 |
+
"r": 8,
|
| 30 |
+
"rank_pattern": {},
|
| 31 |
+
"revision": null,
|
| 32 |
+
"target_modules": "^(model\\.language_model(?=\\.).*\\.(q_proj|gate_proj|up_proj|down_proj|v_proj|k_proj|o_proj)|model\\.multi_modal_projector(?=\\.).*\\.(linear_1|linear_2))$",
|
| 33 |
+
"target_parameters": null,
|
| 34 |
+
"task_type": "CAUSAL_LM",
|
| 35 |
+
"trainable_token_indices": null,
|
| 36 |
+
"use_bdlora": null,
|
| 37 |
+
"use_dora": false,
|
| 38 |
+
"use_qalora": false,
|
| 39 |
+
"use_rslora": false
|
| 40 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bcf735e89535cce3dd41f0c71b03254205c332aacf4e3ae4f374dac2d0f3707a
|
| 3 |
+
size 40621152
|