pushing large
Browse files- README.md +179 -0
- export_models.sh +35 -0
- merges.txt +0 -0
- model.safetensors +3 -0
- tf_model.h5 +3 -0
- training_tokenizer-merges.txt +0 -0
README.md
CHANGED
@@ -1,3 +1,182 @@
|
|
1 |
---
|
2 |
license: cc-by-4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: cc-by-4.0
|
3 |
+
language:
|
4 |
+
- 'no'
|
5 |
+
- nb
|
6 |
+
- nn
|
7 |
+
- en
|
8 |
+
datasets:
|
9 |
+
- NbAiLab/ncc_speech
|
10 |
+
- NbAiLab/NST
|
11 |
+
- NbAiLab/NPSC
|
12 |
+
tags:
|
13 |
+
- audio
|
14 |
+
- asr
|
15 |
+
- automatic-speech-recognition
|
16 |
+
- hf-asr-leaderboard
|
17 |
+
metrics:
|
18 |
+
- wer
|
19 |
+
- cer
|
20 |
+
library_name: transformers
|
21 |
+
pipeline_tag: automatic-speech-recognition
|
22 |
+
widget:
|
23 |
+
- src: https://datasets-server.huggingface.co/assets/google/fleurs/--/nb_no/train/1/audio/audio.mp3
|
24 |
+
example_title: FLEURS sample 1
|
25 |
+
- src: https://datasets-server.huggingface.co/assets/google/fleurs/--/nb_no/train/4/audio/audio.mp3
|
26 |
+
example_title: FLEURS sample 2
|
27 |
---
|
28 |
+
|
29 |
+
# NB-Whisper Large (beta)
|
30 |
+
|
31 |
+
This is a **_public beta_** of the Norwegian NB-Whisper Large model released by the National Library of Norway. NB-Whisper is a series of models for automatic speech recognition (ASR) and speech translation, building upon the foundation laid by [OpenAI's Whisper](https://arxiv.org/abs/2212.04356). All models are trained on 20,000 hours of labeled data.
|
32 |
+
|
33 |
+
<center>
|
34 |
+
<figure>
|
35 |
+
<video controls>
|
36 |
+
<source src="https://huggingface.co/NbAiLab/nb-whisper-small-beta/resolve/main/king.mp4" type="video/mp4">
|
37 |
+
Your browser does not support the video tag.
|
38 |
+
</video>
|
39 |
+
<figcaption><a href="https://www.royalcourt.no/tale.html?tid=137662&sek=28409&scope=27248" target="_blank">Speech given by His Majesty The King of Norway at the garden party hosted by Their Majesties The King and Queen at the Palace Park on 1 September 2016.</a>Transcribed using the Small model.</figcaption>
|
40 |
+
</figure>
|
41 |
+
</center>
|
42 |
+
|
43 |
+
|
44 |
+
## Model Details
|
45 |
+
|
46 |
+
NB-Whisper models will be available in five different sizes:
|
47 |
+
|
48 |
+
| Model Size | Parameters | Availability |
|
49 |
+
|------------|------------|--------------|
|
50 |
+
| tiny | 39M | [NB-Whisper Tiny (beta)](https://huggingface.co/NbAiLab/nb-whisper-tiny-beta) |
|
51 |
+
| base | 74M | [NB-Whisper Base (beta)](https://huggingface.co/NbAiLab/nb-whisper-base-beta) |
|
52 |
+
| small | 244M | [NB-Whisper Small (beta)](https://huggingface.co/NbAiLab/nb-whisper-small-beta) |
|
53 |
+
| medium | 769M | [NB-Whisper Medium (beta)](https://huggingface.co/NbAiLab/nb-whisper-medium-beta) |
|
54 |
+
| large | 1550M | [NB-Whisper Large (beta)](https://huggingface.co/NbAiLab/nb-whisper-large-beta) |
|
55 |
+
|
56 |
+
An official release of NB-Whisper models is planned for the Fall 2023.
|
57 |
+
|
58 |
+
Please refer to the OpenAI Whisper model card for more details about the backbone model.
|
59 |
+
|
60 |
+
### Model Description
|
61 |
+
|
62 |
+
- **Developed by:** [NB AI-Lab](https://ai.nb.no/)
|
63 |
+
- **Shared by:** [NB AI-Lab](https://ai.nb.no/)
|
64 |
+
- **Model type:** `whisper`
|
65 |
+
- **Language(s) (NLP):** Norwegian, Norwegian Bokmål, Norwegian Nynorsk, English
|
66 |
+
- **License:** [Creative Commons Attribution 4.0 International (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/)
|
67 |
+
- **Finetuned from model:** [openai/whisper-small](https://huggingface.co/openai/whisper-small)
|
68 |
+
|
69 |
+
### Model Sources
|
70 |
+
|
71 |
+
<!-- Provide the basic links for the model. -->
|
72 |
+
|
73 |
+
- **Repository:** https://github.com/NbAiLab/nb-whisper/
|
74 |
+
- **Paper:** _Coming soon_
|
75 |
+
- **Demo:** http://ai.nb.no/demo/nb-whisper
|
76 |
+
|
77 |
+
## Uses
|
78 |
+
|
79 |
+
### Direct Use
|
80 |
+
|
81 |
+
This is a **_public beta_** release. The models published in this repository are intended for a generalist purpose and are available to third parties.
|
82 |
+
|
83 |
+
|
84 |
+
### Downstream Use
|
85 |
+
|
86 |
+
For Norwegian transcriptions we are confident that this public beta will give you State-of-the-Art results compared to currently available Norwegian ASR models of the same size. However, it is still known to show some hallucinations, as well as a tendency to drop part of the transcript from time to time. Please also note that the transcripts are typically not word by word. Spoken language and written language are often very different, and the model aims to "translate" spoken utterances into grammatically correct written sentences. We strongly believe that the best way to understand these models is to try them yourself.
|
87 |
+
|
88 |
+
A significant part of the training material comes from TV subtitles. Subtitles often shorten the content to make it easier to read. Typically, non-essential parts of the utterance can be also dropped. In some cases, this is a desired ability, in other cases, this is undesired. The final release of these model will provida a mechanism to control for this beaviour.
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
## Bias, Risks, and Limitations
|
93 |
+
|
94 |
+
This is a public beta that is not intended for production. Production use without adequate assessment of risks and mitigation may be considered irresponsible or harmful. These models may have bias and/or any other undesirable distortions. When third parties, deploy or provide systems and/or services to other parties using any of these models (or using systems based on these models) or become users of the models, they should note that it is their responsibility to mitigate the risks arising from their use and, in any event, to comply with applicable regulations, including regulations regarding the use of artificial intelligence. In no event shall the owner of the models (The National Library of Norway) be liable for any results arising from the use made by third parties of these models.
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
## How to Get Started with the Model
|
99 |
+
|
100 |
+
Use the code below to get started with the model.
|
101 |
+
|
102 |
+
```python
|
103 |
+
from transformers import pipeline
|
104 |
+
|
105 |
+
asr = pipeline(
|
106 |
+
"automatic-speech-recognition",
|
107 |
+
"NbAiLab/nb-whisper-large-beta"
|
108 |
+
)
|
109 |
+
asr(
|
110 |
+
"audio.mp3",
|
111 |
+
generate_kwargs={'task': 'transcribe', 'language': 'no'}
|
112 |
+
)
|
113 |
+
# {'text': ' Så mange anga kører seg i så viktig sak, så vi får du kører det tilbake med. Om kabaret gudam i at vi skal hjælge. Kør seg vi gjør en uda? Nei noe skal å abelistera sonvorne skrifer. Det er sak, så kjent det bare handling i samtatsen til bargører. Trudet første lask. På den å først så å køre og en gange samme, og så får vi gjør å vorte vorte vorte når vi kjent dit.'}
|
114 |
+
```
|
115 |
+
|
116 |
+
Timestamps can also be retrieved by passing in the right parameter.
|
117 |
+
|
118 |
+
```python
|
119 |
+
asr(
|
120 |
+
"audio.mp3",
|
121 |
+
generate_kwargs={'task': 'transcribe', 'language': 'no'},
|
122 |
+
return_timestamps=True,
|
123 |
+
)
|
124 |
+
# {'text': ' at så mange angar til seg så viktig sak, så vi får jo kjølget klare tilbakemeldingen om hva valget dem gjør at vi skal gjøre. Hva skjer vi gjøre nå da? Nei, nå skal jo administrationen vår skrivferdige sak, så kjem til behandling i samfærdshetshøyvalget, tror det første
|
125 |
+
# r. Først så kan vi ta og henge dem kjemme, og så får vi gjøre vårt valget når vi kommer dit.',
|
126 |
+
# 'chunks': [{'timestamp': (0.0, 5.34),
|
127 |
+
# 'text': ' at så mange angar til seg så viktig sak, så vi får jo kjølget klare tilbakemeldingen om'},
|
128 |
+
# {'timestamp': (5.34, 8.64),
|
129 |
+
# 'text': ' hva valget dem gjør at vi skal gjøre.'},
|
130 |
+
# {'timestamp': (8.64, 10.64), 'text': ' Hva skjer vi gjøre nå da?'},
|
131 |
+
# {'timestamp': (10.64, 17.44),
|
132 |
+
# 'text': ' Nei, nå skal jo administrationen vår skrivferdige sak, så kjem til behandling i samfærdshetshøyvalget,'},
|
133 |
+
# {'timestamp': (17.44, 19.44), 'text': ' tror det første år.'},
|
134 |
+
# {'timestamp': (19.44, 23.94),
|
135 |
+
# 'text': ' Først så kan vi ta og henge dem kjemme, og så får vi gjøre vårt valget når vi kommer dit.'}]}
|
136 |
+
```
|
137 |
+
|
138 |
+
## Training Data
|
139 |
+
Trained data comes from Språkbanken and the digital collection at the National Library of Norway. Training data includes:
|
140 |
+
|
141 |
+
- NST Norwegian ASR Database (16 kHz), and its corresponding dataset
|
142 |
+
- Transcribed speeches from the Norwegian Parliament produced by Språkbanken
|
143 |
+
- TV broadcast (NRK) subtitles (NLN digital collection)
|
144 |
+
- Audiobooks (NLN digital collection)
|
145 |
+
|
146 |
+
|
147 |
+
## Environmental Impact
|
148 |
+
|
149 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
150 |
+
|
151 |
+
Carbon emissions 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).
|
152 |
+
|
153 |
+
- **Hardware Type:** TPUv4
|
154 |
+
- **Hours used:** 1,536
|
155 |
+
- **Cloud Provider:** Google Cloud
|
156 |
+
- **Compute Region:** `us-central1`
|
157 |
+
- **Carbon Emitted:** Total emissions are estimated to be 247.77 kgCO₂ of which 100 percents were directly offset by the cloud provider.
|
158 |
+
|
159 |
+
|
160 |
+
#### Software
|
161 |
+
|
162 |
+
The model is trained using Jax/Flax. The final model is converted to Pytorch, Tensorflow, whisper.cpp and ONXX. Please tell us if you would like future models to be converted to other format.
|
163 |
+
|
164 |
+
## Citation & Contributors
|
165 |
+
The development of this model was part of the contributors' professional roles at the National Library of Norway, under the _NoSTram_ project led by _Per Egil Kummervold (PEK)_. The Jax code, dataset loaders, and training scripts were collectively designed by _Javier de la Rosa (JdlR)_, _Freddy Wetjen (FW)_, _Rolv-Arild Braaten (RAB)_, and _PEK_. Primary dataset curation was handled by _FW_, _RAB_, and _PEK_, while _JdlR_ and _PEK_ crafted the documentation. The project was completed under the umbrella of AiLab, directed by _Svein Arne Brygfjeld_.
|
166 |
+
|
167 |
+
All contributors played a part in shaping the optimal training strategy for the Norwegian ASR model based on the Whisper architecture.
|
168 |
+
|
169 |
+
_A paper detailing our process and findings is underway!_
|
170 |
+
|
171 |
+
|
172 |
+
## Acknowledgements
|
173 |
+
|
174 |
+
Thanks to [Google TPU Research Cloud](https://sites.research.google/trc/about/) for supporting this project with extensive training resources. Thanks to Google Cloud for supporting us with credits for translating large parts of the corpus. A special thanks to [Sanchit Ghandi](https://huggingface.co/sanchit-gandhi) for providing thorough technical advice in debugging and with the work of getting this to train on Google TPUs. A special thanks to Per Erik Solberg at Språkbanken for the collaboration with regard to the Stortinget corpus.
|
175 |
+
|
176 |
+
## Contact
|
177 |
+
We are releasing this ASR Whisper model as a public beta to gather constructive feedback on its performance. Please do not hesitate to contact us with any experiences, insights, or suggestions that you may have. Your input is invaluable in helping us to improve the model and ensure that it effectively serves the needs of users. Whether you have technical concerns, usability suggestions, or ideas for future enhancements, we welcome your input. Thank you for participating in this critical stage of our model's development.
|
178 |
+
|
179 |
+
If you intend to incorporate this model into your research, we kindly request that you reach out to us. We can provide you with the most current status of our upcoming paper, which you can cite to acknowledge and provide context for the work done on this model.
|
180 |
+
|
181 |
+
|
182 |
+
Please use this email as the main contact point, it is read by the entire team: <a rel="noopener nofollow" href="mailto:ailab@nb.no">ailab@nb.no</a>
|
export_models.sh
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
pip install optimum[exporters] tensorflow
|
3 |
+
|
4 |
+
python << END
|
5 |
+
from transformers import WhisperForConditionalGeneration, TFWhisperForConditionalGeneration, WhisperTokenizerFast
|
6 |
+
|
7 |
+
tokenizer = WhisperTokenizerFast.from_pretrained("./")
|
8 |
+
|
9 |
+
print("Saving model to PyTorch...", end=" ")
|
10 |
+
model = WhisperForConditionalGeneration.from_pretrained("./", from_flax=True)
|
11 |
+
model.save_pretrained("./", safe_serialization=True)
|
12 |
+
model.save_pretrained("./")
|
13 |
+
print("Done.")
|
14 |
+
|
15 |
+
print("Saving model to TensorFlow...", end=" ")
|
16 |
+
tf_model = TFWhisperForConditionalGeneration.from_pretrained("./", from_pt=True)
|
17 |
+
tf_model.save_pretrained("./")
|
18 |
+
print("Done.")
|
19 |
+
|
20 |
+
print("Saving model to ONNX...", end=" ")
|
21 |
+
from optimum.onnxruntime import ORTModelForSpeechSeq2Seq
|
22 |
+
ort_model = ORTModelForSpeechSeq2Seq.from_pretrained("./", export=True)
|
23 |
+
ort_model.save_pretrained("./onnx")
|
24 |
+
print("Done")
|
25 |
+
|
26 |
+
tokenizer.save_pretrained("./")
|
27 |
+
END
|
28 |
+
|
29 |
+
echo "Saving model to GGML (whisper.cpp)"
|
30 |
+
wget -O convert-h5-to-ggml.py "https://raw.githubusercontent.com/ggerganov/whisper.cpp/94aa56f19eed8b2419bc5ede6b7fda85d5ca59be/models/convert-h5-to-ggml.py"
|
31 |
+
mkdir -p whisper/assets
|
32 |
+
wget -O whisper/assets/mel_filters.npz "https://github.com/openai/whisper/raw/55237228425e39828bbb964fd7bf774c9962eb67/whisper/assets/mel_filters.npz"
|
33 |
+
python ./convert-h5-to-ggml.py ./ ./ ./
|
34 |
+
rm ./convert-h5-to-ggml.py
|
35 |
+
rm -rf ./whisper
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1359097517e148aa00dfb22a24debb9efc7358b319ddb8127f3ced62c313f036
|
3 |
+
size 6173370152
|
tf_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a1a73e0c41370a04a8f6cd4113876a2de1c557671dadd73e37314e792394d7b6
|
3 |
+
size 6174572376
|
training_tokenizer-merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|