Qwen 2 Audio Instruct Dynamic Fp8
Qwen2-Audio是Qwen大音頻語言模型系列的最新版本,能夠接收多種音頻信號輸入,並根據語音指令執行音頻分析或直接生成文本響應。
下載量 24
發布時間 : 4/24/2025
模型概述
Qwen2-Audio支持語音聊天和音頻分析兩種交互模式,能夠處理音頻輸入並生成文本響應,適用於多種音頻理解任務。
模型特點
多模式交互
支持語音聊天和音頻分析兩種交互模式,用戶可以通過語音或文本指令與模型交互。
音頻理解
能夠處理多種音頻信號輸入,包括語音、環境音等,並進行理解和分析。
文本生成
根據音頻輸入生成自然語言文本響應,適用於對話和問答場景。
模型能力
音頻理解
文本生成
語音交互
音頻分析
使用案例
語音交互
語音聊天
用戶無需輸入文本,即可與模型進行自由語音交互。
生成自然語言文本響應
音頻分析
音頻內容理解
用戶提供音頻和文本指令,模型進行分析並生成響應。
識別音頻內容並生成描述
🚀 通義千問/Qwen2-Audio-7B-Instruct-FP8
通義千問2-Audio(Qwen2-Audio)是全新系列的大型音頻語言模型,能夠接收多種音頻信號輸入,並根據語音指令進行音頻分析或直接給出文本回復。本項目提供了語音聊天和音頻分析兩種不同的音頻交互模式,同時發佈了預訓練模型通義千問2-Audio-7B和聊天模型通義千問2-Audio-7B-Instruct。
🚀 快速開始
若要在 vllm 中啟動,請運行以下命令:
vllm serve mlinmg/Qwen-2-Audio-Instruct-dynamic-fp8
✨ 主要特性
通義千問2-Audio 具備以下兩種音頻交互模式:
- 語音聊天:用戶無需輸入文本,即可與通義千問2-Audio 自由進行語音交互。
- 音頻分析:用戶在交互過程中可提供音頻和文本指令進行分析。
📦 安裝指南
通義千問2-Audio 的代碼已集成在最新的 Hugging face transformers 中,建議使用以下命令從源代碼進行構建,否則可能會遇到 KeyError: 'qwen2-audio'
錯誤:
pip install git+https://github.com/huggingface/transformers
💻 使用示例
基礎用法
語音聊天推理
在語音聊天模式下,用戶無需輸入文本,即可與通義千問2-Audio 自由進行語音交互:
from io import BytesIO
from urllib.request import urlopen
import librosa
from transformers import Qwen2AudioForConditionalGeneration, AutoProcessor
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct")
model = Qwen2AudioForConditionalGeneration.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct", device_map="auto")
conversation = [
{"role": "user", "content": [
{"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/guess_age_gender.wav"},
]},
{"role": "assistant", "content": "Yes, the speaker is female and in her twenties."},
{"role": "user", "content": [
{"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/translate_to_chinese.wav"},
]},
]
text = processor.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False)
audios = []
for message in conversation:
if isinstance(message["content"], list):
for ele in message["content"]:
if ele["type"] == "audio":
audios.append(librosa.load(
BytesIO(urlopen(ele['audio_url']).read()),
sr=processor.feature_extractor.sampling_rate)[0]
)
inputs = processor(text=text, audios=audios, return_tensors="pt", padding=True)
inputs.input_ids = inputs.input_ids.to("cuda")
generate_ids = model.generate(**inputs, max_length=256)
generate_ids = generate_ids[:, inputs.input_ids.size(1):]
response = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
音頻分析推理
在音頻分析模式下,用戶可提供音頻和文本指令進行分析:
from io import BytesIO
from urllib.request import urlopen
import librosa
from transformers import Qwen2AudioForConditionalGeneration, AutoProcessor
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct")
model = Qwen2AudioForConditionalGeneration.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct", device_map="auto")
conversation = [
{'role': 'system', 'content': 'You are a helpful assistant.'},
{"role": "user", "content": [
{"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "What's that sound?"},
]},
{"role": "assistant", "content": "It is the sound of glass shattering."},
{"role": "user", "content": [
{"type": "text", "text": "What can you do when you hear that?"},
]},
{"role": "assistant", "content": "Stay alert and cautious, and check if anyone is hurt or if there is any damage to property."},
{"role": "user", "content": [
{"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/1272-128104-0000.flac"},
{"type": "text", "text": "What does the person say?"},
]},
]
text = processor.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False)
audios = []
for message in conversation:
if isinstance(message["content"], list):
for ele in message["content"]:
if ele["type"] == "audio":
audios.append(
librosa.load(
BytesIO(urlopen(ele['audio_url']).read()),
sr=processor.feature_extractor.sampling_rate)[0]
)
inputs = processor(text=text, audios=audios, return_tensors="pt", padding=True)
inputs.input_ids = inputs.input_ids.to("cuda")
generate_ids = model.generate(**inputs, max_length=256)
generate_ids = generate_ids[:, inputs.input_ids.size(1):]
response = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
高級用法
批量推理
本項目還支持批量推理:
from io import BytesIO
from urllib.request import urlopen
import librosa
from transformers import Qwen2AudioForConditionalGeneration, AutoProcessor
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct")
model = Qwen2AudioForConditionalGeneration.from_pretrained("Qwen/Qwen2-Audio-7B-Instruct", device_map="auto")
conversation1 = [
{"role": "user", "content": [
{"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "What's that sound?"},
]},
{"role": "assistant", "content": "It is the sound of glass shattering."},
{"role": "user", "content": [
{"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/f2641_0_throatclearing.wav"},
{"type": "text", "text": "What can you hear?"},
]}
]
conversation2 = [
{"role": "user", "content": [
{"type": "audio", "audio_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-Audio/audio/1272-128104-0000.flac"},
{"type": "text", "text": "What does the person say?"},
]},
]
conversations = [conversation1, conversation2]
text = [processor.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False) for conversation in conversations]
audios = []
for conversation in conversations:
for message in conversation:
if isinstance(message["content"], list):
for ele in message["content"]:
if ele["type"] == "audio":
audios.append(
librosa.load(
BytesIO(urlopen(ele['audio_url']).read()),
sr=processor.feature_extractor.sampling_rate)[0]
)
inputs = processor(text=text, audios=audios, return_tensors="pt", padding=True)
inputs['input_ids'] = inputs['input_ids'].to("cuda")
inputs.input_ids = inputs.input_ids.to("cuda")
generate_ids = model.generate(**inputs, max_length=256)
generate_ids = generate_ids[:, inputs.input_ids.size(1):]
response = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)
📚 詳細文檔
如需瞭解更多詳細信息,請參考我們的 博客、GitHub 和 報告。
📄 許可證
本項目採用 Apache-2.0 許可證。
📖 引用
如果您覺得我們的工作有幫助,請引用以下文獻:
@article{Qwen2-Audio,
title={Qwen2-Audio Technical Report},
author={Chu, Yunfei and Xu, Jin and Yang, Qian and Wei, Haojie and Wei, Xipin and Guo, Zhifang and Leng, Yichong and Lv, Yuanjun and He, Jinzheng and Lin, Junyang and Zhou, Chang and Zhou, Jingren},
journal={arXiv preprint arXiv:2407.10759},
year={2024}
}
@article{Qwen-Audio,
title={Qwen-Audio: Advancing Universal Audio Understanding via Unified Large-Scale Audio-Language Models},
author={Chu, Yunfei and Xu, Jin and Zhou, Xiaohuan and Yang, Qian and Zhang, Shiliang and Yan, Zhijie and Zhou, Chang and Zhou, Jingren},
journal={arXiv preprint arXiv:2311.07919},
year={2023}
}
Phi 4 Multimodal Instruct
MIT
Phi-4-multimodal-instruct是一款輕量級開源多模態基礎模型,融合了Phi-3.5和4.0模型的語言、視覺及語音研究數據。支持文本、圖像和音頻輸入,生成文本輸出,並具備128K token的上下文長度。
文本生成音頻
Transformers 支持多種語言

