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
17
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
---
license: openrail
language:
  - da
base_model: Qwen/Qwen3-ASR-1.7B
tags:
  - automatic-speech-recognition
  - danish
  - qwen
  - asr
  - speech-to-text
  - coral
  - streaming
datasets:
  - alexandrainst/coral
library_name: transformers
pipeline_tag: automatic-speech-recognition
metrics:
  - wer
  - cer
model-index:
  - name: milo-asr
    results:
      - task:
          type: automatic-speech-recognition
          name: Speech Recognition
        dataset:
          type: alexandrainst/coral
          name: CoRal v2 Test
          split: test
        metrics:
          - type: wer
            value: 18.47
            name: WER
          - type: cer
            value: 7.86
            name: CER
---

# Milo-ASR: Dansk ASR Model

**Milo-ASR** er en "state of the art" Dansk automatic speech recognition (ASR) model baseret på [Qwen3-ASR-1.7B](https://huggingface.co/Qwen/Qwen3-ASR-1.7B), finetuned på  [CoRal v2 dataset](https://huggingface.co/datasets/alexandrainst/coral) for at gøre den bedre til at forstå dansk.

## Key Highlights

| Feature | Value |
|---------|-------|
| **WER on CoRal v2** | 18.47% (14% better than Whisper v3) |
| **CER on CoRal v2** | 7.86% (11% better than Whisper v3) |
| **Real-Time Factor** | 0.086 (45% faster than Whisper v3) |
| **Model Size** | ~1.7B parameters |

### Fordele nedarvet fra Qwen3-ASR

- **Streaming/Real-time transcription** via vLLM backend
- **Sang detection** - Til at kunne transskribere teksten fra lyde med baggrundsmusik (find ud af hvad Rasmus seebach synger 🤣)
- **Word-level timestamps** via forced alignment
- **30+ language support** (Danish optimized)
- **20 minutter pr. request** - Kan kører 20 minutter igennem pr. kald

---

## Performance Comparison

### CoRal v2 Test Set (9,123 samples, 17.3 hours)

| Model | WER | CER | RTF | Throughput | Parameters |
|-------|-----|-----|-----|------------|------------|
| **Milo-ASR** | **18.47%** | **7.86%** | **0.086** | 1.71 samples/s | ~1.7B |
| hviske-v3 (Whisper Large v3) | 21.47% | 8.79% | 0.156 | 0.94 samples/s | ~2B |

**Improvements over Whisper Large v3:**
- **14% reduction** in Word Error Rate
- **11% reduction** in Character Error Rate
- **45% faster** inference speed
- **15% fewer** parameters

### Comparison Plots

![WER Comparison](plots/wer_comparison.png)
![Speed Comparison](plots/rtf_comparison.png)
![Accuracy vs Speed](plots/accuracy_vs_speed.png)

---

## Quick Start

### Installation

```bash
pip install qwen-asr transformers torch
```

### Basic Usage

```python
from qwen_asr import Qwen3ASRModel

# Load the model
model = Qwen3ASRModel.from_pretrained(
    "pluttodk/Milo-ASR",
    dtype="bfloat16",
    device_map="cuda:0",
)

# Transcribe audio file
results = model.transcribe(
    audio="path/to/danish_audio.wav",
    language="Danish",
)

print(results[0].text)
```

---

## Advanced Usage

### Batch Transcription (Fast Processing)

Process multiple audio files efficiently in a single call:

```python
from qwen_asr import Qwen3ASRModel

model = Qwen3ASRModel.from_pretrained(
    "pluttodk/Milo-ASR",
    dtype="bfloat16",
    device_map="cuda:0",
    max_inference_batch_size=16,  # Process up to 16 files at once
)

# Batch transcribe multiple files
audio_files = ["audio1.wav", "audio2.wav", "audio3.wav"]
results = model.transcribe(
    audio=audio_files,
    language="Danish",
)

for i, result in enumerate(results):
    print(f"File {i+1}: {result.text}")
```

### Transcription with Timestamps

Get word-level timestamps using the forced aligner:

```python
from qwen_asr import Qwen3ASRModel

model = Qwen3ASRModel.from_pretrained(
    "pluttodk/Milo-ASR",
    forced_aligner="Qwen/Qwen3-ForcedAligner-0.6B",
    dtype="bfloat16",
    device_map="cuda:0",
)

results = model.transcribe(
    audio="path/to/audio.wav",
    language="Danish",
    return_time_stamps=True,
)

# Access word-level timestamps
for item in results[0].time_stamps.items:
    print(f"{item.start_time:.2f}s - {item.end_time:.2f}s: {item.text}")
```

### Streaming/Real-time Transcription (vLLM Backend)

For real-time streaming transcription, use the vLLM backend:

```python
from qwen_asr import Qwen3ASRModel

# Initialize with vLLM backend for streaming
model = Qwen3ASRModel.LLM(
    model="pluttodk/Milo-ASR",
    gpu_memory_utilization=0.8,
)

# Initialize streaming state
state = model.init_streaming_state(
    language="Danish",
    chunk_size_sec=2.0,  # Process audio in 2-second chunks
)

# Simulate streaming audio (16kHz mono float32)
import numpy as np

def audio_stream():
    """Replace with actual audio stream from microphone."""
    for chunk in audio_chunks:
        yield np.array(chunk, dtype=np.float32)

# Process streaming audio
for audio_chunk in audio_stream():
    state = model.streaming_transcribe(audio_chunk, state)
    print(f"Current transcription: {state.text}")

# Finalize stream
state = model.finish_streaming_transcribe(state)
print(f"Final transcription: {state.text}")
```

### Using with Transformers Directly

For more control, use the model directly with transformers:

```python
from transformers import AutoModel, AutoProcessor
import torch
import librosa

# Load model and processor
model = AutoModel.from_pretrained(
    "pluttodk/Milo-ASR",
    trust_remote_code=True,
    torch_dtype=torch.bfloat16,
    device_map="cuda:0",
)
processor = AutoProcessor.from_pretrained(
    "pluttodk/Milo-ASR",
    trust_remote_code=True,
)

# Load and preprocess audio
audio, sr = librosa.load("path/to/audio.wav", sr=16000, mono=True)

# Build input using chat template
messages = [
    {"role": "system", "content": ""},
    {"role": "user", "content": [{"type": "audio", "audio": audio}]},
]

text = processor.apply_chat_template(
    messages,
    add_generation_prompt=True,
    tokenize=False
)
text = text + "language Danish<asr_text>"

# Process and generate
inputs = processor(text=[text], audio=[audio], return_tensors="pt", padding=True)
inputs = inputs.to(model.device).to(model.dtype)

output_ids = model.generate(**inputs, max_new_tokens=512)
transcription = processor.batch_decode(
    output_ids[:, inputs["input_ids"].shape[1]:],
    skip_special_tokens=True,
)[0]

print(transcription)
```

### Singing Detection & Multi-Audio Support

The model inherits Qwen3-ASR's ability to handle singing and background music:

```python
from qwen_asr import Qwen3ASRModel

model = Qwen3ASRModel.from_pretrained(
    "pluttodk/Milo-ASR",
    dtype="bfloat16",
    device_map="cuda:0",
)

# Transcribe audio with singing or background music
results = model.transcribe(
    audio="path/to/song.wav",
    language="Danish",  # or None for auto-detection
)

print(results[0].text)
```

---

## Model Details

### Model Description

Milo-ASR is a Danish-specialized automatic speech recognition model created by finetuning [Qwen3-ASR-1.7B](https://huggingface.co/Qwen/Qwen3-ASR-1.7B) on the [CoRal v2 dataset](https://huggingface.co/datasets/alexandrainst/coral). The model achieves state-of-the-art performance on Danish speech recognition while maintaining fast inference speeds.

- **Developed by:** Mathias Oliver Valdbjørn Rønnelund
- **Model type:** Encoder-decoder speech recognition model
- **Language:** Danish (primary), with inherited multilingual capabilities
- **License:** Apache 2.0
- **Finetuned from:** [Qwen/Qwen3-ASR-1.7B](https://huggingface.co/Qwen/Qwen3-ASR-1.7B)

### Architecture

The model inherits the Qwen3-ASR architecture:

| Component | Specification |
|-----------|--------------|
| Audio Encoder | 24-layer transformer (1024 hidden dim, 16 attention heads) |
| Text Decoder | 28-layer transformer (2048 hidden dim, 16 attention heads) |
| Total Parameters | ~1.7 billion |
| Precision | bfloat16 |
| Audio Input | 16kHz mono WAV |

---

## Training Details

### Training Data

The model was finetuned on the [CoRal v2 dataset](https://huggingface.co/datasets/alexandrainst/coral), a comprehensive Danish speech corpus containing:
- Diverse Danish speakers across demographics
- Various recording conditions and audio qualities
- Natural conversational speech
- Read-aloud speech

### Training Procedure

**Training Approach:** Supervised Fine-Tuning (SFT) with chat template formatting

**Preprocessing:**
- Audio resampled to 16kHz mono
- Chat template applied with system prompt, audio input, and target transcription
- Prefix masking to train only on transcription tokens

**Training Hyperparameters:**

| Parameter | Value |
|-----------|-------|
| Base model | Qwen/Qwen3-ASR-1.7B |
| Learning rate | 2e-5 |
| Batch size (per device) | 8 |
| Gradient accumulation steps | 4 |
| Effective batch size | 32 |
| Epochs | 3 |
| Warmup ratio | 0.1 |
| Weight decay | 0.01 |
| Max gradient norm | 1.0 |
| Precision | bfloat16 |
| Optimizer | AdamW |
| LR scheduler | Linear decay |
| Total training steps | 23,448 |

**Hardware:** Training performed on NVIDIA GPUs (~25GB GPU memory per device)

---

## Evaluation

### Test Data

Evaluated on the CoRal v2 test split:
- **9,123 samples**
- **17.3 hours** of audio
- Diverse Danish speakers and recording conditions

### Metrics

| Metric | Description |
|--------|-------------|
| **WER** | Word Error Rate - percentage of words incorrectly transcribed (lower is better) |
| **CER** | Character Error Rate - percentage of characters incorrectly transcribed (lower is better) |
| **RTF** | Real-Time Factor - ratio of processing time to audio duration (< 1.0 = faster than real-time) |

### Results Summary

| Model | WER | CER | RTF | Throughput |
|-------|-----|-----|-----|------------|
| **Milo-ASR** | **18.47%** | **7.86%** | **0.086** | 1.71 samples/sec |
| hviske-v3 (Whisper v3) | 21.47% | 8.79% | 0.156 | 0.94 samples/sec |

---

## Citation

If you use this model, please cite:

```bibtex
@misc{Milo-ASR,
  author = {Rønnelund, Mathias Oliver Valdbjørn},
  title = {Milo-ASR: Danish ASR Model based on Qwen3-ASR},
  year = {2025},
  publisher = {HuggingFace},
  url = {https://huggingface.co/pluttodk/Milo-ASR}
}
```

Also consider citing the base model and dataset:

```bibtex
@article{qwen3asr,
  title={Qwen3-ASR Technical Report},
  author={Qwen Team},
  journal={arXiv preprint arXiv:2601.21337},
  year={2025}
}

@dataset{coral,
  title={CoRal: A Danish Speech Corpus},
  author={Alexandra Institute},
  year={2024},
  url={https://huggingface.co/datasets/alexandrainst/coral}
}
```

---

## Acknowledgements

- [Qwen Team](https://github.com/QwenLM) for Qwen3-ASR base model
- [Alexandra Institute](https://alexandra.dk/) for CoRal v2 lyd corpus