speech-test commited on
Commit
99317c6
1 Parent(s): 7a61035

Upload model

Browse files
Files changed (4) hide show
  1. README.md +87 -0
  2. config.json +132 -0
  3. preprocessor_config.json +9 -0
  4. 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
+ - wav2vec2
9
+ license: apache-2.0
10
+ ---
11
+
12
+ # Wav2Vec2-Large for Intent Classification
13
+
14
+ ## Model description
15
+
16
+ This is a ported version of [S3PRL's Wav2Vec2 for the SUPERB Intent Classification task](https://github.com/s3prl/s3prl/tree/master/s3prl/downstream/fluent_commands).
17
+
18
+ The base model is [wav2vec2-large-lv60](https://huggingface.co/facebook/wav2vec2-large-lv60), 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 Wav2Vec2ForSequenceClassification, 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 = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-large-superb-ic")
53
+ feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-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.9528` | `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,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "facebook/wav2vec2-large-lv60",
3
+ "activation_dropout": 0.1,
4
+ "apply_spec_augment": true,
5
+ "architectures": [
6
+ "Wav2Vec2ForSequenceClassification"
7
+ ],
8
+ "attention_dropout": 0.1,
9
+ "bos_token_id": 1,
10
+ "classifier_proj_size": 256,
11
+ "codevector_dim": 768,
12
+ "contrastive_logits_temperature": 0.1,
13
+ "conv_bias": true,
14
+ "conv_dim": [
15
+ 512,
16
+ 512,
17
+ 512,
18
+ 512,
19
+ 512,
20
+ 512,
21
+ 512
22
+ ],
23
+ "conv_kernel": [
24
+ 10,
25
+ 3,
26
+ 3,
27
+ 3,
28
+ 3,
29
+ 2,
30
+ 2
31
+ ],
32
+ "conv_stride": [
33
+ 5,
34
+ 2,
35
+ 2,
36
+ 2,
37
+ 2,
38
+ 2,
39
+ 2
40
+ ],
41
+ "ctc_loss_reduction": "sum",
42
+ "ctc_zero_infinity": false,
43
+ "diversity_loss_weight": 0.1,
44
+ "do_stable_layer_norm": true,
45
+ "eos_token_id": 2,
46
+ "feat_extract_activation": "gelu",
47
+ "feat_extract_dropout": 0.0,
48
+ "feat_extract_norm": "layer",
49
+ "feat_proj_dropout": 0.1,
50
+ "feat_quantizer_dropout": 0.0,
51
+ "final_dropout": 0.1,
52
+ "gradient_checkpointing": false,
53
+ "hidden_act": "gelu",
54
+ "hidden_dropout": 0.1,
55
+ "hidden_dropout_prob": 0.1,
56
+ "hidden_size": 1024,
57
+ "id2label": {
58
+ "0": "change language",
59
+ "1": "activate",
60
+ "2": "deactivate",
61
+ "3": "increase",
62
+ "4": "decrease",
63
+ "5": "bring",
64
+ "6": "none_object",
65
+ "7": "music",
66
+ "8": "lights",
67
+ "9": "volume",
68
+ "10": "heat",
69
+ "11": "lamp",
70
+ "12": "newspaper",
71
+ "13": "juice",
72
+ "14": "socks",
73
+ "15": "Chinese",
74
+ "16": "Korean",
75
+ "17": "English",
76
+ "18": "German",
77
+ "19": "shoes",
78
+ "20": "none_location",
79
+ "21": "kitchen",
80
+ "22": "bedroom",
81
+ "23": "washroom"
82
+ },
83
+ "initializer_range": 0.02,
84
+ "intermediate_size": 4096,
85
+ "label2id": {
86
+ "Chinese": 15,
87
+ "English": 17,
88
+ "German": 18,
89
+ "Korean": 16,
90
+ "activate": 1,
91
+ "bedroom": 22,
92
+ "bring": 5,
93
+ "change language": 0,
94
+ "deactivate": 2,
95
+ "decrease": 4,
96
+ "heat": 10,
97
+ "increase": 3,
98
+ "juice": 13,
99
+ "kitchen": 21,
100
+ "lamp": 11,
101
+ "lights": 8,
102
+ "music": 7,
103
+ "newspaper": 12,
104
+ "none_location": 20,
105
+ "none_object": 6,
106
+ "shoes": 19,
107
+ "socks": 14,
108
+ "volume": 9,
109
+ "washroom": 23
110
+ },
111
+ "layer_norm_eps": 1e-05,
112
+ "layerdrop": 0.1,
113
+ "mask_feature_length": 10,
114
+ "mask_feature_prob": 0.0,
115
+ "mask_time_length": 10,
116
+ "mask_time_prob": 0.05,
117
+ "model_type": "wav2vec2",
118
+ "num_attention_heads": 16,
119
+ "num_codevector_groups": 2,
120
+ "num_codevectors_per_group": 320,
121
+ "num_conv_pos_embedding_groups": 16,
122
+ "num_conv_pos_embeddings": 128,
123
+ "num_feat_extract_layers": 7,
124
+ "num_hidden_layers": 24,
125
+ "num_negatives": 100,
126
+ "pad_token_id": 0,
127
+ "proj_codevector_dim": 768,
128
+ "torch_dtype": "float32",
129
+ "transformers_version": "4.11.0.dev0",
130
+ "use_weighted_layer_sum": true,
131
+ "vocab_size": 32
132
+ }
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.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:90e162a5bf7c55f901d2a57d6d5bd172468cc2663e69444c76aa5496dcde1174
3
+ size 1262993067