🚀 Wav2Vec2-Large用於意圖分類
本模型是一個用於語音意圖分類的模型,基於預訓練的Wav2Vec2架構,能有效對語音中的意圖進行分類,在相關語音數據集上表現良好。
🚀 快速開始
本模型可直接用於語音意圖分類任務,使用時需確保輸入語音採樣率為16kHz。
✨ 主要特性
📦 安裝指南
文檔未提及安裝步驟,故跳過此章節。
💻 使用示例
基礎用法
import torch
import librosa
from datasets import load_dataset
from transformers import Wav2Vec2ForSequenceClassification, Wav2Vec2FeatureExtractor
def map_to_array(example):
speech, _ = librosa.load(example["file"], sr=16000, mono=True)
example["speech"] = speech
return example
dataset = load_dataset("anton-l/superb_demo", "ic", split="test")
dataset = dataset.map(map_to_array)
model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-large-superb-ic")
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-large-superb-ic")
inputs = feature_extractor(dataset[:4]["speech"], sampling_rate=16000, padding=True, return_tensors="pt")
logits = model(**inputs).logits
action_ids = torch.argmax(logits[:, :6], dim=-1).tolist()
action_labels = [model.config.id2label[_id] for _id in action_ids]
object_ids = torch.argmax(logits[:, 6:20], dim=-1).tolist()
object_labels = [model.config.id2label[_id + 6] for _id in object_ids]
location_ids = torch.argmax(logits[:, 20:24], dim=-1).tolist()
location_labels = [model.config.id2label[_id + 20] for _id in location_ids]
高級用法
文檔未提及高級用法相關代碼,故跳過此部分。
📚 詳細文檔
模型描述
這是 S3PRL的Wav2Vec2用於SUPERB意圖分類任務 的移植版本。
基礎模型是 wav2vec2-large-lv60,它在16kHz採樣的語音音頻上進行了預訓練。使用該模型時,請確保您的語音輸入也是16kHz採樣的。
更多信息請參考 SUPERB: Speech processing Universal PERformance Benchmark
任務和數據集描述
意圖分類(IC)將話語分類到預定義的類別中,以確定說話者的意圖。SUPERB使用 Fluent Speech Commands 數據集,其中每個話語都標記有三個意圖標籤:動作、對象 和 位置。
有關原始模型的訓練和評估說明,請參考 S3PRL下游任務README。
評估結果
評估指標是準確率。
|
s3prl |
transformers |
測試 |
0.9528 |
N/A |
BibTeX引用和引用信息
@article{yang2021superb,
title={SUPERB: Speech processing Universal PERformance Benchmark},
author={Yang, Shu-wen and Chi, Po-Han and Chuang, Yung-Sung and Lai, Cheng-I Jeff and Lakhotia, Kushal and Lin, Yist Y and Liu, Andy T and Shi, Jiatong and Chang, Xuankai and Lin, Guan-Ting and others},
journal={arXiv preprint arXiv:2105.01051},
year={2021}
}
🔧 技術細節
文檔未提及技術細節相關內容,故跳過此章節。
📄 許可證
本模型使用的許可證是Apache-2.0。