File size: 6,799 Bytes
30951e5
 
 
 
 
 
 
 
 
 
 
 
385b92d
790450f
385b92d
ba814b7
385b92d
4fa06ea
385b92d
790450f
 
 
 
 
ba814b7
385b92d
790450f
385b92d
790450f
385b92d
ee86192
385b92d
ba814b7
385b92d
ba814b7
385b92d
de49693
9feb397
790450f
385b92d
ba814b7
385b92d
790450f
385b92d
 
 
790450f
385b92d
790450f
385b92d
790450f
385b92d
5392f0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
790450f
93a13eb
5392f0a
790450f
5392f0a
790450f
5392f0a
 
 
 
 
 
 
 
790450f
5392f0a
 
790450f
 
5392f0a
385b92d
790450f
385b92d
790450f
385b92d
790450f
 
 
385b92d
790450f
385b92d
790450f
 
 
 
 
 
 
 
 
385b92d
790450f
93a13eb
790450f
385b92d
790450f
 
 
 
385b92d
790450f
 
 
 
 
385b92d
790450f
 
 
385b92d
790450f
 
 
 
385b92d
790450f
385b92d
790450f
385b92d
 
790450f
385b92d
 
 
790450f
385b92d
790450f
385b92d
ba814b7
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
---
library_name: transformers
license: mit
metrics:
- bleu
- wer
pipeline_tag: audio-text-to-text
tags:
- LLM-as-a-Judge
- chat
- audio
---

# 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**, **8 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
- **Funded by:** Singapore NRF
- **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

For more details, please refer to our [report]().

## Model Description

MERaLiON-AudioLLM is designed to take in an **audio-text pair** as input and generates 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 address 8 tasks, including `Automatic Speech Recognition` (ASR), `Speech Translation` (ST), `Spoken Question Answering` (SQA), `Spoken Dialogue Summarization` (SDS), `Speech Instruction` (SI), `Paralinguistics` (PARA), `Audio Captioning` (AC), and `Audio Scene Question Answering` (ASQA). 

[More information about the 8 tasks and evaluation results]

## 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.

**NOTE** This model has not been trained to use a system prompt or to use tool calling.

### Inference

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

repo_id = "MERaLiON/AudioLLM"

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, time_duration_limit=30)

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/AudioLLM"

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, time_duration_limit=30)

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)
```

## Bias, Risks, and Limitations

The current MERaLiON-AudioLLM has not been aligned for safety. Developers and users should perform their own safety fine-tuning and related security measures. In no event shall the authors be held liable for any claim, damages, or other liability arising from the use of the released weights and codes.


## 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 the **National Supercomputing Centre (NSCC)**. 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]