Jingya HF staff commited on
Commit
ef7007e
1 Parent(s): bf4f730

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -3
README.md CHANGED
@@ -1,3 +1,30 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ This is model is compiled explicitly for AWS Neuronx(inferentia 2 / trainium 1) with the following codes:
5
+
6
+ ```python
7
+ import torch
8
+ from datasets import load_dataset
9
+ from transformers import AutoProcessor, AutoFeatureExtractor
10
+
11
+ from optimum.neuron import NeuronModelForXVector, 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 = "anton-l/wav2vec2-base-superb-sv"
19
+ feature_extractor = AutoFeatureExtractor.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 = NeuronModelForXVector.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
+ ```