File size: 23,899 Bytes
30951e5
 
 
 
 
 
8816e37
30951e5
 
 
 
a29dcac
a5b451f
a29dcac
 
a5b451f
 
3e08ac3
 
 
 
8816e37
 
 
 
 
 
 
30951e5
385b92d
790450f
385b92d
a6099b9
385b92d
4fa06ea
385b92d
790450f
 
 
 
ba814b7
385b92d
a5b451f
385b92d
790450f
385b92d
a6099b9
385b92d
ba814b7
385b92d
ba814b7
385b92d
de49693
9feb397
790450f
385b92d
a6099b9
 
a5b451f
385b92d
a6099b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a5b451f
99868b2
a6099b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99868b2
 
a6099b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99868b2
 
a6099b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99868b2
 
a6099b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99868b2
 
a6099b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99868b2
 
a6099b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99868b2
 
a6099b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385b92d
 
 
790450f
385b92d
a6099b9
7c98006
385b92d
790450f
385b92d
5392f0a
 
 
 
edf339b
5392f0a
 
 
 
 
 
 
 
 
 
 
790450f
93a13eb
5392f0a
790450f
5392f0a
790450f
5392f0a
 
 
 
 
 
 
 
a5b451f
5392f0a
 
790450f
 
5392f0a
385b92d
790450f
385b92d
790450f
385b92d
790450f
 
 
385b92d
edf339b
385b92d
790450f
 
 
 
 
 
 
 
 
385b92d
790450f
93a13eb
790450f
385b92d
790450f
 
 
 
385b92d
790450f
 
 
 
 
385b92d
790450f
 
a5b451f
385b92d
790450f
 
 
 
385b92d
a5b451f
a2391de
a5b451f
a2391de
 
 
 
 
a5b451f
a2391de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c98006
385b92d
7c98006
385b92d
a5b451f
385b92d
790450f
385b92d
 
 
790450f
385b92d
790450f
385b92d
edf339b
385b92d
790450f
385b92d
790450f
385b92d
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
---
library_name: transformers
license: mit
metrics:
- bleu
- wer
pipeline_tag: automatic-speech-recognition
tags:
- LLM-as-a-Judge
- chat
- audio
- safetensors
- vllm
datasets:
- MERaLiON/MNSC
base_model:
- openai/whisper-large-v2
widget:
- example_title: Librispeech sample 1
  src: https://cdn-media.huggingface.co/speech_samples/sample1.flac
  output:
    text: >-
      USER: Recognize the speech and give me the transcription.

      ASSISTANT:Going along slushy country roads and speaking to damp audiences
      in drafty schoolrooms day after day for a fortnight he’ll have to put in
      an appearance at some place of worship on sunday morning and he can come
      to us immediately afterwards
---

# MERaLiON

