Kimang18 commited on
Commit
33a2c8c
·
verified ·
1 Parent(s): 70a0e00

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +64 -344
README.md CHANGED
@@ -84,204 +84,78 @@ Finally, the auditory-lingual decoder adopts point-wise dynamic rescaled Gaussia
84
  <!-- Provide the basic links for the model. -->
85
 
86
  - **Repository:** https://github.com/Kimang18/KrorngAI/tree/main/tror-yong-asr
87
- - **Blog Post:** https://kimang18.github.io/krorngai-blog/TrorYongASR/
88
  - **Demo:** https://krorngai-troryongasr-demo.hf.space
89
 
90
 
91
- ### Model Architecture
92
-
93
- #### Length-Aware Rotary Position Embedding
94
-
95
- Length-Aware Rotary Position Embedding (LARoPE), a modification to RoPE, calculates relative distances between query and key vectors using length-normalized indices instead of absolute positional indices [@kim2026length].
96
- This extension induces diagonal bias in the attention score maps to better align the query vector from one source to the key vector from another source.
97
- LARoPE helps improve text-speech alignment in Text-To-Speech models [@kim2026length].
98
-
99
- With permuted sequence modeling design, speech-text alignment in cross-attention layer is crucial to TrorYongASR.
100
- Leveraging LARoPE, TrorYongASR2 achieves significant performance improvement (see @fig-loss).
101
- In addition, to enhance the expressivity of LARoPE as well as RoPE, the lowest frequency portion of the rotation are replaced by zero frequency (_i.e.,_ no rotation).
102
- This is a hybrid architecture of NoPE and RoPE proposed by [@barbero2024round].
103
- It enables channels without rotation to better carry semantic information.
104
-
105
- LARoPE requires the knowledge of audio length and text sequence length.
106
- As the text sequence length is unknown during inference, a length predictor module is designed to predict the sequence length given the audio.
107
-
108
-
109
- ##### Length Predictor
110
-
111
- To make TrorYongASR2 as lightweight as possible, length predictor infers the length of text sequence conditioned directly on the audio encoding.
112
- TrorYongASR2 limits the output text to 448 tokens.
113
- Therefore, length predictor's head is a linear layer with a softcap as the following:
114
-
115
- $$
116
- \mathrm{logits}\leftarrow \mathrm{\beta} \times tanh(\mathrm{logits} / \mathrm{\beta})
117
- $$
118
- where \\( \beta=224 \\).
119
- So, the output of length predictor stays between $-224$ and $224$.
120
- Since the target output space is $\{0, \dots, 448\}$, the length prediction is shifted by $+224$ and mean-squared-error loss can be used to train the length predictor.
121
- Note that no gradient from this length loss should flow to the audio encoder of TrorYongASR2.
122
- The only role of audio encoder is to capture meaningful features of input audio for the auditory-lingual decoder.
123
-
124
- #### Gated Attention Layers
125
-
126
- Auditory-lingual decoder of TrorYongASR is just a single Transformer.
127
- So, the expressivity of the attention mechanisms in this block plays a vital role in improving the model performance.
128
- TrorYongASR2 augments the attention layers of this block with an input-dependent head-specific output gate.
129
- This gate allows the input to modulate the scaled dot-product attention and thus mitigate the 'attention sink' [@qiu2026gated].
130
-
131
- Concretely, for hidden state $\bh$, attention layers have additional parameter $W^g$ such that the gate score for head $i$ is given by $\mathrm{Sigmoid}(W^g_i\bh)$.
132
- Let $\mathrm{head}_i=\mathrm{Attention}(\bh, W^q_i, W^k_i, W^v_i)$ be the scaled dot-product attention of head $i$.
133
- The gated output of multi-head attention is given by
134
- $$
135
- \bo=W^o\mathrm{Concat}\bigg[\mathrm{Sigmoid}(W^g_1\bh)\mathrm{head}_1, \dots, \mathrm{Sigmoid}(W^g_H\bh)\mathrm{head}_H\bigg]
136
- $$
137
- where $H$ is the number of heads in the attention layer.
138
- Hence, the hidden state $\bh$ can shut down or streamlining the scaled dot-product attention from specific head into the residual stream.
139
- This makes the attention layers more expressive.
140
-
141
- With the custom design of TrorYongASR, the head-specific score in self-attention layer is derived from context vectors, not the target token position embeddings (see @fig-archit).
142
- For cross-attention layer, the gate score is generated from the hidden state that derives the query vector for speech-text alignment.
143
-
144
-
145
- #### Normalization-free Transformer
146
-
147
- While normalization layers are crucial to the Transformer, they require a significant amount of compute compared to point-wise activation function.
148
- This induces longer training time and slower inference speed.
149
- [@chen2026stronger] illustrates that Dynamic rescaled Gaussian cumulative distribution function (abbreviated to Derf) can be used to replace normalization layers without hurting the performance.
150
- In fact, their analysis suggests performance gains compared to LayerNorm and RMSNorm across a wide range of domains, including visual recognition and generation, speech representation, and DNA sequence modeling.
151
- TrorYongASR2, thus, embraces this activation function in its auditory-lingual decoder and witnesses the gains in decoding performance and inference speed.
152
- However, TrorYongASR2 still maintains normalization layers over input representation (context vector, and audio encoding) and over pre-logit hidden state (see @fig-archit), as training otherwise became unstable.
153
-
154
-
155
- #### Additional Model's Capabilities
156
-
157
-
158
- ##### Audio with arbitrary length
159
-
160
- TrorYongASR2 is trained with audio of arbitrary length.
161
- This aims at minimizing compute due to pad frames.
162
- Concretely, rather than padding each audio to 30-second length, audios are padded batch by batch to the longest length in the batch (the maximum length is still limited to 30-second long) and the attention mask is derived accordingly.
163
-
164
- In the audio encoder, the number of frames of log-mel spectrogram is reduced by half by 1D convolutional layer.
165
- So, the attention mask is also down sampled by half using 1D max pooling layer with the same configuration of the 1D convolutional layer (_i.e.,_ the same kernel size, stride, etc.).
166
- This updated attention mask is used all the way from encoder transformers in audio encoder to the cross-attention layer of auditory-lingual decoder, as well as the length predictor module.
167
-
168
- With this training pipeline, TrorYongASR2 works directly with audios of arbitrary length during inference.
169
- This means that the inference speed is also faster than the previous version.
170
-
171
- ##### Voice-Activity Detection
172
-
173
- Another feature of speech-to-text model is to detect whether there is speech in the audio or not.
174
- A well-performed model in such detection task reduces its hallucination in both transcription and translation tasks.
175
- For this feature, `nonspeech7k` is used in training TrorYongASR2.
176
-
177
- TrorYongASR2 follows the multi-task training format of Whisper but without timestamps:
178
- For any audio, the token sequence starts with _begin-of-sequence_ token and ends with _end-of-sequence_ token.
179
- If the audio contains no speech, the first token is followed by _no-speech_.
180
- Otherwise, the second and third tokens define the spoken language and the task respectively.
181
- Follow the third token are text tokens (see @fig-multi).
182
-
183
- ```mermaid
184
- flowchart LR
185
- classDef alert fill:#cb4b4f,stroke:#000,color:#fff;
186
- classDef success fill:#009245,stroke:#000,color:#fff;
187
- classDef warn fill:#FFEB3B,stroke:#000,color:#fff;
188
-
189
- A[Begin of sequence]:::success --> B[Language]
190
- A[Begin of sequence]:::success --> C[No speech]
191
- A ~~~ C
192
- B --> D[Transcribe]
193
- B --> E[Translate]
194
- D --> F[Text]
195
- E --> F[Text]
196
- C --> G[End of sequence]:::alert
197
- F --> G[End of sequence]:::alert
198
- ```
199
-
200
- Multi-task training format of TrorYongASR2.
201
- The token sequence of any audio starts with `[B]`, begin-of-sequence token.
202
- For audio without speech, `[B]` is followed by `nospeech` token and `[E]`, end-of-sequence token.
203
- For other audios, the second token, `[L]`, represents the language of speech (either `km` for Khmer or `en` for English).
204
- The third token is the task token `[T]` that conditions the distribution of the text tokens that follow: for English audio, `transcribe` token favors English text tokens, and `translate` token favors Khmer text tokens.
205
- For Khmer audio, it is the reverse
206
-
207
-
208
- ##### Translation
209
-
210
- TrorYongASR2 is trained with larger translation dataset.
211
- Concretely, there are around `142` hours of Khmer audio with English text and around `67` hours of English audio with Khmer text.
212
- This allows TrorYongASR2 to perform better for translation task.
213
-
214
-
215
  ## Training
