d-matrix-user commited on
Commit
f63b478
·
verified ·
1 Parent(s): 2909112

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +57 -57
README.md CHANGED
@@ -1,58 +1,58 @@
1
- ---
2
- license: apache-2.0
3
- ---
4
-
5
- This is a d-Matrix functional reference of the whisper-medium model.
6
- The reference provides the following functional *configurations*:
7
- Configuration | Explanation
8
- :-- | :--
9
- **`BASELINE`** | a reference functionally equivalent to the original model
10
- **`BASIC`** | all linear algebraic operands quantized to `MXINT8-64`, and all other operations transformed to approximated kernel simulations
11
-
12
-
13
- ### Usage
14
-
15
- Install d-Matrix [Dmx_Compressor](https://github.com/d-matrix-ai/dmx-compressor) first.
16
- ```sh
17
- pip install dmx_compressor
18
- ```
19
-
20
- The following is an example model and its evaluation.
21
-
22
- ```python
23
- import torch
24
- from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
25
- from datasets import load_dataset
26
- from dmx.compressor.modeling import DmxModel
27
-
28
-
29
- device = "cuda:0" if torch.cuda.is_available() else "cpu"
30
- torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
31
-
32
- model_id = "d-matrix/whisper-medium"
33
-
34
- model = AutoModelForSpeechSeq2Seq.from_pretrained(
35
- model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
36
- )
37
- model.to(device)
38
-
39
- processor = AutoProcessor.from_pretrained(model_id)
40
-
41
- pipe = pipeline(
42
- "automatic-speech-recognition",
43
- model=model,
44
- tokenizer=processor.tokenizer,
45
- feature_extractor=processor.feature_extractor,
46
- torch_dtype=torch_dtype,
47
- device=device,
48
- )
49
-
50
- dataset = load_dataset("distil-whisper/librispeech_long", "clean", split="validation")
51
- sample = dataset[0]["audio"]
52
- shorter_audio = sample["array"][:1000]
53
-
54
- pipe.model = DmxModel.from_torch(pipe.model)
55
-
56
- result = pipe(shorter_audio)
57
- print(result["text"])
58
  ```
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ This is a d-Matrix functional reference of the whisper-medium model.
6
+ The reference provides the following functional *configurations*:
7
+ Configuration | Explanation
8
+ :-- | :--
9
+ **`BASELINE`** | a reference functionally equivalent to the original model
10
+ **`BASIC`** | all linear algebraic operands quantized to `MXINT8-64`
11
+
12
+
13
+ ### Usage
14
+
15
+ Install d-Matrix [Dmx_Compressor](https://github.com/d-matrix-ai/dmx-compressor) first.
16
+ ```sh
17
+ pip install dmx_compressor
18
+ ```
19
+
20
+ The following is an example model and its evaluation.
21
+
22
+ ```python
23
+ import torch
24
+ from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
25
+ from datasets import load_dataset
26
+ from dmx.compressor.modeling import DmxModel
27
+
28
+
29
+ device = "cuda:0" if torch.cuda.is_available() else "cpu"
30
+ torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
31
+
32
+ model_id = "d-matrix/whisper-medium"
33
+
34
+ model = AutoModelForSpeechSeq2Seq.from_pretrained(
35
+ model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
36
+ )
37
+ model.to(device)
38
+
39
+ processor = AutoProcessor.from_pretrained(model_id)
40
+
41
+ pipe = pipeline(
42
+ "automatic-speech-recognition",
43
+ model=model,
44
+ tokenizer=processor.tokenizer,
45
+ feature_extractor=processor.feature_extractor,
46
+ torch_dtype=torch_dtype,
47
+ device=device,
48
+ )
49
+
50
+ dataset = load_dataset("distil-whisper/librispeech_long", "clean", split="validation")
51
+ sample = dataset[0]["audio"]
52
+ shorter_audio = sample["array"][:1000]
53
+
54
+ pipe.model = DmxModel.from_torch(pipe.model)
55
+
56
+ result = pipe(shorter_audio)
57
+ print(result["text"])
58
  ```