Views
No views yet
peft and transformers libraries. Note that librosa is required for audio loading in this example.1import torch
2import librosa
3from transformers import Qwen2_5OmniThinkerForConditionalGeneration, Qwen2_5OmniProcessor
4from peft import PeftModel
5
6device = "cuda" if torch.cuda.is_available() else "cpu"
7model_id = "Qwen/Qwen2.5-Omni-7B"
8adapter_id = "ASU-GSL/Qwen-Audio-AHA"
9
10# Load base model and processor
11processor = Qwen2_5OmniProcessor.from_pretrained(model_id)
12model = Qwen2_5OmniThinkerForConditionalGeneration.from_pretrained(
13 model_id, torch_dtype="auto", device_map="auto"
14)
15
16# Load LoRA adapter
17model = PeftModel.from_pretrained(model, adapter_id)
18
19# Load Audio
20# Replace "example.wav" with the path to your audio file
21audio, _ = librosa.load("example.wav", sr=processor.feature_extractor.sampling_rate)
22prompt = "<|audio|>
23Describe the temporal order of events in this audio."
24inputs = processor(text=prompt, audios=audio, return_tensors="pt").to(device)
25
26# Generate
27generate_ids = model.generate(**inputs, max_new_tokens=256)
28print(processor.batch_decode(generate_ids, skip_special_tokens=True)[0])1@article{chen2025aha,
2 title={AHA: Aligning Large Audio-Language Models for Reasoning Hallucinations via Counterfactual Hard Negatives},
3 author={Chen, Yanxi and Zhu, Wenhui and Chen, Xiwen and Wang, Zhipeng and Li, Xin and Qiu, Peijie and Wang, Hao and Dong, Xuanzhao and Xiong, Yujian and Schneider, Anderson and others},
4 journal={arXiv preprint arXiv:2512.24052},
5 year={2025}
6}