Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
|
5 |
+
This is model is compiled explicitly for AWS Neuronx(inferentia 2 / trainium 1) with the following codes:
|
6 |
+
|
7 |
+
```python
|
8 |
+
from datasets import load_dataset
|
9 |
+
from transformers import AutoProcessor
|
10 |
+
|
11 |
+
from optimum.neuron import NeuronModelForAudioClassification, 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 = "facebook/wav2vec2-large-960h-lv60-self"
|
19 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
20 |
+
input_shapes = {"batch_size": 1, "audio_sequence_length": 100000}
|
21 |
+
compiler_args = {"auto_cast": "matmul", "auto_cast_type": "bf16"}
|
22 |
+
model = NeuronModelForAudioClassification.from_pretrained(
|
23 |
+
model_id,
|
24 |
+
export=True,
|
25 |
+
disable_neuron_cache=True,
|
26 |
+
**input_shapes,
|
27 |
+
**compiler_args,
|
28 |
+
)
|
29 |
+
model.save_pretrained("wav2vec2_neuron")
|
30 |
+
```
|