🚀 Hubert-Base 用於意圖分類
本項目提供的模型可用於語音意圖分類任務,藉助預訓練的 Hubert 模型,能高效準確地對語音中的意圖進行分類,為語音交互等應用提供有力支持。
🚀 快速開始
本模型是 S3PRL 的 Hubert 用於 SUPERB 意圖分類任務 的移植版本。
基礎模型為 hubert-base-ls960,它在 16kHz 採樣的語音音頻上進行了預訓練。使用該模型時,請確保您的語音輸入也是 16kHz 採樣的。
更多信息請參考 SUPERB: Speech processing Universal PERformance Benchmark。
✨ 主要特性
- 基於預訓練的 Hubert 模型,在語音意圖分類任務上表現出色。
- 適配 SUPERB 基準測試,具有良好的通用性。
📦 安裝指南
文檔未提供具體安裝步驟,故跳過此章節。
💻 使用示例
基礎用法
import torch
import librosa
from datasets import load_dataset
from transformers import HubertForSequenceClassification, 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 = HubertForSequenceClassification.from_pretrained("superb/hubert-base-superb-ic")
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-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 測試結果 |
0.9834 |
transformers 測試結果 |
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 許可證。