MERaLiON-AudioLLM is a Speech-Text Large Language Model tailored for Singapore’s multilingual and multicultural landscape. Integrating a localised [Whisper-large-v2](https://huggingface.co/openai/whisper-large-v2) speech encoder and [SEA-LION V3](https://huggingface.co/aisingapore/gemma2-9b-cpt-sea-lionv3-instruct) text decoder, MERaLiON-AudioLLM is finetuned on **260,000 hours of speech and audio data**, **6 various tasks**, to address the diverse linguistic nuances of Singapore's local accents and dialects.

MERaLiON stands for **M**ultimodal **E**mpathetic **R**easoning **a**nd **L**earning **i**n **O**ne **N**etwork.

- **Developed by:** I<sup>2</sup>R, A\*STAR
- **Model type:** MultiModal LLM
- **Language(s) (Speech):** English (Global & Singapore)
- **Language(s) (NLP):** English, Chinese, Vietnamese, Indonesian, Thai, Filipino, Tamil, Malay, Khmer, Lao, Burmese, Javanese, Sundanese
- **License:** MIT

We support model inference using the [Huggingface](#inference) and [vLLM](#vllm-inference) frameworks. For more technical details, please refer to our [report]().

## Model Description

MERaLiON-AudioLLM is designed to take in an **audio-text pair** as input and generate a **text output**.

The architecture comprises three key components: an **audio encoder** that transforms speech or audio inputs into sequences of vector representations, a **text decoder** that interprets and responds to natural language instructions, and an **adaptor module** that compresses the encoder representations while aligning the encoder’s hidden dimension with the text decoder’s embedding size.

Specifically, we fine-tuned the **MERaLiON-Whisper** encoder from Whisper-large-v2 for the audio encoder and used SEA-LION V3, a localised LLM developed by our partner AI Singapore as the text decoder.

<img src="model_architecture.png" alt="model_architecture" width="400" style="margin-left:'auto' margin-right:'auto' display:'block'"/>

## Capabilities

MERaLiON-AudioLLM is trained to mainly address 6 tasks, namely `Automatic Speech Recognition` (ASR), 
`Speech Translation` (ST), `Spoken Question Answering` (SQA), 
`Spoken Dialogue Summarization` (SDS), `Speech Instruction` (SI), and `Paralinguistics` (PARA). 

We benchmark MERaLiON-AudioLLM with a series of test sets from the [AudioBench benchmark](https://github.com/AudioLLMs/AudioBench) 
against three well-known AudioLLMs: `Qwen2-Audio 7B`, `WavLLM`, and `SALMONN`. We also compared with a cascaded model, 
which feeds the transcriptions recognized by Whisper-large-v2 and the instruction prompts to a Gemma2 9B CPT SEA-LIONv3 Instruct model to
get the responses. We tuned its hyperparameters and prompt template to optimise performance across
various speech-to-text tasks. As is shown in the following table, MERaLiON-AudioLLM performs better in the Singapore local context, 
as evidenced by evaluation results on Singapore's [Multitask National Speech Corpus](MERaLiON/MNSC) (MNSC) datasets. 

> [!NOTE]
> MNSC is a multitask speech understanding dataset derived and further annotated from [IMDA NSC Corpus](https://www.imda.gov.sg/how-we-can-help/national-speech-corpus).
> It focuses on the knowledge of Singapore's local accent, localised terms, and code-switching.

> [!NOTE]
> We assess ASR and ST tasks using Word Error Rate (WER) and BLEU scores, respectively.
> For other tasks, we employ the LLM-as-a-Judge framework,
> which uses a pre-trained large language model to evaluate task performance
> by generating and scoring responses based on relevance, coherence, and accuracy criteria.
> Refer to the [AudioBench paper](https://arxiv.org/abs/2406.16020) for more details.

<div class="table*">
<table>
<thead>
<tr>
  <th style="text-align: center;"><strong>Task</strong></th>
  <th style="text-align: center;"><strong>Dataset</strong></th>
  <th style="text-align: center;"><strong>MERaLiON</strong></th>
  <th style="text-align: center;"><strong>Qwen2-Audio 7B</strong></th>
  <th style="text-align: center;"><strong>WavLLM</strong></th>
  <th style="text-align: center;"><strong>SALMONN-7B</strong></th>
  <th style="text-align: center;"><strong>Cascaded Model</strong></th>
</tr>
</thead>
<tbody>
<tr>
  <td style="text-align: center;" rowspan="11"><strong>Automatic Speech Recognition</strong><br>WER (<span
  class="math inline"></span>)</td>
  <td style="text-align: center;">LibriSpeech-Test-Clean</td>
  <td style="text-align: center;">0.03</td>
  <td style="text-align: center;">0.03</td>
  <td style="text-align: center;"><strong><u>0.02</u></strong></td>
  <td style="text-align: center;">0.10</td>
  <td style="text-align: center;">0.03</td>
</tr>
<tr>
  <td style="text-align: center;">LibriSpeech-Test-Other</td>
  <td style="text-align: center;"><strong><u>0.05</u></strong></td>
  <td style="text-align: center;">0.06</td>
  <td style="text-align: center;"><strong><u>0.05</u></strong></td>
  <td style="text-align: center;">0.10</td>
  <td style="text-align: center;"><u>0.05</u></td>
</tr>
<tr>
  <td style="text-align: center;">Common-Voice-15-En-Test</td>
  <td style="text-align: center;"><strong><u>0.10</u></strong></td>
  <td style="text-align: center;">0.11</td>
  <td style="text-align: center;">0.15</td>
  <td style="text-align: center;">0.31</td>
  <td style="text-align: center;">0.11</td>
</tr>
<tr>
  <td style="text-align: center;">Earnings21-Test</td>
  <td style="text-align: center;"><strong>0.17</strong></td>
  <td style="text-align: center;">0.19</td>
  <td style="text-align: center;">0.65</td>
  <td style="text-align: center;">0.26</td>
  <td style="text-align: center;"><u>0.11</u></td>
</tr>
<tr>
  <td style="text-align: center;">Earnings22-Test</td>
  <td style="text-align: center;"><strong>0.20</strong></td>
  <td style="text-align: center;">0.24</td>
  <td style="text-align: center;">0.67</td>
  <td style="text-align: center;">0.36</td>
  <td style="text-align: center;"><u>0.14</u></td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-ASR-Part 1</td>
  <td style="text-align: center;"><u><strong>0.05</strong></u></td>
  <td style="text-align: center;">0.07</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">0.09</td>
  <td style="text-align: center;">0.07</td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-ASR-Part 2</td>
  <td style="text-align: center;"><u><strong>0.05</strong></u></td>
  <td style="text-align: center;">0.19</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">0.42</td>
  <td style="text-align: center;">0.33</td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-ASR-Part 3</td>
  <td style="text-align: center;"><u><strong>0.28</strong></u></td>
  <td style="text-align: center;">0.35</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">0.66</td>
  <td style="text-align: center;">0.30</td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-ASR-Part 4</td>
  <td style="text-align: center;"><u><strong>0.40</strong></u></td>
  <td style="text-align: center;">0.56</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">0.76</td>
  <td style="text-align: center;">0.48</td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-ASR-Part 5</td>
  <td style="text-align: center;"><u><strong>0.21</strong></u></td>
  <td style="text-align: center;">0.28</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">0.35</td>
  <td style="text-align: center;">0.23</td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-ASR-Part 6</td>
  <td style="text-align: center;"><u><strong>0.15</strong></u></td>
  <td style="text-align: center;">0.22</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">0.25</td>
  <td style="text-align: center;">0.18</td>
</tr>
<tr>
  <td style="text-align: center;" rowspan="6"><strong>Speech Translation</strong><br>BLEU (<span
  class="math inline"></span>)</td>
  <td style="text-align: center;">CoVoST 2 En <span
  class="math inline"></span> Id</td>
  <td style="text-align: center;"><strong><u>32.62</u></strong></td>
  <td style="text-align: center;">16.33</td>
  <td style="text-align: center;">13.84</td>
  <td style="text-align: center;">14.14</td>
  <td style="text-align: center;">27.62</td>
</tr>
<tr>
  <td style="text-align: center;">CoVoST 2 En <span
  class="math inline"></span> Zh</td>
  <td style="text-align: center;"><strong><u>37.98</u></strong></td>
  <td style="text-align: center;">25.77</td>
  <td style="text-align: center;">31.96</td>
  <td style="text-align: center;">33.89</td>
  <td style="text-align: center;">35.27</td>
</tr>
<tr>
  <td style="text-align: center;">CoVoST 2 En <span
  class="math inline"></span> Ta</td>
  <td style="text-align: center;"><strong><u>8.50</u></strong></td>
  <td style="text-align: center;">0.03</td>
  <td style="text-align: center;">0.00</td>
  <td style="text-align: center;">0.00</td>
  <td style="text-align: center;">8.46</td>
</tr>
<tr>
  <td style="text-align: center;">CoVoST 2 Id <span
  class="math inline"></span> En</td>
  <td style="text-align: center;"><strong>37.07</strong></td>
  <td style="text-align: center;">6.33</td>
  <td style="text-align: center;">5.93</td>
  <td style="text-align: center;">26.89</td>
  <td style="text-align: center;"><u>46.80</u></td>
</tr>
<tr>
  <td style="text-align: center;">CoVoST 2 Zh <span
  class="math inline"></span> En</td>
  <td style="text-align: center;">15.01</td>
  <td style="text-align: center;"><strong><u>16.47</u></strong></td>
  <td style="text-align: center;">2.37</td>
  <td style="text-align: center;">5.30</td>
  <td style="text-align: center;">15.21</td>
</tr>
<tr>
  <td style="text-align: center;">CoVoST 2 Ta <span
  class="math inline"></span> En</td>
  <td style="text-align: center;"><strong><u>3.97</u></strong></td>
  <td style="text-align: center;">0.04</td>
  <td style="text-align: center;">0.17</td>
  <td style="text-align: center;">0.36</td>
  <td style="text-align: center;">2.83</td>
</tr>
<tr>
  <td style="text-align: center;" rowspan="8"><strong>Spoken Question Answering</strong><br>LLM-as-a-Judge (<span
  class="math inline"></span>)</td>
  <td style="text-align: center;">SLUE-SQA-5</td>
  <td style="text-align: center;">82.94</td>
  <td style="text-align: center;">80.05</td>
  <td style="text-align: center;"><strong>83.92</strong></td>
  <td style="text-align: center;">83.48</td>
  <td style="text-align: center;"><u>88.58</u></td>
</tr>
<tr>
  <td style="text-align: center;">Spoken-SQuAD</td>
  <td style="text-align: center;">70.33</td>
  <td style="text-align: center;">64.86</td>
  <td style="text-align: center;"><strong>77.65</strong></td>
  <td style="text-align: center;">66.40</td>
  <td style="text-align: center;"><u>88.62</u></td>
</tr>
<tr>
  <td style="text-align: center;">CN-College-Listen-Test</td>
  <td style="text-align: center;"><strong>85.03</strong></td>
  <td style="text-align: center;">74.51</td>
  <td style="text-align: center;">65.43</td>
  <td style="text-align: center;">50.90</td>
  <td style="text-align: center;"><u>91.85</u></td>
</tr>
<tr>
  <td style="text-align: center;">Singapore-Public-Speech-SQA</td>
  <td style="text-align: center;"><strong>60.32</strong></td>
  <td style="text-align: center;">58.31</td>
  <td style="text-align: center;">58.55</td>
  <td style="text-align: center;">59.24</td>
  <td style="text-align: center;"><u>73.11</u></td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-SQA-Part 3</td>
  <td style="text-align: center;"><strong>51.4</strong></td>
  <td style="text-align: center;">42.0</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">40.60</td>
  <td style="text-align: center;"><u>53.20</u></td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-SQA-Part 4</td>
  <td style="text-align: center;"><strong>49.0</strong></td>
  <td style="text-align: center;">39.6</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">36.60</td>
  <td style="text-align: center;"><u>60.20</u></td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-SQA-Part 5</td>
  <td style="text-align: center;"><strong>58.2</strong></td>
  <td style="text-align: center;">51.6</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">44.60</td>
  <td style="text-align: center;"><u>67.20</u></td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-SQA-Part 6</td>
  <td style="text-align: center;"><strong>65.2</strong></td>
  <td style="text-align: center;">53.6</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">46.80</td>
  <td style="text-align: center;"><u>71.60</u></td>
</tr>
<tr>
  <td style="text-align: center;" rowspan="4"><strong>Spoken Dialogue Summarization</strong><br>LLM-as-a-Judge (<span
  class="math inline"></span>)</td>
  <td style="text-align: center;">MNSC-SDS-Part 3</td>
  <td style="text-align: center;"><u><strong>46.80</strong></u></td>
  <td style="text-align: center;">33.80</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">9.0</td>
  <td style="text-align: center;">45.40</td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-SDS-Part 4</td>
  <td style="text-align: center;"><u><strong>45.80</strong></u></td>
  <td style="text-align: center;">24.80</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">7.0</td>
  <td style="text-align: center;">44.00</td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-SDS-Part 5</td>
  <td style="text-align: center;"><strong>55.2</strong></td>
  <td style="text-align: center;">40.4</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">17.2</td>
  <td style="text-align: center;"><u>58.00</u></td>
</tr>
<tr>
  <td style="text-align: center;">MNSC-SDS-Part 6</td>
  <td style="text-align: center;"><strong>61.8</strong></td>
  <td style="text-align: center;">46.2</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">24.2</td>
  <td style="text-align: center;"><u>65.40</u></td>
</tr>
<tr>
  <td style="text-align: center;" rowspan="2"><strong>Speech Instruction</strong><br>LLM-as-a-Judge (<span
  class="math inline"></span>)</td>
  <td style="text-align: center;">OpenHermes-Audio</td>
  <td style="text-align: center;"><strong>71.4</strong></td>
  <td style="text-align: center;">44.8</td>
  <td style="text-align: center;">22.40</td>
  <td style="text-align: center;">15.80</td>
  <td style="text-align: center;"><u>72.20</u></td>
</tr>
<tr>
  <td style="text-align: center;">Alpaca-GPT4-Audio</td>
  <td style="text-align: center;"><strong>73.4</strong></td>
  <td style="text-align: center;">52.6</td>
  <td style="text-align: center;">21.60</td>
  <td style="text-align: center;">17.20</td>
  <td style="text-align: center;"><u>73.80</u></td>
</tr>
<tr>
  <td style="text-align: center;" rowspan="4"><strong>Paralinguistics</strong><br>LLM-as-a-Judge (<span
  class="math inline"></span>)</td>
  <td style="text-align: center;">VoxCeleb-Gender-Test</td>
  <td style="text-align: center;"><strong><u>99.53</u></strong></td>
  <td style="text-align: center;">99.12</td>
  <td style="text-align: center;">69.68</td>
  <td style="text-align: center;">88.81</td>
  <td style="text-align: center;">35.25</td>
</tr>
<tr>
  <td style="text-align: center;">VoxCeleb-Accent-Test</td>
  <td style="text-align: center;"><strong><u>46.35</u></strong></td>
  <td style="text-align: center;">29.18</td>
  <td style="text-align: center;">-</td>
  <td style="text-align: center;">34.22</td>
  <td style="text-align: center;">24.64</td>
</tr>
<tr>
  <td style="text-align: center;">MELD-Sentiment-Test</td>
  <td style="text-align: center;">42.26</td>
  <td style="text-align: center;"><strong>53.49</strong></td>
  <td style="text-align: center;">50.08</td>
  <td style="text-align: center;">42.07</td>
  <td style="text-align: center;"><u>56.67</u></td>
</tr>
<tr>
  <td style="text-align: center;">MELD-Emotion-Test</td>
  <td style="text-align: center;">30.15</td>
  <td style="text-align: center;">40.54</td>
  <td style="text-align: center;"><strong>41.07</strong></td>
  <td style="text-align: center;">30.73</td>
  <td style="text-align: center;"><u>47.39</u></td>
</tr>
</tbody>
</table>
</div>

## Uses

Here we provide a code snippet illustrating the process of loading both the processor and model, alongside detailed instructions on executing the MERaLiON-AudioLLM model for content generation.

> [!WARNING]
> **Out of Scope use**: This model is not intended for use in tool calling, math, and coding tasks.

### Inference

```python
from datasets import load_dataset
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor

repo_id = "MERaLiON/MERaLiON-AudioLLM-Whisper-SEA-LION"

processor = AutoProcessor.from_pretrained(
    repo_id, 
    trust_remote_code=True,
    )
model = AutoModelForSpeechSeq2Seq.from_pretrained(
    repo_id,
    use_safetensors=True,
    trust_remote_code=True,
)

prompt = "Given the following audio context: <SpeechHere>\n\nText instruction: {query}"
query = "Please transcribe this speech."
conversation = [
    {"role": "user", "content": prompt.format(query=query)}
]

chat_prompt = processor.tokenizer.apply_chat_template(
    conversation=conversation,
    tokenize=False,
    add_generation_prompt=True
)

libri_data = load_dataset("distil-whisper/librispeech_long", "clean", split="validation")
audio_array = libri_data[0]["audio"]["array"]
inputs = processor(text=chat_prompt, audios=audio_array)

outputs = model.generate(**inputs, max_new_tokens=128)
generated_ids = outputs[:, inputs['input_ids'].size(1):]
response = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
```

### Batch Inference

MERaLiON-AudioLLM also supports batch inference.

```python
from datasets import load_dataset
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor

repo_id = "MERaLiON/MERaLiON-AudioLLM-Whisper-SEA-LION"

processor = AutoProcessor.from_pretrained(
    repo_id, 
    trust_remote_code=True,
    )
model = AutoModelForSpeechSeq2Seq.from_pretrained(
    repo_id,
    use_safetensors=True,
    trust_remote_code=True,
)

prompt = "Given the following audio context: <SpeechHere>\n\nText instruction: {query}"
transcribe_query = "Please transcribe this speech."
translate_query = "Can you please translate this speech into written Chinese?"

conversation = [
    [{"role": "user", "content": prompt.format(query=transcribe_query)}],
    [{"role": "user", "content": prompt.format(query=translate_query)}],
]

chat_prompt = processor.tokenizer.apply_chat_template(
    conversation=conversation,
    tokenize=False,
    add_generation_prompt=True
)

libri_data = load_dataset("distil-whisper/librispeech_long", "clean", split="validation")
audio_array = [libri_data[0]["audio"]["array"]]*2
inputs = processor(text=chat_prompt, audios=audio_array)

outputs = model.generate(**inputs, max_new_tokens=128)
generated_ids = outputs[:, inputs['input_ids'].size(1):]
response = processor.batch_decode(generated_ids, skip_special_tokens=True)
```

### vLLM Inference

MERaLiON-AudioLLM requires vLLM version `0.6.4.post1`.

```
pip install vllm==0.6.4.post1
```

Here is an example of offline inference using our custom vLLM class. 

```python
import torch
from vllm import ModelRegistry, LLM, SamplingParams
from vllm.assets.audio import AudioAsset

# register custom MERaLiON-AudioLLM class
from .vllm_meralion import MERaLiONForConditionalGeneration
ModelRegistry.register_model("MERaLiONForConditionalGeneration", MERaLiONForConditionalGeneration)

def run_meralion(question: str):
    model_name = "MERaLiON/MERaLiON-AudioLLM-Whisper-SEA-LION"

    llm = LLM(model=model_name,
              tokenizer=model_name,
              tokenizer_mode="slow",
              max_model_len=4096,
              max_num_seqs=5,
              limit_mm_per_prompt={"audio": 1},
              trust_remote_code=True,
              dtype=torch.bfloat16
              )

    audio_in_prompt = "Given the following audio context: <SpeechHere>\n\n"

    prompt = ("<start_of_turn>user\n"
              f"{audio_in_prompt}Text instruction: {question}<end_of_turn>\n"
              "<start_of_turn>model\n")
    stop_token_ids = None
    return llm, prompt, stop_token_ids

audio_asset = AudioAsset("mary_had_lamb")
question= "Please trancribe this speech."

llm, prompt, stop_token_ids = run_meralion(question)

# We set temperature to 0.2 so that outputs can be different
# even when all prompts are identical when running batch inference.
sampling_params = SamplingParams(temperature=0.2,
                                    max_tokens=64,
                                    stop_token_ids=stop_token_ids)

mm_data = {"audio": [audio_asset.audio_and_sample_rate]}
inputs = {"prompt": prompt, "multi_modal_data": mm_data}

# batch inference
inputs = [inputs] * 2

outputs = llm.generate(inputs, sampling_params=sampling_params)

for o in outputs:
    generated_text = o.outputs[0].text
    print(generated_text)
```

## Disclaimer

The current MERaLiON-AudioLLM has not been specifically aligned for safety and may generate content that is inappropriate, offensive, or harmful. Developers and users are responsible for performing their own safety fine-tuning and implementing necessary security measures. The authors shall not be held liable for any claims, damages, or other liabilities arising from the use of the released models, weights, or code.

This research is supported by the National Research Foundation, Singapore, and Infocomm Media Development Authority, Singapore under its National Large Language Models Funding Initiative. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not reflect the views of National Research Foundation, Singapore and Infocomm Media Development Authority, Singapore.

## Technical Specifications 

### Training Data

MERaLiON-AudioLLM is trained on a diverse collection of publicly available datasets, alongside synthesised and augmented samples carefully curated by the team and native speakers, totaling 260,000 hours of audio.

### Compute and Infrastructure

MERaLiON-AudioLLM is trained on the **ASPIRE 2A+** Supercomputer Cluster, provided by **National Supercomputing Centre (NSCC)**, Singapore. ASPIRE 2A+ cluster provides multiple H100 nodes, with each compute node equipped with 8 Nvidia H100 GPUs, 2 TB of RAM, and 30 TB of locally attached NVMe storage. These nodes are interconnected via a rail-optimised, full fat-tree topology, utilising 400 Gb/s NDR InfiniBand cables. Additionally, the cluster incorporates a 2.5 PB SSD-based Lustre file system, linked to the H100 nodes through high-speed InfiniBand connections. 

With a global batch size of 640, we train the current release of MERaLiON-AudioLLM for around 200k steps, which took 2 days to complete using 16 nodes, 128 H100 GPUs.

## Citation

<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->

**BibTeX:**

[More Information Needed]

**APA:**

[More Information Needed]