Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
|
5 |
+
This is model is compiled explictly for AWS Neuronx(inferentia 2 / trainium 1) with following codes:
|
6 |
+
|
7 |
+
```python
|
8 |
+
from datasets import load_dataset
|
9 |
+
from transformers import AutoProcessor
|
10 |
+
|
11 |
+
from optimum.neuron import NeuronModelForCTC, pipeline
|
12 |
+
|
13 |
+
|
14 |
+
dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", split="validation")
|
15 |
+
dataset = dataset.sort("id")
|
16 |
+
sampling_rate = dataset.features["audio"].sampling_rate
|
17 |
+
|
18 |
+
# model_id = "hf-internal-testing/tiny-random-Wav2Vec2Model"
|
19 |
+
model_id = "facebook/wav2vec2-large-960h-lv60-self"
|
20 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
21 |
+
input_shapes = {"batch_size": 1, "audio_sequence_length": 100000}
|
22 |
+
compiler_args = {"auto_cast": "matmul", "auto_cast_type": "bf16"}
|
23 |
+
model = NeuronModelForCTC.from_pretrained(
|
24 |
+
model_id,
|
25 |
+
export=True,
|
26 |
+
disable_neuron_cache=True,
|
27 |
+
**input_shapes,
|
28 |
+
**compiler_args,
|
29 |
+
)
|
30 |
+
model.save_pretrained("wav2vec2_neuron")
|
31 |
+
```
|