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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
tags: []
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Model Card for Model ID
|
| 7 |
+
|
| 8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
## Model Details
|
| 13 |
+
|
| 14 |
+
### Model Description
|
| 15 |
+
|
| 16 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 17 |
+
|
| 18 |
+
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
| 19 |
+
|
| 20 |
+
- **Developed by:** [More Information Needed]
|
| 21 |
+
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
+
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
+
- **Model type:** [More Information Needed]
|
| 24 |
+
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
+
- **License:** [More Information Needed]
|
| 26 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
+
|
| 28 |
+
### Model Sources [optional]
|
| 29 |
+
|
| 30 |
+
<!-- Provide the basic links for the model. -->
|
| 31 |
+
|
| 32 |
+
- **Repository:** [More Information Needed]
|
| 33 |
+
- **Paper [optional]:** [More Information Needed]
|
| 34 |
+
- **Demo [optional]:** [More Information Needed]
|
| 35 |
+
|
| 36 |
+
## Uses
|
| 37 |
+
|
| 38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
+
|
| 40 |
+
### Direct Use
|
| 41 |
+
|
| 42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 43 |
+
|
| 44 |
+
[More Information Needed]
|
| 45 |
+
|
| 46 |
+
### Downstream Use [optional]
|
| 47 |
+
|
| 48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 49 |
+
|
| 50 |
+
[More Information Needed]
|
| 51 |
+
|
| 52 |
+
### Out-of-Scope Use
|
| 53 |
+
|
| 54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 55 |
+
|
| 56 |
+
[More Information Needed]
|
| 57 |
+
|
| 58 |
+
## Bias, Risks, and Limitations
|
| 59 |
+
|
| 60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
+
|
| 62 |
+
[More Information Needed]
|
| 63 |
+
|
| 64 |
+
### Recommendations
|
| 65 |
+
|
| 66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
+
|
| 68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
+
|
| 70 |
+
## How to Get Started with the Model
|
| 71 |
+
|
| 72 |
+
Use the code below to get started with the model.
|
| 73 |
+
|
| 74 |
+
[More Information Needed]
|
| 75 |
+
|
| 76 |
+
## Training Details
|
| 77 |
+
|
| 78 |
+
### Training Data
|
| 79 |
+
|
| 80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
+
|
| 82 |
+
[More Information Needed]
|
| 83 |
+
|
| 84 |
+
### Training Procedure
|
| 85 |
+
|
| 86 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
+
|
| 88 |
+
#### Preprocessing [optional]
|
| 89 |
+
|
| 90 |
+
[More Information Needed]
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
#### Training Hyperparameters
|
| 94 |
+
|
| 95 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
+
|
| 97 |
+
#### Speeds, Sizes, Times [optional]
|
| 98 |
+
|
| 99 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
+
|
| 101 |
+
[More Information Needed]
|
| 102 |
+
|
| 103 |
+
## Evaluation
|
| 104 |
+
|
| 105 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
+
|
| 107 |
+
### Testing Data, Factors & Metrics
|
| 108 |
+
|
| 109 |
+
#### Testing Data
|
| 110 |
+
|
| 111 |
+
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
+
|
| 113 |
+
[More Information Needed]
|
| 114 |
+
|
| 115 |
+
#### Factors
|
| 116 |
+
|
| 117 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
+
|
| 119 |
+
[More Information Needed]
|
| 120 |
+
|
| 121 |
+
#### Metrics
|
| 122 |
+
|
| 123 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
+
|
| 125 |
+
[More Information Needed]
|
| 126 |
+
|
| 127 |
+
### Results
|
| 128 |
+
|
| 129 |
+
[More Information Needed]
|
| 130 |
+
|
| 131 |
+
#### Summary
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
## Model Examination [optional]
|
| 136 |
+
|
| 137 |
+
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
+
|
| 139 |
+
[More Information Needed]
|
| 140 |
+
|
| 141 |
+
## Environmental Impact
|
| 142 |
+
|
| 143 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
+
|
| 145 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
+
|
| 147 |
+
- **Hardware Type:** [More Information Needed]
|
| 148 |
+
- **Hours used:** [More Information Needed]
|
| 149 |
+
- **Cloud Provider:** [More Information Needed]
|
| 150 |
+
- **Compute Region:** [More Information Needed]
|
| 151 |
+
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
+
|
| 153 |
+
## Technical Specifications [optional]
|
| 154 |
+
|
| 155 |
+
### Model Architecture and Objective
|
| 156 |
+
|
| 157 |
+
[More Information Needed]
|
| 158 |
+
|
| 159 |
+
### Compute Infrastructure
|
| 160 |
+
|
| 161 |
+
[More Information Needed]
|
| 162 |
+
|
| 163 |
+
#### Hardware
|
| 164 |
+
|
| 165 |
+
[More Information Needed]
|
| 166 |
+
|
| 167 |
+
#### Software
|
| 168 |
+
|
| 169 |
+
[More Information Needed]
|
| 170 |
+
|
| 171 |
+
## Citation [optional]
|
| 172 |
+
|
| 173 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
+
|
| 175 |
+
**BibTeX:**
|
| 176 |
+
|
| 177 |
+
[More Information Needed]
|
| 178 |
+
|
| 179 |
+
**APA:**
|
| 180 |
+
|
| 181 |
+
[More Information Needed]
|
| 182 |
+
|
| 183 |
+
## Glossary [optional]
|
| 184 |
+
|
| 185 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
+
|
| 187 |
+
[More Information Needed]
|
| 188 |
+
|
| 189 |
+
## More Information [optional]
|
| 190 |
+
|
| 191 |
+
[More Information Needed]
|
| 192 |
+
|
| 193 |
+
## Model Card Authors [optional]
|
| 194 |
+
|
| 195 |
+
[More Information Needed]
|
| 196 |
+
|
| 197 |
+
## Model Card Contact
|
| 198 |
+
|
| 199 |
+
[More Information Needed]
|
config.json
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|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 0.0,
|
| 4 |
+
"activation_function": "gelu",
|
| 5 |
+
"apply_spec_augment": false,
|
| 6 |
+
"architectures": [
|
| 7 |
+
"WhisperForConditionalGeneration"
|
| 8 |
+
],
|
| 9 |
+
"attention_dropout": 0.0,
|
| 10 |
+
"auto_map": {
|
| 11 |
+
"AutoConfig": "configuration_whisper_spkreg.WhisperSpkRegConfig"
|
| 12 |
+
},
|
| 13 |
+
"begin_suppress_tokens": [
|
| 14 |
+
220,
|
| 15 |
+
50257
|
| 16 |
+
],
|
| 17 |
+
"bos_token_id": 50257,
|
| 18 |
+
"classifier_proj_size": 256,
|
| 19 |
+
"d_model": 512,
|
| 20 |
+
"decoder_attention_heads": 8,
|
| 21 |
+
"decoder_ffn_dim": 2048,
|
| 22 |
+
"decoder_layerdrop": 0.0,
|
| 23 |
+
"decoder_layers": 6,
|
| 24 |
+
"decoder_start_token_id": 50258,
|
| 25 |
+
"dropout": 0.0,
|
| 26 |
+
"easy_margin": false,
|
| 27 |
+
"encoder_attention_heads": 8,
|
| 28 |
+
"encoder_ffn_dim": 2048,
|
| 29 |
+
"encoder_layerdrop": 0.0,
|
| 30 |
+
"encoder_layers": 6,
|
| 31 |
+
"eos_token_id": 50257,
|
| 32 |
+
"forced_decoder_ids": [
|
| 33 |
+
[
|
| 34 |
+
1,
|
| 35 |
+
50259
|
| 36 |
+
],
|
| 37 |
+
[
|
| 38 |
+
2,
|
| 39 |
+
50359
|
| 40 |
+
],
|
| 41 |
+
[
|
| 42 |
+
3,
|
| 43 |
+
50363
|
| 44 |
+
]
|
| 45 |
+
],
|
| 46 |
+
"init_std": 0.02,
|
| 47 |
+
"is_encoder_decoder": true,
|
| 48 |
+
"label_smoothing": 0.0,
|
| 49 |
+
"loss_fct": "cross_entropy",
|
| 50 |
+
"margin": 0.35,
|
| 51 |
+
"mask_feature_length": 10,
|
| 52 |
+
"mask_feature_min_masks": 0,
|
| 53 |
+
"mask_feature_prob": 0.0,
|
| 54 |
+
"mask_time_length": 10,
|
| 55 |
+
"mask_time_min_masks": 2,
|
| 56 |
+
"mask_time_prob": 0.05,
|
| 57 |
+
"max_length": 448,
|
| 58 |
+
"max_source_positions": 1500,
|
| 59 |
+
"max_target_positions": 448,
|
| 60 |
+
"median_filter_width": 7,
|
| 61 |
+
"model_type": "whisper_spkreg",
|
| 62 |
+
"num_hidden_layers": 6,
|
| 63 |
+
"num_mel_bins": 80,
|
| 64 |
+
"pad_token_id": 50257,
|
| 65 |
+
"reduction": "mean",
|
| 66 |
+
"scale": 30.0,
|
| 67 |
+
"scale_embedding": false,
|
| 68 |
+
"suppress_tokens": [
|
| 69 |
+
1,
|
| 70 |
+
2,
|
| 71 |
+
7,
|
| 72 |
+
8,
|
| 73 |
+
9,
|
| 74 |
+
10,
|
| 75 |
+
14,
|
| 76 |
+
25,
|
| 77 |
+
26,
|
| 78 |
+
27,
|
| 79 |
+
28,
|
| 80 |
+
29,
|
| 81 |
+
31,
|
| 82 |
+
58,
|
| 83 |
+
59,
|
| 84 |
+
60,
|
| 85 |
+
61,
|
| 86 |
+
62,
|
| 87 |
+
63,
|
| 88 |
+
90,
|
| 89 |
+
91,
|
| 90 |
+
92,
|
| 91 |
+
93,
|
| 92 |
+
359,
|
| 93 |
+
503,
|
| 94 |
+
522,
|
| 95 |
+
542,
|
| 96 |
+
873,
|
| 97 |
+
893,
|
| 98 |
+
902,
|
| 99 |
+
918,
|
| 100 |
+
922,
|
| 101 |
+
931,
|
| 102 |
+
1350,
|
| 103 |
+
1853,
|
| 104 |
+
1982,
|
| 105 |
+
2460,
|
| 106 |
+
2627,
|
| 107 |
+
3246,
|
| 108 |
+
3253,
|
| 109 |
+
3268,
|
| 110 |
+
3536,
|
| 111 |
+
3846,
|
| 112 |
+
3961,
|
| 113 |
+
4183,
|
| 114 |
+
4667,
|
| 115 |
+
6585,
|
| 116 |
+
6647,
|
| 117 |
+
7273,
|
| 118 |
+
9061,
|
| 119 |
+
9383,
|
| 120 |
+
10428,
|
| 121 |
+
10929,
|
| 122 |
+
11938,
|
| 123 |
+
12033,
|
| 124 |
+
12331,
|
| 125 |
+
12562,
|
| 126 |
+
13793,
|
| 127 |
+
14157,
|
| 128 |
+
14635,
|
| 129 |
+
15265,
|
| 130 |
+
15618,
|
| 131 |
+
16553,
|
| 132 |
+
16604,
|
| 133 |
+
18362,
|
| 134 |
+
18956,
|
| 135 |
+
20075,
|
| 136 |
+
21675,
|
| 137 |
+
22520,
|
| 138 |
+
26130,
|
| 139 |
+
26161,
|
| 140 |
+
26435,
|
| 141 |
+
28279,
|
| 142 |
+
29464,
|
| 143 |
+
31650,
|
| 144 |
+
32302,
|
| 145 |
+
32470,
|
| 146 |
+
36865,
|
| 147 |
+
42863,
|
| 148 |
+
47425,
|
| 149 |
+
49870,
|
| 150 |
+
50254,
|
| 151 |
+
50258,
|
| 152 |
+
50358,
|
| 153 |
+
50359,
|
| 154 |
+
50360,
|
| 155 |
+
50361,
|
| 156 |
+
50362
|
| 157 |
+
],
|
| 158 |
+
"torch_dtype": "float32",
|
| 159 |
+
"transformers_version": "4.46.2",
|
| 160 |
+
"use_cache": true,
|
| 161 |
+
"use_weighted_layer_sum": false,
|
| 162 |
+
"vocab_size": 51865
|
| 163 |
+
}
|
configuration_whisper_spkreg.py
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Whisper model configuration"""
|
| 2 |
+
|
| 3 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 4 |
+
from transformers.utils import logging
|
| 5 |
+
|
| 6 |
+
logger = logging.get_logger(__name__)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
# fmt: off
|
| 10 |
+
NON_SPEECH_TOKENS = [
|
| 11 |
+
1, 2, 7, 8, 9, 10, 14, 25,
|
| 12 |
+
26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
|
| 13 |
+
63, 90, 91, 92, 93, 357, 366, 438, 532, 685,
|
| 14 |
+
705, 796, 930, 1058, 1220, 1267, 1279, 1303, 1343, 1377,
|
| 15 |
+
1391, 1635, 1782, 1875, 2162, 2361, 2488, 3467, 4008, 4211,
|
| 16 |
+
4600, 4808, 5299, 5855, 6329, 7203, 9609, 9959, 10563, 10786,
|
| 17 |
+
11420, 11709, 11907, 13163, 13697, 13700, 14808, 15306, 16410, 16791,
|
| 18 |
+
17992, 19203, 19510, 20724, 22305, 22935, 27007, 30109, 30420, 33409,
|
| 19 |
+
34949, 40283, 40493, 40549, 47282, 49146, 50257, 50359, 50360, 50361
|
| 20 |
+
]
|
| 21 |
+
NON_SPEECH_TOKENS_MULTI = [
|
| 22 |
+
1, 2, 7, 8, 9, 10, 14, 25,
|
| 23 |
+
26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
|
| 24 |
+
63, 90, 91, 92, 93, 359, 503, 522, 542, 873,
|
| 25 |
+
893, 902, 918, 922, 931, 1350, 1853, 1982, 2460, 2627,
|
| 26 |
+
3246, 3253, 3268, 3536, 3846, 3961, 4183, 4667, 6585, 6647,
|
| 27 |
+
7273, 9061, 9383, 10428, 10929, 11938, 12033, 12331, 12562, 13793,
|
| 28 |
+
14157, 14635, 15265, 15618, 16553, 16604, 18362, 18956, 20075, 21675,
|
| 29 |
+
22520, 26130, 26161, 26435, 28279, 29464, 31650, 32302, 32470, 36865,
|
| 30 |
+
42863, 47425, 49870, 50254, 50258, 50360, 50361, 50362
|
| 31 |
+
]
|
| 32 |
+
# fmt: on
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class WhisperSpkRegConfig(PretrainedConfig):
|
| 36 |
+
r"""
|
| 37 |
+
This is the configuration class to store the configuration of a [`WhisperModel`]. It is used to instantiate a
|
| 38 |
+
Whisper model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
| 39 |
+
with the defaults will yield a similar configuration to that of the Whisper
|
| 40 |
+
[openai/whisper-tiny](https://huggingface.co/openai/whisper-tiny) architecture.
|
| 41 |
+
|
| 42 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 43 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
Args:
|
| 47 |
+
vocab_size (`int`, *optional*, defaults to 51865):
|
| 48 |
+
Vocabulary size of the Whisper model. Defines the number of different tokens that can be represented by the
|
| 49 |
+
`decoder_input_ids` passed when calling [`WhisperModel`]
|
| 50 |
+
num_mel_bins (`int`, *optional*, defaults to 80):
|
| 51 |
+
Number of mel features used per input features. Should correspond to the value used in the
|
| 52 |
+
`WhisperProcessor` class.
|
| 53 |
+
encoder_layers (`int`, *optional*, defaults to 4):
|
| 54 |
+
Number of encoder layers.
|
| 55 |
+
decoder_layers (`int`, *optional*, defaults to 4):
|
| 56 |
+
Number of decoder layers.
|
| 57 |
+
encoder_attention_heads (`int`, *optional*, defaults to 6):
|
| 58 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 59 |
+
decoder_attention_heads (`int`, *optional*, defaults to 6):
|
| 60 |
+
Number of attention heads for each attention layer in the Transformer decoder.
|
| 61 |
+
encoder_ffn_dim (`int`, *optional*, defaults to 1536):
|
| 62 |
+
Dimensionality of the "intermediate" (often named feed-forward) layer in encoder.
|
| 63 |
+
decoder_ffn_dim (`int`, *optional*, defaults to 1536):
|
| 64 |
+
Dimensionality of the "intermediate" (often named feed-forward) layer in decoder.
|
| 65 |
+
encoder_layerdrop (`float`, *optional*, defaults to 0.0):
|
| 66 |
+
The LayerDrop probability for the encoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
|
| 67 |
+
for more details.
|
| 68 |
+
decoder_layerdrop (`float`, *optional*, defaults to 0.0):
|
| 69 |
+
The LayerDrop probability for the decoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
|
| 70 |
+
for more details.
|
| 71 |
+
decoder_start_token_id (`int`, *optional*, defaults to 50257):
|
| 72 |
+
Corresponds to the "<|startoftranscript|>" token, which is automatically used when no `decoder_input_ids`
|
| 73 |
+
are provided to the `generate` function. It is used to guide the model`s generation process depending on
|
| 74 |
+
the task.
|
| 75 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 76 |
+
Whether or not the model should return the last key/values attentions (not used by all models).
|
| 77 |
+
is_encoder_decoder (`bool`, *optional*, defaults to `True`):
|
| 78 |
+
Whether the model is used as an encoder/decoder or not.
|
| 79 |
+
activation_function (`str`, *optional*, defaults to `"gelu"`):
|
| 80 |
+
The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
|
| 81 |
+
`"relu"`, `"silu"` and `"gelu_new"` are supported.
|
| 82 |
+
d_model (`int`, *optional*, defaults to 384):
|
| 83 |
+
Dimensionality of the layers.
|
| 84 |
+
dropout (`float`, *optional*, defaults to 0.1):
|
| 85 |
+
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
|
| 86 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 87 |
+
The dropout ratio for the attention probabilities.
|
| 88 |
+
activation_dropout (`float`, *optional*, defaults to 0.0):
|
| 89 |
+
The dropout ratio for activations inside the fully connected layer.
|
| 90 |
+
init_std (`float`, *optional*, defaults to 0.02):
|
| 91 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 92 |
+
scale_embedding (`bool`, *optional*, defaults to False):
|
| 93 |
+
Scale embeddings by diving by sqrt(d_model).
|
| 94 |
+
max_source_positions (`int`, *optional*, defaults to 1500):
|
| 95 |
+
The maximum sequence length of log-mel filter-bank features that this model might ever be used with.
|
| 96 |
+
max_target_positions (`int`, *optional*, defaults to 448):
|
| 97 |
+
The maximum sequence length that this model might ever be used with. Typically set this to something large
|
| 98 |
+
just in case (e.g., 512 or 1024 or 2048).
|
| 99 |
+
pad_token_id (`int`, *optional*, defaults to 50256):
|
| 100 |
+
Padding token id.
|
| 101 |
+
bos_token_id (`int`, *optional*, defaults to 50256):
|
| 102 |
+
Begin of stream token id.
|
| 103 |
+
eos_token_id (`int`, *optional*, defaults to 50256):
|
| 104 |
+
End of stream token id.
|
| 105 |
+
suppress_tokens (`List[int]`, *optional*):
|
| 106 |
+
A list containing the non-speech tokens that will be used by the logit processor in the `generate`
|
| 107 |
+
function. NON_SPEECH_TOKENS and NON_SPEECH_TOKENS_MULTI each correspond to the `english-only` and the
|
| 108 |
+
`multilingual` model.
|
| 109 |
+
begin_suppress_tokens (`List[int]`, *optional*, defaults to `[220,50256]`):
|
| 110 |
+
A list containing tokens that will be supressed at the beginning of the sampling process. Initialized as
|
| 111 |
+
the token for `" "` (`blank_token_id`) and the `eos_token_id`
|
| 112 |
+
use_weighted_layer_sum (`bool`, *optional*, defaults to `False`):
|
| 113 |
+
Whether to use a weighted average of layer outputs with learned weights. Only relevant when using an
|
| 114 |
+
instance of [`WhisperForAudioClassification`].
|
| 115 |
+
classifier_proj_size (`int`, *optional*, defaults to 256):
|
| 116 |
+
Dimensionality of the projection before token mean-pooling for classification. Only relevant when using an
|
| 117 |
+
instance of [`WhisperForAudioClassification`].
|
| 118 |
+
apply_spec_augment (`bool`, *optional*, defaults to `False`):
|
| 119 |
+
Whether to apply *SpecAugment* data augmentation to the outputs of the feature encoder. For reference see
|
| 120 |
+
[SpecAugment: A Simple Data Augmentation Method for Automatic Speech
|
| 121 |
+
Recognition](https://arxiv.org/abs/1904.08779).
|
| 122 |
+
mask_time_prob (`float`, *optional*, defaults to 0.05):
|
| 123 |
+
Percentage (between 0 and 1) of all feature vectors along the time axis which will be masked. The masking
|
| 124 |
+
procecure generates `mask_time_prob*len(time_axis)/mask_time_length` independent masks over the axis. If
|
| 125 |
+
reasoning from the propability of each feature vector to be chosen as the start of the vector span to be
|
| 126 |
+
masked, *mask_time_prob* should be `prob_vector_start*mask_time_length`. Note that overlap may decrease the
|
| 127 |
+
actual percentage of masked vectors. This is only relevant if `apply_spec_augment == True`.
|
| 128 |
+
mask_time_length (`int`, *optional*, defaults to 10):
|
| 129 |
+
Length of vector span along the time axis.
|
| 130 |
+
mask_time_min_masks (`int`, *optional*, defaults to 2),:
|
| 131 |
+
The minimum number of masks of length `mask_feature_length` generated along the time axis, each time step,
|
| 132 |
+
irrespectively of `mask_feature_prob`. Only relevant if ''mask_time_prob*len(time_axis)/mask_time_length <
|
| 133 |
+
mask_time_min_masks''
|
| 134 |
+
mask_feature_prob (`float`, *optional*, defaults to 0.0):
|
| 135 |
+
Percentage (between 0 and 1) of all feature vectors along the feature axis which will be masked. The
|
| 136 |
+
masking procecure generates `mask_feature_prob*len(feature_axis)/mask_time_length` independent masks over
|
| 137 |
+
the axis. If reasoning from the propability of each feature vector to be chosen as the start of the vector
|
| 138 |
+
span to be masked, *mask_feature_prob* should be `prob_vector_start*mask_feature_length`. Note that overlap
|
| 139 |
+
may decrease the actual percentage of masked vectors. This is only relevant if `apply_spec_augment is
|
| 140 |
+
True`.
|
| 141 |
+
mask_feature_length (`int`, *optional*, defaults to 10):
|
| 142 |
+
Length of vector span along the feature axis.
|
| 143 |
+
mask_feature_min_masks (`int`, *optional*, defaults to 0),:
|
| 144 |
+
The minimum number of masks of length `mask_feature_length` generated along the feature axis, each time
|
| 145 |
+
step, irrespectively of `mask_feature_prob`. Only relevant if
|
| 146 |
+
`mask_feature_prob*len(feature_axis)/mask_feature_length < mask_feature_min_masks`.
|
| 147 |
+
median_filter_width (`int`, *optional*, defaults to 7):
|
| 148 |
+
Width of the median filter used to smoothen to cross-attention outputs when computing token timestamps.
|
| 149 |
+
Should be an odd number.
|
| 150 |
+
|
| 151 |
+
Example:
|
| 152 |
+
|
| 153 |
+
```python
|
| 154 |
+
>>> from transformers import WhisperConfig, WhisperModel
|
| 155 |
+
|
| 156 |
+
>>> # Initializing a Whisper tiny style configuration
|
| 157 |
+
>>> configuration = WhisperConfig()
|
| 158 |
+
|
| 159 |
+
>>> # Initializing a model (with random weights) from the tiny style configuration
|
| 160 |
+
>>> model = WhisperModel(configuration)
|
| 161 |
+
|
| 162 |
+
>>> # Accessing the model configuration
|
| 163 |
+
>>> configuration = model.config
|
| 164 |
+
```"""
|
| 165 |
+
|
| 166 |
+
model_type = "whisper_spkreg"
|
| 167 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 168 |
+
attribute_map = {
|
| 169 |
+
"num_key_value_heads": "encoder_attention_heads",
|
| 170 |
+
"num_attention_heads": "encoder_attention_heads",
|
| 171 |
+
"hidden_size": "d_model",
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
def __init__(
|
| 175 |
+
self,
|
| 176 |
+
vocab_size=51865,
|
| 177 |
+
num_mel_bins=80,
|
| 178 |
+
encoder_layers=4,
|
| 179 |
+
encoder_attention_heads=6,
|
| 180 |
+
decoder_layers=4,
|
| 181 |
+
decoder_attention_heads=6,
|
| 182 |
+
decoder_ffn_dim=1536,
|
| 183 |
+
encoder_ffn_dim=1536,
|
| 184 |
+
encoder_layerdrop=0.0,
|
| 185 |
+
decoder_layerdrop=0.0,
|
| 186 |
+
decoder_start_token_id=50257,
|
| 187 |
+
use_cache=True,
|
| 188 |
+
is_encoder_decoder=True,
|
| 189 |
+
activation_function="gelu",
|
| 190 |
+
d_model=384,
|
| 191 |
+
dropout=0.0,
|
| 192 |
+
attention_dropout=0.0,
|
| 193 |
+
activation_dropout=0.0,
|
| 194 |
+
init_std=0.02,
|
| 195 |
+
scale_embedding=False,
|
| 196 |
+
max_source_positions=1500,
|
| 197 |
+
max_target_positions=448,
|
| 198 |
+
pad_token_id=50256,
|
| 199 |
+
bos_token_id=50256,
|
| 200 |
+
eos_token_id=50256,
|
| 201 |
+
suppress_tokens=None,
|
| 202 |
+
begin_suppress_tokens=[220, 50256],
|
| 203 |
+
use_weighted_layer_sum=False,
|
| 204 |
+
classifier_proj_size=256,
|
| 205 |
+
apply_spec_augment=False,
|
| 206 |
+
mask_time_prob=0.05,
|
| 207 |
+
mask_time_length=10,
|
| 208 |
+
mask_time_min_masks=2,
|
| 209 |
+
mask_feature_prob=0.0,
|
| 210 |
+
mask_feature_length=10,
|
| 211 |
+
mask_feature_min_masks=0,
|
| 212 |
+
median_filter_width=7,
|
| 213 |
+
loss_fct: str = 'cross_entropy', # cross_entropy, additive_margin, additive_angular_margin
|
| 214 |
+
label_smoothing: float = 0.0,
|
| 215 |
+
scale: float = 30.0,
|
| 216 |
+
margin: float = 0.35,
|
| 217 |
+
easy_margin: bool = False,
|
| 218 |
+
reduction: str = "mean",
|
| 219 |
+
**kwargs,
|
| 220 |
+
):
|
| 221 |
+
self.vocab_size = vocab_size
|
| 222 |
+
self.num_mel_bins = num_mel_bins
|
| 223 |
+
self.d_model = d_model
|
| 224 |
+
self.encoder_layers = encoder_layers
|
| 225 |
+
self.encoder_attention_heads = encoder_attention_heads
|
| 226 |
+
self.decoder_layers = decoder_layers
|
| 227 |
+
self.decoder_attention_heads = decoder_attention_heads
|
| 228 |
+
self.decoder_ffn_dim = decoder_ffn_dim
|
| 229 |
+
self.encoder_ffn_dim = encoder_ffn_dim
|
| 230 |
+
self.dropout = dropout
|
| 231 |
+
self.attention_dropout = attention_dropout
|
| 232 |
+
self.activation_dropout = activation_dropout
|
| 233 |
+
self.activation_function = activation_function
|
| 234 |
+
self.init_std = init_std
|
| 235 |
+
self.encoder_layerdrop = encoder_layerdrop
|
| 236 |
+
self.decoder_layerdrop = decoder_layerdrop
|
| 237 |
+
self.use_cache = use_cache
|
| 238 |
+
self.num_hidden_layers = encoder_layers
|
| 239 |
+
self.scale_embedding = scale_embedding # scale factor will be sqrt(d_model) if True
|
| 240 |
+
self.max_source_positions = max_source_positions
|
| 241 |
+
self.max_target_positions = max_target_positions
|
| 242 |
+
|
| 243 |
+
# Audio Classification-specific parameters. Feel free to ignore for other classes.
|
| 244 |
+
self.classifier_proj_size = classifier_proj_size
|
| 245 |
+
self.use_weighted_layer_sum = use_weighted_layer_sum
|
| 246 |
+
|
| 247 |
+
# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
|
| 248 |
+
self.apply_spec_augment = apply_spec_augment
|
| 249 |
+
self.mask_time_prob = mask_time_prob
|
| 250 |
+
self.mask_time_length = mask_time_length
|
| 251 |
+
self.mask_time_min_masks = mask_time_min_masks
|
| 252 |
+
self.mask_feature_prob = mask_feature_prob
|
| 253 |
+
self.mask_feature_length = mask_feature_length
|
| 254 |
+
self.mask_feature_min_masks = mask_feature_min_masks
|
| 255 |
+
|
| 256 |
+
self.median_filter_width = median_filter_width
|
| 257 |
+
|
| 258 |
+
# Loss function parameters. Feel free to ignore for other classes.
|
| 259 |
+
self.loss_fct = loss_fct
|
| 260 |
+
self.label_smoothing = label_smoothing
|
| 261 |
+
self.scale = scale
|
| 262 |
+
self.margin = margin
|
| 263 |
+
self.easy_margin = easy_margin
|
| 264 |
+
self.reduction = reduction
|
| 265 |
+
|
| 266 |
+
super().__init__(
|
| 267 |
+
pad_token_id=pad_token_id,
|
| 268 |
+
bos_token_id=bos_token_id,
|
| 269 |
+
eos_token_id=eos_token_id,
|
| 270 |
+
is_encoder_decoder=is_encoder_decoder,
|
| 271 |
+
decoder_start_token_id=decoder_start_token_id,
|
| 272 |
+
suppress_tokens=suppress_tokens,
|
| 273 |
+
begin_suppress_tokens=begin_suppress_tokens,
|
| 274 |
+
**kwargs,
|
| 275 |
+
)
|