🚀 用於意圖分類的Wav2Vec2-Base模型
本模型主要用於語音的意圖分類任務,基於預訓練的wav2vec2-base模型,能將語音輸入分類到預定義的類別中,從而確定說話者的意圖。
🚀 快速開始
本模型是 S3PRL的Wav2Vec2用於SUPERB意圖分類任務 的移植版本。
基礎模型為 wav2vec2-base,它在16kHz採樣的語音音頻上進行了預訓練。使用該模型時,請確保您的語音輸入也採樣為16kHz。
更多信息請參考 SUPERB: 語音處理通用性能基準。
✨ 主要特性
- 基於預訓練的wav2vec2-base模型,在語音意圖分類任務上表現出色。
- 可處理16kHz採樣的語音輸入。
📦 安裝指南
文檔未提及安裝步驟,可參考相關依賴庫(如torch
、librosa
、datasets
、transformers
)的官方安裝指南進行安裝。
💻 使用示例
基礎用法
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-base-superb-ic")
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-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]
📚 詳細文檔
任務和數據集描述
意圖分類(IC)將話語分類到預定義的類別中,以確定說話者的意圖。SUPERB使用 Fluent Speech Commands 數據集,其中每個話語都標記有三個意圖標籤:動作、對象 和 位置。
有關原始模型的訓練和評估說明,請參考 S3PRL下游任務README。
評估結果
評估指標為準確率。
|
s3prl |
transformers |
測試集 |
0.9235 |
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許可證。