mazesmazes commited on
Commit
1a57f53
·
verified ·
1 Parent(s): 648911e

Update README from MODEL_CARD.md

Browse files
Files changed (1) hide show
  1. README.md +263 -138
README.md CHANGED
@@ -1,142 +1,267 @@
1
  ---
2
- library_name: transformers
 
 
 
 
 
 
 
 
3
  tags:
4
- - generated_from_trainer
5
- model-index:
6
- - name: tiny-audio-embedded
7
- results: []
 
 
8
  ---
9
 
10
- <!-- This model card has been generated automatically according to the information the Trainer had access to. You
11
- should probably proofread and complete it, then remove this comment. -->
12
-
13
- # tiny-audio-embedded
14
-
15
- This model is a fine-tuned version of [](https://huggingface.co/) on the None dataset.
16
- It achieves the following results on the evaluation set:
17
- - Loss: 0.1981
18
-
19
- ## Model description
20
-
21
- More information needed
22
-
23
- ## Intended uses & limitations
24
-
25
- More information needed
26
-
27
- ## Training and evaluation data
28
-
29
- More information needed
30
-
31
- ## Training procedure
32
-
33
- ### Training hyperparameters
34
-
35
- The following hyperparameters were used during training:
36
- - learning_rate: 0.0001
37
- - train_batch_size: 32
38
- - eval_batch_size: 32
39
- - seed: 43
40
- - gradient_accumulation_steps: 2
41
- - total_train_batch_size: 64
42
- - optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
43
- - lr_scheduler_type: constant_with_warmup
44
- - lr_scheduler_warmup_steps: 500
45
- - num_epochs: 1
46
-
47
- ### Training results
48
-
49
- | Training Loss | Epoch | Step | Validation Loss |
50
- |:-------------:|:------:|:-----:|:---------------:|
51
- | 0.6455 | 0.0119 | 1000 | 0.2053 |
52
- | 0.6832 | 0.0238 | 2000 | 0.2058 |
53
- | 0.6383 | 0.0357 | 3000 | 0.2058 |
54
- | 0.6507 | 0.0476 | 4000 | 0.2069 |
55
- | 0.6877 | 0.0596 | 5000 | 0.2060 |
56
- | 0.6479 | 0.0715 | 6000 | 0.2054 |
57
- | 0.7227 | 0.0834 | 7000 | 0.2056 |
58
- | 0.7055 | 0.0953 | 8000 | 0.2057 |
59
- | 0.6465 | 0.1072 | 9000 | 0.2052 |
60
- | 0.7416 | 0.1191 | 10000 | 0.2046 |
61
- | 0.7090 | 0.1310 | 11000 | 0.2048 |
62
- | 0.6912 | 0.1429 | 12000 | 0.2060 |
63
- | 0.5886 | 0.1549 | 13000 | 0.2056 |
64
- | 0.7237 | 0.1668 | 14000 | 0.2045 |
65
- | 0.6725 | 0.1787 | 15000 | 0.2046 |
66
- | 0.6518 | 0.1906 | 16000 | 0.2038 |
67
- | 0.6546 | 0.2025 | 17000 | 0.2042 |
68
- | 0.6793 | 0.2144 | 18000 | 0.2032 |
69
- | 0.6697 | 0.2263 | 19000 | 0.2035 |
70
- | 0.7108 | 0.2382 | 20000 | 0.2042 |
71
- | 0.7447 | 0.2502 | 21000 | 0.2038 |
72
- | 0.6575 | 0.2621 | 22000 | 0.2039 |
73
- | 0.7154 | 0.2740 | 23000 | 0.2034 |
74
- | 0.6833 | 0.2859 | 24000 | 0.2024 |
75
- | 0.6613 | 0.2978 | 25000 | 0.2028 |
76
- | 0.6906 | 0.3097 | 26000 | 0.2025 |
77
- | 0.6843 | 0.3216 | 27000 | 0.2027 |
78
- | 0.6966 | 0.3335 | 28000 | 0.2023 |
79
- | 0.6801 | 0.3454 | 29000 | 0.2027 |
80
- | 0.7171 | 0.3574 | 30000 | 0.2027 |
81
- | 0.7029 | 0.3693 | 31000 | 0.2017 |
82
- | 0.6876 | 0.3812 | 32000 | 0.2019 |
83
- | 0.6646 | 0.3931 | 33000 | 0.2022 |
84
- | 0.6834 | 0.4050 | 34000 | 0.2022 |
85
- | 0.6868 | 0.4169 | 35000 | 0.2014 |
86
- | 0.6831 | 0.4288 | 36000 | 0.2019 |
87
- | 0.6309 | 0.4407 | 37000 | 0.2009 |
88
- | 0.6603 | 0.4527 | 38000 | 0.2007 |
89
- | 0.6818 | 0.4646 | 39000 | 0.2006 |
90
- | 0.6539 | 0.4765 | 40000 | 0.2001 |
91
- | 0.6999 | 0.4884 | 41000 | 0.2001 |
92
- | 0.6870 | 0.5003 | 42000 | 0.1997 |
93
- | 0.5977 | 0.5122 | 43000 | 0.2000 |
94
- | 0.6747 | 0.5241 | 44000 | 0.2002 |
95
- | 0.6695 | 0.5360 | 45000 | 0.2005 |
96
- | 0.6763 | 0.5479 | 46000 | 0.1992 |
97
- | 0.6656 | 0.5599 | 47000 | 0.2006 |
98
- | 0.6674 | 0.5718 | 48000 | 0.2000 |
99
- | 0.7177 | 0.5837 | 49000 | 0.1995 |
100
- | 0.6904 | 0.5956 | 50000 | 0.1999 |
101
- | 0.6421 | 0.6075 | 51000 | 0.2003 |
102
- | 0.6555 | 0.6194 | 52000 | 0.2004 |
103
- | 0.7010 | 0.6313 | 53000 | 0.2003 |
104
- | 0.6520 | 0.6432 | 54000 | 0.1993 |
105
- | 0.6284 | 0.6552 | 55000 | 0.1999 |
106
- | 0.6770 | 0.6671 | 56000 | 0.1994 |
107
- | 0.7453 | 0.6790 | 57000 | 0.1993 |
108
- | 0.6441 | 0.6909 | 58000 | 0.1978 |
109
- | 0.6670 | 0.7028 | 59000 | 0.1980 |
110
- | 0.6380 | 0.7147 | 60000 | 0.1979 |
111
- | 0.7013 | 0.7266 | 61000 | 0.1984 |
112
- | 0.6442 | 0.7385 | 62000 | 0.1988 |
113
- | 0.6750 | 0.7505 | 63000 | 0.1981 |
114
- | 0.6776 | 0.7624 | 64000 | 0.1985 |
115
- | 0.6316 | 0.7743 | 65000 | 0.1992 |
116
- | 0.6929 | 0.7862 | 66000 | 0.1988 |
117
- | 0.6887 | 0.7981 | 67000 | 0.1982 |
118
- | 0.6502 | 0.8100 | 68000 | 0.1975 |
119
- | 0.7152 | 0.8219 | 69000 | 0.1983 |
120
- | 0.6906 | 0.8338 | 70000 | 0.1985 |
121
- | 0.6128 | 0.8457 | 71000 | 0.1978 |
122
- | 0.5966 | 0.8577 | 72000 | 0.1973 |
123
- | 0.6726 | 0.8696 | 73000 | 0.1983 |
124
- | 0.6668 | 0.8815 | 74000 | 0.1984 |
125
- | 0.6337 | 0.8934 | 75000 | 0.1982 |
126
- | 0.6272 | 0.9053 | 76000 | 0.1973 |
127
- | 0.7112 | 0.9172 | 77000 | 0.1978 |
128
- | 0.5871 | 0.9291 | 78000 | 0.1989 |
129
- | 0.6428 | 0.9410 | 79000 | 0.1972 |
130
- | 0.6740 | 0.9530 | 80000 | 0.1966 |
131
- | 0.6933 | 0.9649 | 81000 | 0.1976 |
132
- | 0.6668 | 0.9768 | 82000 | 0.1975 |
133
- | 0.5919 | 0.9887 | 83000 | 0.1977 |
134
- | 0.7215 | 1.0 | 83950 | 0.1981 |
135
-
136
-
137
- ### Framework versions
138
-
139
- - Transformers 5.7.0
140
- - Pytorch 2.8.0+cu128
141
- - Datasets 3.6.0
142
- - Tokenizers 0.22.2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ datasets:
6
+ - speechbrain/LoquaciousSet
7
+ base_model:
8
+ - zai-org/GLM-ASR-Nano-2512
9
+ - Qwen/Qwen3-0.6B
10
+ pipeline_tag: automatic-speech-recognition
11
  tags:
12
+ - asr
13
+ - speech-recognition
14
+ - audio
15
+ - qwen
16
+ - glm-asr
17
+ library_name: transformers
18
  ---
19
 
20
+ # Tiny Audio
21
+
22
+ A speech recognition model trained in 24 hours on a single GPU for ~$12. Built with [Tiny Audio](https://github.com/alexkroman/tiny-audio)—a minimal, hackable ASR framework.
23
+
24
+ ## Quick Start
25
+
26
+ ```python
27
+ from transformers import pipeline
28
+
29
+ pipe = pipeline("automatic-speech-recognition", model="mazesmazes/tiny-audio", trust_remote_code=True)
30
+ result = pipe("audio.wav")
31
+ print(result["text"])
32
+ ```
33
+
34
+ ## Usage Examples
35
+
36
+ ### Basic Transcription
37
+
38
+ ```python
39
+ from transformers import pipeline
40
+
41
+ pipe = pipeline("automatic-speech-recognition", model="mazesmazes/tiny-audio", trust_remote_code=True)
42
+
43
+ # From file
44
+ result = pipe("audio.wav")
45
+ print(result["text"])
46
+
47
+ # From URL
48
+ result = pipe("https://example.com/audio.mp3")
49
+
50
+ # From numpy array (must be 16kHz)
51
+ import numpy as np
52
+ audio = np.random.randn(16000).astype(np.float32) # 1 second
53
+ result = pipe(audio)
54
+ ```
55
+
56
+ ### Batch Processing
57
+
58
+ ```python
59
+ # Process multiple files
60
+ files = ["audio1.wav", "audio2.wav", "audio3.wav"]
61
+ results = pipe(files, batch_size=4)
62
+ for r in results:
63
+ print(r["text"])
64
+ ```
65
+
66
+ ### Word-Level Timestamps
67
+
68
+ ```python
69
+ result = pipe("audio.wav", return_timestamps="word")
70
+ # Returns:
71
+ # {
72
+ # "text": "hello world",
73
+ # "chunks": [
74
+ # {"text": "hello", "timestamp": (0.0, 0.5)},
75
+ # {"text": "world", "timestamp": (0.6, 1.0)}
76
+ # ]
77
+ # }
78
+ ```
79
+
80
+ ### Streaming Inference
81
+
82
+ ```python
83
+ from tiny_audio import ASRModel, ASRProcessor
84
+ import torch
85
+
86
+ model = ASRModel.from_pretrained("mazesmazes/tiny-audio")
87
+ processor = ASRProcessor.from_pretrained("mazesmazes/tiny-audio")
88
+
89
+ # Load and process audio
90
+ import librosa
91
+ audio, sr = librosa.load("audio.wav", sr=16000)
92
+ inputs = processor(audio, sampling_rate=16000, return_tensors="pt")
93
+
94
+ # Stream tokens
95
+ for token in model.generate_streaming(inputs["input_features"]):
96
+ print(token, end="", flush=True)
97
+ ```
98
+
99
+ ### Using with torch directly
100
+
101
+ ```python
102
+ from tiny_audio import ASRModel, ASRProcessor
103
+ import torch
104
+ import librosa
105
+
106
+ # Load model and processor
107
+ model = ASRModel.from_pretrained("mazesmazes/tiny-audio")
108
+ processor = ASRProcessor.from_pretrained("mazesmazes/tiny-audio")
109
+
110
+ # Load audio (16kHz)
111
+ audio, sr = librosa.load("audio.wav", sr=16000)
112
+
113
+ # Process
114
+ inputs = processor(audio, sampling_rate=16000, return_tensors="pt")
115
+
116
+ # Generate
117
+ with torch.no_grad():
118
+ output = model.generate(
119
+ input_features=inputs["input_features"],
120
+ attention_mask=inputs["attention_mask"],
121
+ max_new_tokens=256
122
+ )
123
+
124
+ # Decode
125
+ text = processor.batch_decode(output, skip_special_tokens=True)[0]
126
+ print(text)
127
+ ```
128
+
129
+ ### GPU Inference
130
+
131
+ ```python
132
+ import torch
133
+
134
+ pipe = pipeline(
135
+ "automatic-speech-recognition",
136
+ model="mazesmazes/tiny-audio",
137
+ trust_remote_code=True,
138
+ device="cuda" # or device=0
139
+ )
140
+ ```
141
+
142
+ ### Half Precision
143
+
144
+ ```python
145
+ pipe = pipeline(
146
+ "automatic-speech-recognition",
147
+ model="mazesmazes/tiny-audio",
148
+ trust_remote_code=True,
149
+ torch_dtype=torch.float16,
150
+ device="cuda"
151
+ )
152
+ ```
153
+
154
+ ## Architecture
155
+
156
+ ```
157
+ Audio (16kHz) → GLM-ASR Encoder (frozen) → MLP Projector (trained) → Qwen3 (frozen) → Text
158
+ ```
159
+
160
+ Only the projector is trained (~12M params). The encoder and decoder remain frozen, leveraging their pretrained knowledge.
161
+
162
+ | Component | Model | Parameters | Status |
163
+ |-----------|-------|------------|--------|
164
+ | Audio Encoder | GLM-ASR-Nano-2512 | ~600M | Frozen |
165
+ | Projector | 2-layer MLP | ~12M | Trained |
166
+ | Language Model | Qwen3-0.6B | ~600M | Frozen |
167
+
168
+ ### How It Works
169
+
170
+ 1. **Audio Encoder**: GLM-ASR converts 16kHz audio into frame-level embeddings (768-dim)
171
+ 2. **Projector**: A 2-layer MLP with frame stacking bridges the audio and text embedding spaces
172
+ 3. **Language Model**: Qwen3 generates text autoregressively, conditioned on the projected audio
173
+
174
+ The projector reduces sequence length via frame stacking: `output_len = (input_len - 5) // 5 + 1`
175
+
176
+ ## Model Specifications
177
+
178
+ | Specification | Value |
179
+ |---------------|-------|
180
+ | Input | Audio (16kHz mono) |
181
+ | Output | Text transcription |
182
+ | Max Audio Length | ~30 seconds (limited by encoder) |
183
+ | Vocabulary | Qwen3 tokenizer |
184
+ | Languages | English only |
185
+ | Generation | Greedy decoding (num_beams=1, do_sample=False) |
186
+
187
+ ## Training Details
188
+
189
+ | | |
190
+ |---|---|
191
+ | **Dataset** | LoquaciousSet (25,000 hours) |
192
+ | **Hardware** | Single NVIDIA A40 |
193
+ | **Time** | ~24 hours |
194
+ | **Cost** | ~$12 |
195
+ | **Optimizer** | AdamW |
196
+ | **Learning Rate** | 1e-4 |
197
+ | **Batch Size** | 4 |
198
+ | **Steps** | 50,000 |
199
+
200
+ ## Limitations
201
+
202
+ - **English only**: Not trained on other languages
203
+ - **Sample rate**: Expects 16kHz audio (other rates resampled automatically)
204
+ - **Audio length**: Best for clips under 30 seconds
205
+ - **Accuracy**: May degrade on:
206
+ - Heavily accented speech
207
+ - Noisy or low-quality audio
208
+ - Domain-specific terminology
209
+ - Overlapping speakers
210
+ - **No punctuation**: Output is lowercase without punctuation by default
211
+
212
+ ## Requirements
213
+
214
+ ```
215
+ transformers>=4.40.0
216
+ torch>=2.0.0
217
+ torchaudio>=2.0.0
218
+ ```
219
+
220
+ Optional for streaming:
221
+ ```
222
+ librosa
223
+ soundfile
224
+ ```
225
+
226
+ ## Files
227
+
228
+ | File | Description |
229
+ |------|-------------|
230
+ | `config.json` | Model configuration |
231
+ | `model.safetensors` | Projector weights (~48MB) |
232
+ | `preprocessor_config.json` | Audio preprocessing config |
233
+ | `tokenizer.json` | Tokenizer |
234
+ | `tokenizer_config.json` | Tokenizer config |
235
+ | `special_tokens_map.json` | Special tokens |
236
+
237
+ Note: Only the projector weights are stored. The encoder (GLM-ASR) and decoder (Qwen3) are loaded from their respective HuggingFace repos.
238
+
239
+ ## Citation
240
+
241
+ If you use this model, please cite:
242
+
243
+ ```bibtex
244
+ @misc{tinyaudio2024,
245
+ author = {Alex Kroman},
246
+ title = {Tiny Audio: Minimal ASR Training},
247
+ year = {2024},
248
+ publisher = {GitHub},
249
+ url = {https://github.com/alexkroman/tiny-audio}
250
+ }
251
+ ```
252
+
253
+ ## Links
254
+
255
+ - [GitHub Repository](https://github.com/alexkroman/tiny-audio) - Train your own model
256
+ - [Free 3.5-hour Course](https://github.com/alexkroman/tiny-audio/blob/main/docs/course/0-course-overview.md) - Learn ASR from scratch
257
+ - [Live Demo](https://huggingface.co/spaces/mazesmazes/tiny-audio) - Try it in your browser
258
+
259
+ ## Acknowledgments
260
+
261
+ - [GLM-ASR](https://huggingface.co/zai-org/GLM-ASR-Nano-2512) for the audio encoder
262
+ - [Qwen3](https://huggingface.co/Qwen/Qwen3-0.6B) for the language model
263
+ - [LoquaciousSet](https://huggingface.co/datasets/speechbrain/LoquaciousSet) for training data
264
+
265
+ ## License
266
+
267
+ MIT