Qwen 2 Audio Instruct Dynamic Fp8
Qwen2-AudioはQwen大規模音声言語モデルシリーズの最新バージョンで、複数の音声信号入力を処理し、音声指示に基づいて音声分析を実行したり、直接テキスト応答を生成したりできます。
ダウンロード数 24
リリース時間 : 4/24/2025
モデル概要
Qwen2-Audioは音声チャットと音声分析の2つのインタラクションモードをサポートし、音声入力を処理してテキスト応答を生成することができ、さまざまな音声理解タスクに適しています。
モデル特徴
マルチモードインタラクション
音声チャットと音声分析の2つのインタラクションモードをサポートし、ユーザーは音声またはテキスト指示でモデルと対話できます。
音声理解
音声、環境音など、さまざまな音声信号入力を処理し、理解と分析を行うことができます。
テキスト生成
音声入力に基づいて自然言語のテキスト応答を生成し、対話や質問応答のシナリオに適しています。
モデル能力
音声理解
テキスト生成
音声インタラクション
音声分析
使用事例
音声インタラクション
音声チャット
ユーザーはテキスト入力を必要とせず、自由に音声でモデルと対話できます。
自然言語のテキスト応答を生成
音声分析
音声コンテンツ理解
ユーザーが音声とテキスト指示を提供し、モデルが分析して応答を生成します。
音声コンテンツを識別し、説明を生成
🚀 Qwen/Qwen2-Audio-7B-Instruct-FP8
Qwen2-Audioは、Qwenの新シリーズの大規模音声言語モデルです。このモデルは、様々な音声信号入力を受け取り、音声分析や音声指示に対する直接的なテキスト応答を行うことができます。2つの異なる音声対話モードを提供しています。
- 音声チャット: ユーザーはテキスト入力なしでQwen2-Audioと自由に音声対話を行うことができます。
- 音声分析: ユーザーは対話中に音声とテキスト指示を提供して分析を行うことができます。
Qwen2-Audio-7BとQwen2-Audio-7B-Instructをリリースしており、それぞれ事前学習モデルとチャットモデルです。
詳細については、ブログ、GitHub、およびレポートを参照してください。
🚀 クイックスタート
vllmでの起動方法
vllm serve mlinmg/Qwen-2-Audio-Instruct-dynamic-fp8
推論の使用方法
以下では、Qwen2-Audio-7B-Instruct
を使用した推論方法を示します。音声チャットと音声分析の両方のモードをサポートしています。対話にはChatML形式を使用しており、このデモではapply_chat_template
を使用する方法を示します。
基本的な使用法
音声チャット推論
音声チャットモードでは、ユーザーはテキスト入力なしでQwen2-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)
📦 インストール
Qwen2-Audioのコードは最新のHugging face transformersに含まれています。ソースからビルドすることをおすすめします。以下のコマンドでインストールできます。
pip install git+https://github.com/huggingface/transformers
これを行わないと、以下のエラーが発生する可能性があります。
KeyError: 'qwen2-audio'
📄 ライセンス
このプロジェクトは、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トークンのコンテキスト長を備えています。
テキスト生成オーディオ
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のVRAM使用量を大幅に削減し、マルチモーダル処理能力をサポートします。
テキスト生成オーディオ
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アーキテクチャに基づく中国語抽出型QAモデルで、与えられたテキストから回答を抽出するタスクに適しています。
質問応答システム 中国語
R
uer
2,694
98