patrickvonplaten eustlb HF Staff commited on
Commit
f74a921
·
1 Parent(s): 164070a

trfms-integration (#23)

Browse files

- trmfs integration (1f032b3c3f2c4d4c216945f6279069b743cdb2d7)
- update config (4eeddac9908f942fa3ed3e30e37485e6e7802f1f)


Co-authored-by: Eustache Le Bihan <eustlb@users.noreply.huggingface.co>

Files changed (5) hide show
  1. README.md +38 -2
  2. config.json +60 -0
  3. generation_config.json +9 -0
  4. model.safetensors +3 -0
  5. processor_config.json +15 -0
README.md CHANGED
@@ -196,9 +196,45 @@ We have added two simple example files that allow you to:
196
 
197
  ### Transformers
198
 
199
- *WIP ⏳*
200
 
201
- For progress, see: https://github.com/huggingface/transformers/pull/43769
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
  ### Community Contributions (Untested)
204
 
 
196
 
197
  ### Transformers
198
 
199
+ Starting with `transformers >= 5.2.0`, you can run Voxtral Realtime natively in Transformers!
200
 
201
+ For more details, refer to the [Transformers documentation](https://huggingface.co/docs/transformers/main/en/model_doc/voxtral_realtime).
202
+
203
+ #### Installation
204
+
205
+ Install Transformers:
206
+
207
+ ```bash
208
+ pip install --upgrade transformers
209
+ ```
210
+
211
+ Make sure to have `mistral-common` installed with audio dependencies:
212
+
213
+ ```bash
214
+ pip install --upgrade "mistral-common[audio]"
215
+ ```
216
+
217
+ ```python
218
+ import torch
219
+ from transformers import VoxtralRealtimeForConditionalGeneration, AutoProcessor
220
+ from datasets import load_dataset
221
+
222
+ repo_id = "mistralai/Voxtral-Mini-4B-Realtime-2602"
223
+
224
+ processor = AutoProcessor.from_pretrained(repo_id)
225
+ model = VoxtralRealtimeForConditionalGeneration.from_pretrained(repo_id, device_map="auto")
226
+
227
+ ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
228
+ audio = ds[0]["audio"]["array"]
229
+
230
+ inputs = processor(audio, return_tensors="pt")
231
+ inputs = inputs.to(model.device, dtype=model.dtype)
232
+
233
+ outputs = model.generate(**inputs)
234
+ decoded_outputs = processor.batch_decode(outputs, skip_special_tokens=True)
235
+
236
+ print(decoded_outputs[0])
237
+ ```
238
 
239
  ### Community Contributions (Untested)
240
 
config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "VoxtralRealtimeForConditionalGeneration"
4
+ ],
5
+ "audio_config": {
6
+ "activation_function": "gelu",
7
+ "attention_dropout": 0.0,
8
+ "head_dim": 64,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 1280,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 5120,
13
+ "max_position_embeddings": 1500,
14
+ "model_type": "voxtral_realtime_encoder",
15
+ "num_attention_heads": 32,
16
+ "num_hidden_layers": 32,
17
+ "num_key_value_heads": 32,
18
+ "num_mel_bins": 128,
19
+ "rms_norm_eps": 1e-05,
20
+ "rope_parameters": {
21
+ "rope_theta": 1000000.0,
22
+ "rope_type": "default"
23
+ },
24
+ "sliding_window": 750,
25
+ "vocab_size": 131072
26
+ },
27
+ "audio_length_per_tok": 8,
28
+ "default_num_delay_tokens": 6,
29
+ "downsample_factor": 4,
30
+ "dtype": "bfloat16",
31
+ "hidden_size": 3072,
32
+ "model_type": "voxtral_realtime",
33
+ "projector_hidden_act": "gelu",
34
+ "text_config": {
35
+ "attention_dropout": 0.0,
36
+ "bos_token_id": 1,
37
+ "eos_token_id": 2,
38
+ "head_dim": 128,
39
+ "hidden_act": "silu",
40
+ "hidden_size": 3072,
41
+ "initializer_range": 0.02,
42
+ "intermediate_size": 9216,
43
+ "max_position_embeddings": 131072,
44
+ "model_type": "voxtral_realtime_text",
45
+ "num_attention_heads": 32,
46
+ "num_hidden_layers": 26,
47
+ "num_key_value_heads": 8,
48
+ "pad_token_id": null,
49
+ "rms_norm_eps": 1e-05,
50
+ "rope_parameters": {
51
+ "rope_theta": 1000000.0,
52
+ "rope_type": "default"
53
+ },
54
+ "sliding_window": 8192,
55
+ "tie_word_embeddings": true,
56
+ "use_cache": true,
57
+ "vocab_size": 131072
58
+ },
59
+ "transformers_version": "5.2.0.dev0"
60
+ }
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 1,
3
+ "eos_token_id": 2,
4
+ "output_attentions": false,
5
+ "output_hidden_states": false,
6
+ "pad_token_id": 11,
7
+ "transformers_version": "5.2.0.dev0",
8
+ "use_cache": true
9
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e745e4902df6a4c48f29f2f8dc1f6d0fb4cc73c7156bc45923451a5bcdfcd1d6
3
+ size 8859446848
processor_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "feature_extractor": {
3
+ "feature_extractor_type": "VoxtralRealtimeFeatureExtractor",
4
+ "feature_size": 128,
5
+ "global_log_mel_max": 1.5,
6
+ "hop_length": 160,
7
+ "n_fft": 400,
8
+ "padding_side": "right",
9
+ "padding_value": 0.0,
10
+ "return_attention_mask": true,
11
+ "sampling_rate": 16000,
12
+ "win_length": 400
13
+ },
14
+ "processor_class": "VoxtralRealtimeProcessor"
15
+ }