216
 
217
  TrorYongASR2 is trained on 5 datasets:
218
 
219
- - `234` hours of `Digital-Divide-Data/khmer-speech-dataset` (the whole dataset contains 727.94 hours) for Khmer audio and Khmer text (transcription)
220
  - `train.360` split of `openslr/librispeech_asr` for English audio and English text (transcription)
221
  - `KrorngAI/DDD-Cambodia-khmer-speech-dataset-parquet-000-159-en-translate` for Khmer audio and English text (translation)
222
  - `KrorngAI/openslr-librispeech_asr-clean100-00000-19999-km-translate` for English audio and Khmer text (translation)
223
  - `nospeech7k` for no speech audio (voice activity detection)
224
 
225
- So, there are around `804` hours of audio in the training dataset.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
 
227
  To underline the gain from architectural improvement, TrorYongASR1 is retrained on the same 5 datasets above using the same set of hyperparameters used by TrorYongASR2.
228
- @fig-loss shows the training history of `tiny` configuration (for more information about the configuration, see section blow).
229
  TrorYongASR2 has smaller training and validation losses, and higher validation token accuracy.
230
  This shows the effectiveness of the new architectural design in TrorYongASR2.
231
  The refinement also manifests in the evaluation below.
232
 
233
- ![Training history of TrorYongASR1 represented by the blue color and TrorYongASR2 represented by the red one. The first row shows the training loss and the second one describe validation performance. The top right plot shows the moving average of training loss. All plots suggest that TrorYongASR2 has better performance compared to TrorYongASR1.](./figures/train_val.png){#fig-loss}
 
 
 
 
 
 
 
 
234
 
235
- <!--
236
  ### Training Hyperparameters
237
 
238
  - **Training regime:** 16-mixed precision training using `LightningAI` package
 
239
  - **Optimizer:** MuonAdamW (custom implementation)
240
- - **Learning rate:** Linear Warmup (38 optimizer steps) + CosineAnnealing (3774 optimizer steps)
241
- - **Weight decay:** 0.1
242
  - **Effective Batch size:** 64
243
- - **Number of optimizer steps:** 3812
244
- - **Number of epochs:** roughly 2 epochs
245
  - **Gradient Clip Value:** 0.5 (only for parameters trained by AdamW)
246
 
247
 
248
- ### Speeds, Sizes, Times
249
-
250
- The training was conducted over 3812 optimizer steps.
251
-
252
- - For tiny variant, the training took around 6 hours on 1 Tesla T4 GPU.
253
- - For small variant, the training took around 7 hours on 2 Tesla T4 GPU (using DDP strategy).
254
- -->
255
-
256
- # Evaluation
257
 
258
- The evaluation assesses two capabilities — 1) language identification and 2) transcription — on two datasets ([`google/fleurs`](https://huggingface.co/datasets/Kimang18/google-fleurs-km-kh) for Khmer and [`openslr/librispeech_asr`](https://huggingface.co/datasets/openslr/librispeech_asr) for English).
 
259
  All results are from the **test split** of each dataset.
260
 
261
  | Dataset | Language | Testing samples | Description |
262
  |-----------------------|------------|------------------|---------------------------------------------------|
263
  | **google/fleurs** | Khmer | 765 | Multi-lingual dataset with Khmer language samples |
264
- | **librispeech.clean** | English | 2611 | Clean speech dataset for English transcription |
265
 
266
- Audios longer than `30 seconds` are excluded from the evaluation (that is why `google/fleurs` has 765 samples instead of 771 and `librispeech.clean` has 2611 instead of 2620).
267
 
268
- **TrorYongASR2** has 2 configurations as the following
269
 
270
- | **Model Size** | Tiny | Small |
271
- |:-----------------:|:-----------------:|:-------------------:|
272
- | **Audio Encoder** | 4 layers, 6 heads | 12 layers, 12 heads |
273
- | **Audio Context** | 1500 | 1500 |
274
- | **Text Decoder** | 1 layer, 12 heads | 1 layer, 24 heads |
275
- | **Text Context** | 448 | 448 |
276
- | **Embedding Dim** | 384 | 768 |
277
- | **Parameters** | 29M | 136M |
278
-
279
- The audio array is processed to log-mel spectrogram with `80` mel bins (the same as Whisper models of the same size)
280
-
281
- These configurations are the same as the ones of TrorYongASR1.
282
-
283
-
284
- ### Transcription
285
 
286
  For transcription task, 3 metrics below are used
287
 
@@ -289,11 +163,11 @@ For transcription task, 3 metrics below are used
289
  - **Character Error Rate (CER)**: Proportion of characters that are incorrect
290
  - **Word Error Rate (WER)**: Proportion of words that are incorrect
291
 
292
- Token Error Rate measures model's capability in predicting the next token given the audio input and the current sequence of tokens.
293
- This metric is weaker than Word Error Rate (WER) and Character Error Rate (CER) because it doesn't account for insertions, deletions, substitutions, and autoregression as comprehensively.
294
 
295
 
296
- **Results:**
297
 
298
  | Model | Metric | Khmer (`fleurs`) | English (`librispeech.clean`) |
299
  |-----------|--------|------------------|-------------------------------|
@@ -304,7 +178,6 @@ This metric is weaker than Word Error Rate (WER) and Character Error Rate (CER)
304
  | | CER | 29.26% | 6.05% |
305
  | | TER | 38% | 5% |
306
 
307
- : {.striped .hover}
308
 
309
  Both configurations performance well on English language.
310
  However, Khmer language remains a challenge.
@@ -318,166 +191,27 @@ It is due to no-boundary Khmer words that Token Error Rate is utilized as one of
318
 
319
  | Size | Model | Parameters | Khmer (`fleurs`) | English (`librispeech.clean`) |
320
  | -------- | ------------ | ---------- | --------------------------- | ----------------------------- |
321
- | **Tiny** | TrorYongASR2 | 29M | 57.07% | 20.35% |
322
  | | TrorYongASR1 | 29M | 75.88% | 54.33% |
323
- | | Whisper | 39M | 100.6% | 7.6% |
324
- | **Small**| TrorYongASR2 | 136M | 36.70% | 10.12% |
 
325
  | | TrorYongASR1 | 135M | 50.46% | 21.75% |
326
- | | Whisper | 244M | 104.4% | 3.4% |
327
 
328
- : {.striped .hover}
329
 
330
  **Key Observations:**
331
 
332
  - As mentioned above, TrorYongASR2 clearly outperforms TrorYongASR1 and requires just a small increase in the number of parameters (the increase comes from additional length predictor and gate projection layers)
333
- - Whisper models have more parameters for comparable configuration (39M vs 29M for Tiny, 244M vs 136M for Small)
334
- - Whisper shows significantly lower word error rates on English (7.6% vs 20.35% for Tiny, 3.4% vs 10.12% for Small)
335
- - Whisper performs worse on Khmer (100.6% vs 57.07% for Tiny, 36.70% vs 50.46% for Small)
336
-
337
- **Note:** `WER` data of Whisper is taken from their [paper](https://arxiv.org/abs/2212.04356).
338
-
339
- **Note on Translation Task:** According to [KrorngAI](https://huggingface.co/KrorngAI), the 2 translation datasets above is built using API of [TranslateKH](https://translatekh.mptc.gov.kh/) which, in turn, uses an AI model to translate Khmer to English and vice versa.
340
- Without the means to check the correctness of the translation over `209` hours of audio, TrorYongASR2 is not evaluated on any translation datasets.
341
- It should be noted that the translation performance of TrorYongASR2 is upper bounded by the AI model used in the backend of [TranslateKH](https://translatekh.mptc.gov.kh/).
342
-
343
-
344
- ## Downstream Tasks and Limitations
345
-
346
- TrorYongASR2 can be integrated into:
347
 
348
- - IoT devices: Smart speakers, voice assistants
349
- - Mobile application: Android/iOS apps with speech recognition
350
- - Larger ASR systems: As a component in multi-language ASR pipelines
351
 
352
- However, TrorYongASR2 does not have built-in support for timestamps prediction.
353
- It might be possible to develop this feature around built-in voice-activity detection.
354
- TrorYongASR2 is an Encoder-Decoder model for Automatic Speech Recognition (ASR) task.
355
- It is inspired by [PARSeq](https://github.com/baudm/parseq/tree/main) and [Whisper](https://github.com/openai/whisper/tree/main): the auditory-lingual decoder has only one transformer block.
356
-
357
-
358
- ### Old section
359
-
360
- <div align="center">
361
- <picture>
362
- <img src="figures/architecture.png" width="100%" alt="TrorYongASR">
363
- </picture>
364
- </div>
365
-
366
-
367
- ## Evaluation
368
-
369
- The evaluation assesses two capabilities — language detection and transcription — on two datasets ([`google/fleurs`](https://huggingface.co/datasets/Kimang18/google-fleurs-km-kh) for Khmer and [`openslr/librispeech_asr`](https://huggingface.co/datasets/openslr/librispeech_asr) for English). All results are from the **test split** of each dataset, representing the model's generalization ability to unseen data.
370
-
371
- ### Testing Data
372
-
373
- <!-- This should link to a Dataset Card if possible. -->
374
-
375
- <div align="center">
376
-
377
- | Dataset | Language | Testing examples | Description |
378
- | ------------- | ---------- | ------------- | - |
379
- | **google/fleurs** | Khmer | 765 | Multi-lingual dataset with Khmer language samples |
380
- | **librispeech.clean** | English | 2620 | Clean speech dataset for English transcription |
381
- </div>
382
-
383
- **Note:** Audios longer than `30 seconds` are excluded from the evaluation (that is why `google/fleurs` has 765 examples instead of 771).
384
-
385
- ### Metrics and Results
386
-
387
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
388
-
389
- #### Language Detection
390
-
391
- Language detection measures model’s capability to recognize the spoken language from audio input. Since TrorYongASR currently supports 2 languages, this task becomes binary classification task. Classic metrics are used:
392
-
393
- - **Precision**: Proportion of predicted languages that are correct
394
- - **Recall** : Proportion of actual language samples correctly identified
395
- - **F1-score** : Harmonic mean of precision and recall
396
-
397
- **Results:**
398
-
399
- <div align="center">
400
-
401
- | Model | Metrics | Khmer (`fleurs`) | English (`librispeech.clean`) |
402
- |-------|-----------|------------------|-------------------------------|
403
- | Tiny | Precision | 100% | 100% |
404
- | | Recall | 100% | 100% |
405
- | | F1-score | 100% | 100% |
406
- | Small | Precision | 100% | 99% |
407
- | | Recall | 96% | 100% |
408
- | | F1-score | 98% | 99% |
409
- </div>
410
-
411
- Tiny size achieved perfect language detection performance on both datasets, indicating excellent binary classification capability for distinguishing between Khmer and English audio. Small size performs slightly worst by tending to predict English language.
412
-
413
- The 100% language detection scores may appear unusually high. This is expected because during pre-training, the model performs permutations on word tokens starting from position 3, while the first three positions (start token, language token, and task token) remain fixed. Since language detection relies on the language token at position 1, and this token is never permuted during pre-training, the model can achieve perfect accuracy on language detection tasks.
414
-
415
-
416
- #### Transcription
417
-
418
- For transcription task, 3 metrics below are used
419
-
420
- - **Token Error Rate (TER)** : Proportion of incorrectly transcribed tokens
421
- - **Character Error Rate (CER)** : Proportion of characters that are incorrect
422
- - **Word Error Rate (WER)** : Proportion of words that are incorrect
423
-
424
- Token Error Rate (TER) measures model's capability in predicting the next token given the audio input and the current sequence of tokens. This metric is weaker than Word Error Rate (WER) and Character Error Rate (CER) because it doesn't account for insertions, deletions, substitutions, and autoregression as comprehensively. Token Error Rate is used here because Khmer text lacks word boundaries, making WER and CER calculations challenging without additional preprocessing.
425
-
426
-
427
- **Transcription Results:**
428
-
429
- <div align="center">
430
-
431
- | Model | Metric | Khmer (`fleurs`) | English (`librispeech.clean`) | Mixed (Khmer + English) |
432
- |-----------|----------------------------|------------------|-------------------------------|-------------------------|
433
- | **Tiny** | WER | 75.81% | 54.33% | 60.36% |
434
- | | CER | 54.99% | 42.41% | 46.18% |
435
- | | TER | 54% | 17% | 27% |
436
- | **Small** | WER | 50.46% | 21.75% | 29.78% |
437
- | | CER | 35.89% | 16.58% | 22.37% |
438
- | | TER | 43% | 8% | 18% |
439
- </div>
440
-
441
- **Key Observations:**
442
-
443
- - The tiny model shows strong performance on English (54.33% WER, 42.41% CER, 17% TER)
444
- - Performance drops significantly for Khmer (75.88% WER, 54.99% CER, 54% TER)
445
- - The small model shows strong performance on English (21.75% WER, 16.58% CER, 8% TER)
446
- - Performance for Khmer is moderate (50.46% WER, 35.89% CER, 43% TER)
447
- - The larger model benefits from increased embedding dimension (768 vs 384) and more layers for audio encoder (12 vs 4)
448
-
449
- **Note:** To compute `CER` and `WER`, whitespaces are added between words in Khmer text (Khmer text does not have word boundaries like English text). To do so, `khmercut` PyPI package is used to tokenize Khmer text into words, and then the words are joined back together with whitespaces.
450
-
451
-
452
- **WER Comparison with Whisper:**
453
-
454
- | Tiny | Parameters | Khmer (`fleurs`) | English (`librispeech.clean`) |
455
- | ------- | -------- | --------------------------- | --- |
456
- | TrorYongASR | 29M | 75.88% | 54.33% |
457
- | Whisper | 39M | 100.6% | 7.6% |
458
-
459
- | Small | Parameters | Khmer (`fleurs`) | English (`librispeech.clean`) |
460
- | ------- | -------- | --------------------------- | --- |
461
- | TrorYongASR | 135M | 50.46% | 21.75% |
462
- | Whisper | 244M | 104.4% | 3.4% |
463
-
464
- **Key Observations:**
465
-
466
- - Whisper models have more parameters for comparable sizes (39M vs 29M for Tiny, 244M vs 135M for Small)
467
- - Whisper shows significantly lower word error rates on English (7.6% vs 54.33% for Tiny, 3.4% vs 12.95% for Small)
468
- - Whisper performs worse on Khmer (100.6% vs 75.88% for Tiny, 104.4% vs 50.46% for Small)
469
- - Error rates > 100% for Whisper on Khmer indicate the model is overfitting to the training data
470
-
471
- **Note:** `WER` data of Whisper is taken from their [paper](https://arxiv.org/abs/2212.04356).
472
-
473
-
474
- ### Result Summary
475
-
476
- **Language Detection:** Both model sizes achieved great performance across all metrics (Precision, Recall, F1-score) on both datasets, indicating excellent binary classification capability for distinguishing between Khmer and English audio. This high score is expected because during pre-training, the model performs permutations on word tokens starting from position 3, while the first three positions (start token, language token, and task token) remain fixed. Since language detection relies on the language token at position 1, and this token is never permuted during pre-training, the model can achieve perfect accuracy on language detection tasks.
477
-
478
- **Transcription:** The Small model shows strong performance on English (21.75% WER, 16.58% CER, 8% TER) and moderate performance for Khmer (50.46% WER, 35.89% CER, 43% TER). The Tiny model shows strong performance on English (54.33% WER, 42.41% CER, 17% TER) but significantly lower performance for Khmer (75.88% WER, 54.99% CER, 54% TER). This shows that TrorYongASR can be scaled to get higher performance.
479
-
480
- **Note on Translation Task:** The models are also trained for `translation` task, but evaluation is deferred to future work due to scarce data (there are only 2000 examples from Khmer audio to English text, and 1000 examples from English audio to Khmer text in the pre-training).
481
 
482
 
483
  ## How to Get Started with the Model
@@ -494,7 +228,7 @@ from transformers import AutoProcessor
494
  from tror_yong_asr import TrorYongASRModel, transcribe, translate, detect_language
495
 
496
 
497
- model_id = "KrorngAI/TrorYongASR-small"
498
  processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
499
  model = TrorYongASRModel.from_pretrained(model_id, trust_remote_code=True)
500
 
@@ -518,15 +252,15 @@ Notebook (TBA)
518
 
519
  ### Direct Use
520
 
521
- The Tiny model can be used directly for:
522
  - **Speech-to-text transcription**: transcribe Khmer and English audio
523
  - **Speech-to-text translation**: translate Khmer audio to English text and English audio to Khmer text
524
- - **Language detection**: Identify whether audio is in Khmer or English (100% accuracy)
525
- - **Edge computing**: Deploy on mobile devices, IoT devices, and embedded systems due to its small size (29M parameters)
526
  - **Real-time applications**: Low latency inference suitable for real-time speech interfaces
527
 
528
 
529
- ### Downstream Use [optional]
530
 
531
  The model can be integrated into:
532
  - **Mobile applications**: Android/iOS apps with speech recognition
@@ -538,10 +272,8 @@ The model can be integrated into:
538
  ## Bias, Risks, and Limitations
539
 
540
  **Technical Limitations:**
541
- - **No speech detection**: The model was not trained for this task. User needs to fine-tune the model for this task (TrorYongASRTokenizer has `<|nospeech|>` token.)
542
- - **Translate task**: The training data for translation task is scarce. User needs to fine-tune the model for better translation performance
543
- - **Noise robustness**: Performance may degrade in noisy environments
544
  - **No timestamp output**: The model does not support timestamp output
 
545
 
546
  **Sociotechnical Limitations:**
547
  - **Accent variability**: May not perform well on diverse Khmer accents
@@ -549,15 +281,6 @@ The model can be integrated into:
549
  - **Speaker variability**: May struggle with different speaking styles and rates
550
 
551
 
552
- ### Recommendations
553
-
554
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
555
-
556
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
557
-
558
-
559
-
560
-
561
  ## Citation
562
 
563
  <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
@@ -567,10 +290,11 @@ Users (both direct and downstream) should be made aware of the risks, biases and
567
  ```bibtex
568
  @online{khun2026,
569
  author = {Khun, Kimang},
570
- title = {TrorYongASR: {Permuted} {AutoRegressive} {Sequence}
571
- {Modeling} for {Automatic} {Speech} {Recognition}},
572
- date = {2026-05-07},
573
- url = {https://kimang18.github.io/krorngai-blog/TrorYongASR/},
 
574
  langid = {en}
575
  }
576
  ```
@@ -583,13 +307,9 @@ Users (both direct and downstream) should be made aware of the risks, biases and
583
 
584
  ## Acknowledgement
585
 
586
- [`LightningAI`](https://lightning.ai), Kaggle, and `Google Colab` did not specifically sponsor this project.
587
- But, both models are trained thanks to their free credits.
588
- So, huge thanks to [`LightningAI`](https://lightning.ai), Kaggle and `Google Colab`.
589
-
590
- Thanks to the authors of [`PARSeq`](https://github.com/baudm/parseq/tree/main) and [`Whisper`](https://github.com/openai/whisper/tree/main) for their publicly available sourcecode.
591
 
592
- Thanks to [`openslr`](https://openslr.org), [Mozilla Data Collective](https://mozilladatacollective.com/datasets/cml9h5vgc01bxmn075sjeftek) and Google for their publicly available dataset.
593
 
594
  ## Model Card Contact
595
 
 
84
  <!-- Provide the basic links for the model. -->
85
 
86
  - **Repository:** https://github.com/Kimang18/KrorngAI/tree/main/tror-yong-asr
87
+ - **Blog Post:** [https://kimang18.github.io/krorngai-blog/TrorYongASR2/](https://kimang18.github.io/krorngai-blog/TrorYongASR2/)
88
  - **Demo:** https://krorngai-troryongasr-demo.hf.space
89
 
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  ## Training
92
 
93
  TrorYongASR2 is trained on 5 datasets:
94
 
95
+ - 234 hours of `Digital-Divide-Data/khmer-speech-dataset` (the whole dataset contains 727.94 hours) for Khmer audio and Khmer text (transcription)
96
  - `train.360` split of `openslr/librispeech_asr` for English audio and English text (transcription)
97
  - `KrorngAI/DDD-Cambodia-khmer-speech-dataset-parquet-000-159-en-translate` for Khmer audio and English text (translation)
98
  - `KrorngAI/openslr-librispeech_asr-clean100-00000-19999-km-translate` for English audio and Khmer text (translation)
99
  - `nospeech7k` for no speech audio (voice activity detection)
100
 
101
+ So, there are around 804 hours of audio in the training dataset.
102
+
103
+ TrorYongASR2 has 2 configurations as the following
104
+
105
+ | **Model Size** | Tiny | Small |
106
+ |:-----------------:|:-----------------:|:-------------------:|
107
+ | **Audio Encoder** | 4 layers, 6 heads | 12 layers, 12 heads |
108
+ | **Audio Context** | 1500 | 1500 |
109
+ | **Auditory-lingual Decoder** | 1 layer, 12 heads | 1 layer, 24 heads |
110
+ | **Text Context** | 448 | 448 |
111
+ | **Embedding Dimension** | 384 | 768 |
112
+ | **Parameters** | 29M | 136M |
113
+
114
+ The audio array is processed to log-mel spectrogram with 80 mel bins (the same as Whisper models of the same size).
115
+ These configurations are the same as the ones of TrorYongASR1.
116
 
117
  To underline the gain from architectural improvement, TrorYongASR1 is retrained on the same 5 datasets above using the same set of hyperparameters used by TrorYongASR2.
118
+ @fig-loss shows the training history of `tiny` configuration.
119
  TrorYongASR2 has smaller training and validation losses, and higher validation token accuracy.
120
  This shows the effectiveness of the new architectural design in TrorYongASR2.
121
  The refinement also manifests in the evaluation below.
122
 
123
+ <figure>
124
+ <div style="text-align: center;"><a name='fig-loss' ><img src="https://kimang18.github.io/krorngai-blog/TrorYongASR2/figures/train_val.png" width="100%" /></a></div>
125
+ <figcaption>
126
+ Training history of TrorYongASR1 represented by the blue color and TrorYongASR2 represented by the red one.
127
+ The first row shows the training loss and the second one describes validation performance.
128
+ The top right plot shows the moving average of training loss.
129
+ All plots suggest that TrorYongASR2 has better performance compared to TrorYongASR1.
130
+ </figcaption>
131
+ </figure>
132
 
 
133
  ### Training Hyperparameters
134
 
135
  - **Training regime:** 16-mixed precision training using `LightningAI` package
136
+ - **Number of epochs:** roughly 2 epochs
137
  - **Optimizer:** MuonAdamW (custom implementation)
138
+ - **Number of optimizer steps:** 10149
139
+ - **Learning rate:** Linear Warmup (153 optimizer steps) + CosineAnnealing (9996 optimizer steps)
140
  - **Effective Batch size:** 64
 
 
141
  - **Gradient Clip Value:** 0.5 (only for parameters trained by AdamW)
142
 
143
 
144
+ ## Evaluation
 
 
 
 
 
 
 
 
145
 
146
+ ### Dataset
147
+ The evaluation assesses transcription capability on two datasets: 1) [`google/fleurs`](https://huggingface.co/datasets/Kimang18/google-fleurs-km-kh) for Khmer and 2) [`openslr/librispeech_asr`](https://huggingface.co/datasets/openslr/librispeech_asr) for English.
148
  All results are from the **test split** of each dataset.
149
 
150
  | Dataset | Language | Testing samples | Description |
151
  |-----------------------|------------|------------------|---------------------------------------------------|
152
  | **google/fleurs** | Khmer | 765 | Multi-lingual dataset with Khmer language samples |
153
+ | **librispeech_asr.clean** | English | 2611 | Clean speech dataset for English transcription |
154
 
155
+ Audio longer than 30 seconds are excluded from the evaluation (that is why `google/fleurs` has 765 samples instead of 771 and `librispeech_asr.clean` has 2611 instead of 2620).
156
 
 
157
 
158
+ ### Metrics
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
 
160
  For transcription task, 3 metrics below are used
161
 
 
163
  - **Character Error Rate (CER)**: Proportion of characters that are incorrect
164
  - **Word Error Rate (WER)**: Proportion of words that are incorrect
165
 
166
+ TER measures model's capability in predicting the next token given the audio input and the current sequence of tokens.
167
+ This metric is weaker than WER and CER because it doesn't account for insertions, deletions, substitutions, and autoregression as comprehensively.
168
 
169
 
170
+ ### Results
171
 
172
  | Model | Metric | Khmer (`fleurs`) | English (`librispeech.clean`) |
173
  |-----------|--------|------------------|-------------------------------|
 
178
  | | CER | 29.26% | 6.05% |
179
  | | TER | 38% | 5% |
180
 
 
181
 
182
  Both configurations performance well on English language.
183
  However, Khmer language remains a challenge.
 
191
 
192
  | Size | Model | Parameters | Khmer (`fleurs`) | English (`librispeech.clean`) |
193
  | -------- | ------------ | ---------- | --------------------------- | ----------------------------- |
194
+ | **Tiny** | TrorYongASR2 | 29M | **57.07%** | 20.35% |
195
  | | TrorYongASR1 | 29M | 75.88% | 54.33% |
196
+ | | Whisper | 39M | 100.6% | **7.6%** |
197
+ | | | | | |
198
+ | **Small**| TrorYongASR2 | 136M | **36.70%** | 10.12% |
199
  | | TrorYongASR1 | 135M | 50.46% | 21.75% |
200
+ | | Whisper | 244M | 104.4% | **3.4%** |
201
 
 
202
 
203
  **Key Observations:**
204
 
205
  - As mentioned above, TrorYongASR2 clearly outperforms TrorYongASR1 and requires just a small increase in the number of parameters (the increase comes from additional length predictor and gate projection layers)
206
+ - Whisper has most parameters for comparable configuration (39M vs 29M for `tiny`, and 244M vs 136M for `small`)
207
+ - Whisper shows significantly lower word error rates on English (7.6% for `tiny`, 3.4% for `small`)
208
+ - TrorYongASR2 performs best on Khmer dataset (57.07% for `tiny`, and 36.70% for `small`)
 
 
 
 
 
 
 
 
 
 
 
209
 
210
+ **Note:** `WER` data of Whisper is taken directly from their [paper](https://arxiv.org/abs/2212.04356).
 
 
211
 
212
+ **Note on Translation Task:** According to [KrorngAI](https://huggingface.co/KrorngAI), the 2 translation datasets above are built using the API of [TranslateKH](https://translatekh.mptc.gov.kh/) which, in turn, uses an AI model for the translation (Khmer to English and vice-versa).
213
+ Without any means to check the correctness of the translation over 209 hours of audio, TrorYongASR2 is not evaluated on any translation datasets.
214
+ It can be assumed that the translation performance of TrorYongASR2 is upper bounded by the AI model used in the backend of [TranslateKH](https://translatekh.mptc.gov.kh/).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
 
217
  ## How to Get Started with the Model
 
228
  from tror_yong_asr import TrorYongASRModel, transcribe, translate, detect_language
229
 
230
 
231
+ model_id = "KrorngAI/TrorYongASR2-small"
232
  processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
233
  model = TrorYongASRModel.from_pretrained(model_id, trust_remote_code=True)
234
 
 
252
 
253
  ### Direct Use
254
 
255
+ The model can be used directly for:
256
  - **Speech-to-text transcription**: transcribe Khmer and English audio
257
  - **Speech-to-text translation**: translate Khmer audio to English text and English audio to Khmer text
258
+ - **Language identification**: identify if the spoken language in an audio is Khmer or English (100% accuracy)
259
+ - **Edge computing**: Deploy on mobile devices, IoT devices, and embedded systems due to its small size (29M parameters for tiny or 136M for small)
260
  - **Real-time applications**: Low latency inference suitable for real-time speech interfaces
261
 
262
 
263
+ ### Downstream Use
264
 
265
  The model can be integrated into:
266
  - **Mobile applications**: Android/iOS apps with speech recognition
 
272
  ## Bias, Risks, and Limitations
273
 
274
  **Technical Limitations:**
 
 
 
275
  - **No timestamp output**: The model does not support timestamp output
276
+ - **Noise robustness**: Performance may degrade in noisy environments
277
 
278
  **Sociotechnical Limitations:**
279
  - **Accent variability**: May not perform well on diverse Khmer accents
 
281
  - **Speaker variability**: May struggle with different speaking styles and rates
282
 
283
 
 
 
 
 
 
 
 
 
 
284
  ## Citation
285
 
286
  <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
 
290
  ```bibtex
291
  @online{khun2026,
292
  author = {Khun, Kimang},
293
+ title = {TrorYongASR2: {Permuted} {Language} {Modeling} with
294
+ {Monotonic} {Alignment,} {Gated} {Attention,} and
295
+ {Normalization-free} {Design}},
296
+ date = {2026-10-19},
297
+ url = {https://kimang18.github.io/krorngai-blog/TrorYongASR2/},
298
  langid = {en}
299
  }
300
  ```
 
307
 
308
  ## Acknowledgement
309
 
310
+ Both models are trained thanks to the free credits from Kaggle, and `Google Colab`.
 
 
 
 
311
 
312
+ Thanks to [`KrorngAI`](https://huggingface.co/KrorngAI), [`openslr`](https://openslr.org), and [Mozilla Data Collective](https://mozilladatacollective.com/datasets/cml9h5vgc01bxmn075sjeftek) for their publicly available dataset.
313
 
314
  ## Model Card Contact
315