Model save
Browse files- .gitattributes +1 -0
- README.md +83 -263
.gitattributes
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 3 |
tokenizer_config.json -filter -diff -merge text
|
|
|
|
|
|
| 1 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 3 |
tokenizer_config.json -filter -diff -merge text
|
| 4 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,267 +1,87 @@
|
|
| 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 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
###
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 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
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
+
tags:
|
| 4 |
+
- generated_from_trainer
|
| 5 |
+
model-index:
|
| 6 |
+
- name: tiny-audio
|
| 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
|
| 14 |
+
|
| 15 |
+
This model is a fine-tuned version of [](https://huggingface.co/) on an unknown dataset.
|
| 16 |
+
It achieves the following results on the evaluation set:
|
| 17 |
+
- Loss: 1.8002
|
| 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.002
|
| 37 |
+
- train_batch_size: 14
|
| 38 |
+
- eval_batch_size: 14
|
| 39 |
+
- seed: 42
|
| 40 |
+
- optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
|
| 41 |
+
- lr_scheduler_type: polynomial
|
| 42 |
+
- lr_scheduler_warmup_steps: 1000
|
| 43 |
+
- num_epochs: 4
|
| 44 |
+
- label_smoothing_factor: 0.1
|
| 45 |
+
|
| 46 |
+
### Training results
|
| 47 |
+
|
| 48 |
+
| Training Loss | Epoch | Step | Validation Loss |
|
| 49 |
+
|:-------------:|:------:|:------:|:---------------:|
|
| 50 |
+
| 2.1624 | 0.1303 | 10000 | 1.8803 |
|
| 51 |
+
| 2.1100 | 0.2607 | 20000 | 1.8542 |
|
| 52 |
+
| 2.0734 | 0.3910 | 30000 | 1.8479 |
|
| 53 |
+
| 2.1233 | 0.5214 | 40000 | 1.8361 |
|
| 54 |
+
| 2.1015 | 0.6517 | 50000 | 1.8280 |
|
| 55 |
+
| 2.0839 | 0.7820 | 60000 | 1.8288 |
|
| 56 |
+
| 2.0971 | 0.9124 | 70000 | 1.8219 |
|
| 57 |
+
| 2.0907 | 1.0427 | 80000 | 1.8218 |
|
| 58 |
+
| 2.0599 | 1.1731 | 90000 | 1.8167 |
|
| 59 |
+
| 2.0747 | 1.3034 | 100000 | 1.8171 |
|
| 60 |
+
| 2.0713 | 1.4337 | 110000 | 1.8152 |
|
| 61 |
+
| 2.0866 | 1.5641 | 120000 | 1.8133 |
|
| 62 |
+
| 2.0904 | 1.6944 | 130000 | 1.8104 |
|
| 63 |
+
| 2.0554 | 1.8248 | 140000 | 1.8092 |
|
| 64 |
+
| 2.0968 | 1.9551 | 150000 | 1.8100 |
|
| 65 |
+
| 2.0644 | 2.0855 | 160000 | 1.8077 |
|
| 66 |
+
| 2.0499 | 2.2158 | 170000 | 1.8054 |
|
| 67 |
+
| 2.0570 | 2.3461 | 180000 | 1.8056 |
|
| 68 |
+
| 2.0432 | 2.4765 | 190000 | 1.8066 |
|
| 69 |
+
| 2.0413 | 2.6068 | 200000 | 1.8050 |
|
| 70 |
+
| 2.0373 | 2.7372 | 210000 | 1.8039 |
|
| 71 |
+
| 2.0117 | 2.8675 | 220000 | 1.8036 |
|
| 72 |
+
| 2.0437 | 2.9978 | 230000 | 1.8036 |
|
| 73 |
+
| 2.0454 | 3.1282 | 240000 | 1.8032 |
|
| 74 |
+
| 2.0181 | 3.2585 | 250000 | 1.8022 |
|
| 75 |
+
| 2.0266 | 3.3889 | 260000 | 1.8015 |
|
| 76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