P
microsoft
584.02k
1,329
Ultravox V0 5 Llama 3 2 1b
MIT
Ultravox是一個基於Llama3.2-1B和Whisper-large-v3構建的多模態語音大語言模型,能夠同時處理語音和文本輸入。
文本生成音頻
Transformers 支持多種語言

U
fixie-ai
167.25k
21
Seamless M4t V2 Large
SeamlessM4T v2 是 Facebook 發佈的大規模多語言多模態機器翻譯模型,支持近100種語言的語音和文本翻譯。
文本生成音頻
Transformers 支持多種語言

S
facebook
64.59k
821
Ultravox V0 3
MIT
Ultravox 是一個基於 Llama3.1-8B-Instruct 和 Whisper-small 構建的多模態語音大語言模型,能夠同時處理語音和文本輸入。
文本生成音頻
Transformers 英語

U
fixie-ai
48.30k
17
Ultravox V0 5 Llama 3 1 8b
MIT
Ultravox是一款基於Llama3.1-8B-Instruct和whisper-large-v3-turbo構建的多模態語音大語言模型,能夠同時處理語音和文本輸入。
文本生成音頻
Transformers 支持多種語言

U
fixie-ai
17.86k
12
Hf Seamless M4t Medium
SeamlessM4T 是一個多語言翻譯模型,支持語音和文本的輸入輸出,實現跨語言交流。
文本生成音頻
Transformers

H
facebook
14.74k
30
Granite Speech 3.3 8b
Apache-2.0
專為自動語音識別(ASR)和自動語音翻譯(AST)設計的緊湊高效語音語言模型,採用雙階段設計處理音頻和文本
文本生成音頻
Transformers 英語

G
ibm-granite
5,532
35
Voila Tokenizer
MIT
Voila是一個大型語音-語言基礎模型系列,旨在提升人機交互體驗,支持多種音頻任務和語言。
文本生成音頻
Transformers 支持多種語言

V
maitrix-org
4,912
3
Hf Seamless M4t Large
SeamlessM4T 是一個支持多語言語音和文本翻譯的統一模型,能夠實現語音到語音、語音到文本、文本到語音和文本到文本的翻譯任務。
文本生成音頻
Transformers

H
facebook
4,648
57
Minicpm O 2 6 Int4
MiniCPM-o 2.6的int4量化版本,顯著降低GPU顯存佔用,支持多模態處理能力。
文本生成音頻
Transformers 其他

M
openbmb
4,249
42
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98