speech-test
commited on
Commit
•
7862572
1
Parent(s):
d1ecfaa
Upload model
Browse files- README.md +87 -0
- config.json +131 -0
- preprocessor_config.json +9 -0
- pytorch_model.bin +3 -0
README.md
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
datasets:
|
4 |
+
- superb
|
5 |
+
tags:
|
6 |
+
- speech
|
7 |
+
- audio
|
8 |
+
- hubert
|
9 |
+
license: apache-2.0
|
10 |
+
---
|
11 |
+
|
12 |
+
# Hubert-Large for Intent Classification
|
13 |
+
|
14 |
+
## Model description
|
15 |
+
|
16 |
+
This is a ported version of [S3PRL's Hubert for the SUPERB Intent Classification task](https://github.com/s3prl/s3prl/tree/master/s3prl/downstream/fluent_commands).
|
17 |
+
|
18 |
+
The base model is [hubert-large-ll60k](https://huggingface.co/facebook/hubert-large-ll60k), which is pretrained on 16kHz
|
19 |
+
sampled speech audio. When using the model make sure that your speech input is also sampled at 16Khz.
|
20 |
+
|
21 |
+
For more information refer to [SUPERB: Speech processing Universal PERformance Benchmark](https://arxiv.org/abs/2105.01051)
|
22 |
+
|
23 |
+
## Task and dataset description
|
24 |
+
|
25 |
+
Intent Classification (IC) classifies utterances into predefined classes to determine the intent of
|
26 |
+
speakers. SUPERB uses the
|
27 |
+
[Fluent Speech Commands](https://fluent.ai/fluent-speech-commands-a-dataset-for-spoken-language-understanding-research/)
|
28 |
+
dataset, where each utterance is tagged with three intent labels: **action**, **object**, and **location**.
|
29 |
+
|
30 |
+
For the original model's training and evaluation instructions refer to the
|
31 |
+
[S3PRL downstream task README](https://github.com/s3prl/s3prl/tree/master/s3prl/downstream#ic-intent-classification---fluent-speech-commands).
|
32 |
+
|
33 |
+
|
34 |
+
## Usage examples
|
35 |
+
|
36 |
+
You can use the model directly like so:
|
37 |
+
```python
|
38 |
+
import torch
|
39 |
+
import librosa
|
40 |
+
from datasets import load_dataset
|
41 |
+
from transformers import HubertForSequenceClassification, Wav2Vec2FeatureExtractor
|
42 |
+
|
43 |
+
def map_to_array(example):
|
44 |
+
speech, _ = librosa.load(example["file"], sr=16000, mono=True)
|
45 |
+
example["speech"] = speech
|
46 |
+
return example
|
47 |
+
|
48 |
+
# load a demo dataset and read audio files
|
49 |
+
dataset = load_dataset("anton-l/superb_demo", "ic", split="test")
|
50 |
+
dataset = dataset.map(map_to_array)
|
51 |
+
|
52 |
+
model = HubertForSequenceClassification.from_pretrained("superb/hubert-large-superb-ic")
|
53 |
+
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-large-superb-ic")
|
54 |
+
|
55 |
+
# compute attention masks and normalize the waveform if needed
|
56 |
+
inputs = feature_extractor(dataset[:4]["speech"], sampling_rate=16000, padding=True, return_tensors="pt")
|
57 |
+
|
58 |
+
logits = model(**inputs).logits
|
59 |
+
|
60 |
+
action_ids = torch.argmax(logits[:, :6], dim=-1).tolist()
|
61 |
+
action_labels = [model.config.id2label[_id] for _id in action_ids]
|
62 |
+
|
63 |
+
object_ids = torch.argmax(logits[:, 6:20], dim=-1).tolist()
|
64 |
+
object_labels = [model.config.id2label[_id + 6] for _id in object_ids]
|
65 |
+
|
66 |
+
location_ids = torch.argmax(logits[:, 20:24], dim=-1).tolist()
|
67 |
+
location_labels = [model.config.id2label[_id + 20] for _id in location_ids]
|
68 |
+
```
|
69 |
+
|
70 |
+
## Eval results
|
71 |
+
|
72 |
+
The evaluation metric is accuracy.
|
73 |
+
|
74 |
+
| | **s3prl** | **transformers** |
|
75 |
+
|--------|-----------|------------------|
|
76 |
+
|**test**| `0.9876` | `N/A` |
|
77 |
+
|
78 |
+
### BibTeX entry and citation info
|
79 |
+
|
80 |
+
```bibtex
|
81 |
+
@article{yang2021superb,
|
82 |
+
title={SUPERB: Speech processing Universal PERformance Benchmark},
|
83 |
+
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},
|
84 |
+
journal={arXiv preprint arXiv:2105.01051},
|
85 |
+
year={2021}
|
86 |
+
}
|
87 |
+
```
|
config.json
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "facebook/hubert-large-ll60k",
|
3 |
+
"activation_dropout": 0.0,
|
4 |
+
"apply_spec_augment": true,
|
5 |
+
"architectures": [
|
6 |
+
"HubertForSequenceClassification"
|
7 |
+
],
|
8 |
+
"attention_dropout": 0.1,
|
9 |
+
"bos_token_id": 1,
|
10 |
+
"classifier_proj_size": 256,
|
11 |
+
"conv_bias": true,
|
12 |
+
"conv_dim": [
|
13 |
+
512,
|
14 |
+
512,
|
15 |
+
512,
|
16 |
+
512,
|
17 |
+
512,
|
18 |
+
512,
|
19 |
+
512
|
20 |
+
],
|
21 |
+
"conv_kernel": [
|
22 |
+
10,
|
23 |
+
3,
|
24 |
+
3,
|
25 |
+
3,
|
26 |
+
3,
|
27 |
+
2,
|
28 |
+
2
|
29 |
+
],
|
30 |
+
"conv_stride": [
|
31 |
+
5,
|
32 |
+
2,
|
33 |
+
2,
|
34 |
+
2,
|
35 |
+
2,
|
36 |
+
2,
|
37 |
+
2
|
38 |
+
],
|
39 |
+
"ctc_loss_reduction": "sum",
|
40 |
+
"ctc_zero_infinity": false,
|
41 |
+
"do_stable_layer_norm": true,
|
42 |
+
"eos_token_id": 2,
|
43 |
+
"feat_extract_activation": "gelu",
|
44 |
+
"feat_extract_dropout": 0.0,
|
45 |
+
"feat_extract_norm": "layer",
|
46 |
+
"feat_proj_dropout": 0.1,
|
47 |
+
"final_dropout": 0.0,
|
48 |
+
"gradient_checkpointing": false,
|
49 |
+
"hidden_act": "gelu",
|
50 |
+
"hidden_dropout": 0.1,
|
51 |
+
"hidden_size": 1024,
|
52 |
+
"id2label": {
|
53 |
+
"0": "change language",
|
54 |
+
"1": "activate",
|
55 |
+
"2": "deactivate",
|
56 |
+
"3": "increase",
|
57 |
+
"4": "decrease",
|
58 |
+
"5": "bring",
|
59 |
+
"6": "none_object",
|
60 |
+
"7": "music",
|
61 |
+
"8": "lights",
|
62 |
+
"9": "volume",
|
63 |
+
"10": "heat",
|
64 |
+
"11": "lamp",
|
65 |
+
"12": "newspaper",
|
66 |
+
"13": "juice",
|
67 |
+
"14": "socks",
|
68 |
+
"15": "Chinese",
|
69 |
+
"16": "Korean",
|
70 |
+
"17": "English",
|
71 |
+
"18": "German",
|
72 |
+
"19": "shoes",
|
73 |
+
"20": "none_location",
|
74 |
+
"21": "kitchen",
|
75 |
+
"22": "bedroom",
|
76 |
+
"23": "washroom"
|
77 |
+
},
|
78 |
+
"initializer_range": 0.02,
|
79 |
+
"intermediate_size": 4096,
|
80 |
+
"label2id": {
|
81 |
+
"Chinese": 15,
|
82 |
+
"English": 17,
|
83 |
+
"German": 18,
|
84 |
+
"Korean": 16,
|
85 |
+
"activate": 1,
|
86 |
+
"bedroom": 22,
|
87 |
+
"bring": 5,
|
88 |
+
"change language": 0,
|
89 |
+
"deactivate": 2,
|
90 |
+
"decrease": 4,
|
91 |
+
"heat": 10,
|
92 |
+
"increase": 3,
|
93 |
+
"juice": 13,
|
94 |
+
"kitchen": 21,
|
95 |
+
"lamp": 11,
|
96 |
+
"lights": 8,
|
97 |
+
"music": 7,
|
98 |
+
"newspaper": 12,
|
99 |
+
"none_location": 20,
|
100 |
+
"none_object": 6,
|
101 |
+
"shoes": 19,
|
102 |
+
"socks": 14,
|
103 |
+
"volume": 9,
|
104 |
+
"washroom": 23
|
105 |
+
},
|
106 |
+
"layer_norm_eps": 1e-05,
|
107 |
+
"layerdrop": 0.1,
|
108 |
+
"mask_channel_length": 10,
|
109 |
+
"mask_channel_min_space": 1,
|
110 |
+
"mask_channel_other": 0.0,
|
111 |
+
"mask_channel_prob": 0.0,
|
112 |
+
"mask_channel_selection": "static",
|
113 |
+
"mask_feature_length": 10,
|
114 |
+
"mask_feature_prob": 0.0,
|
115 |
+
"mask_time_length": 10,
|
116 |
+
"mask_time_min_space": 1,
|
117 |
+
"mask_time_other": 0.0,
|
118 |
+
"mask_time_prob": 0.075,
|
119 |
+
"mask_time_selection": "static",
|
120 |
+
"model_type": "hubert",
|
121 |
+
"num_attention_heads": 16,
|
122 |
+
"num_conv_pos_embedding_groups": 16,
|
123 |
+
"num_conv_pos_embeddings": 128,
|
124 |
+
"num_feat_extract_layers": 7,
|
125 |
+
"num_hidden_layers": 24,
|
126 |
+
"pad_token_id": 0,
|
127 |
+
"torch_dtype": "float32",
|
128 |
+
"transformers_version": "4.11.0.dev0",
|
129 |
+
"use_weighted_layer_sum": true,
|
130 |
+
"vocab_size": 32
|
131 |
+
}
|
preprocessor_config.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_normalize": false,
|
3 |
+
"feature_extractor_type": "Wav2Vec2FeatureExtractor",
|
4 |
+
"feature_size": 1,
|
5 |
+
"padding_side": "right",
|
6 |
+
"padding_value": 0,
|
7 |
+
"return_attention_mask": true,
|
8 |
+
"sampling_rate": 16000
|
9 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ca41df74e40e83719818d86da732302fe6181c96d3c3096391095f5c3b8e1adf
|
3 |
+
size 1262991467
|