<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rachel LW Tan on Medium]]></title>
        <description><![CDATA[Stories by Rachel LW Tan on Medium]]></description>
        <link>https://medium.com/@racheltlw?source=rss-5557871b7f2c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Co3S057qVhTJUeEu_5qVYQ.jpeg</url>
            <title>Stories by Rachel LW Tan on Medium</title>
            <link>https://medium.com/@racheltlw?source=rss-5557871b7f2c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 07:41:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@racheltlw/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[HTX x MERaLiON — towards a Spoken Language Model for Singapore and the Home Team]]></title>
            <link>https://medium.com/htx-dsai/htx-x-meralion-towards-a-spoken-language-model-for-singapore-and-the-home-team-94c55252f8c6?source=rss-5557871b7f2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/94c55252f8c6</guid>
            <category><![CDATA[singapore]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[speech]]></category>
            <category><![CDATA[audio-llm]]></category>
            <category><![CDATA[spoken-language-model]]></category>
            <dc:creator><![CDATA[Rachel LW Tan]]></dc:creator>
            <pubDate>Wed, 06 Aug 2025 02:53:23 GMT</pubDate>
            <atom:updated>2025-08-06T02:53:23.296Z</atom:updated>
            <content:encoded><![CDATA[<h3>HTX x MERaLiON — towards a Spoken Language Model for Singapore and the Home Team</h3><p>Not long ago, foundation models for language tasks, known as Large Language Models (LLMs) took the world by storm. LLMs changed the way we interacted and built AI systems because they enabled one model to do it all — perform multiple language-related tasks such as content generation, translation or summarisation. While LLMs have transformed the way we live and work, will foundation models one day truly change the way we interact with AI, and each other? Enter the universal speech processing system — and the goal to build a multi-modal foundational model that can handle a range of speech and language tasks.</p><p>In the realm of speech technology, there are a variety of tasks that enable us to make sense of and interact with our environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bOLHIhoehrG2fVXZNR3NGA.png" /><figcaption>My interpretation of the key areas that could be addressed by a Spoken Language Model.</figcaption></figure><p>Transcription only tells us what is being said, yet it is arguably equally if not more important to know <em>who</em> said what, <em>how </em>it was said and even <em>where</em> it was said. Speech tasks that deal with making sense of multiple speaker sources, or complex understanding of the content of speech help us to achieve this. Moreover, prosodic features like tone, rhythm, pauses, or non-verbal cues like laughter or whispering help provide emotional colour to speech. Background noise can provide further information about the location of the speaker, and hence complete the picture of the overall acoustic scene.</p><p>Can we achieve a universal speech processing system that can directly transcribe and translate the speech we hear, describe background noise, identify the number of people speaking and describe their perceived genders, ages and emotions? Can it then summarise this information, or facilitate question and answering directly from the speech, and then speak back to us in a natural-sounding manner? To add to the complexity of this task, can we do this in the wider Southeast Asian, local Singaporean and even Home Team specific context? We explored the intricacies of our in-domain linguistic environment in a <a href="https://medium.com/htx-dsai/finetuning-whisper-for-the-singaporean-home-team-context-a3ae1a6ae809">previous article here.</a> Introducing <a href="https://huggingface.co/MERaLiON">MERaLiON,</a> an AI model developed by A*STAR Institute for Infocomm Research (A*STAR I²R) that aims to address these issues. In order to understand how MERaLiON attempts to bridge this gap, let’s first dive into the world of foundation models for speech, otherwise known as Spoken Language Models (SLMs).</p><h4>What is a Spoken Language Model?</h4><p>Like any emerging technology, the definitions surrounding SLMs are still ever-evolving. I enjoyed reading t<a href="https://arxiv.org/abs/2504.08528">his comprehensive survey</a> on the topic, and will rely heavily on it for the explanations on SLMs below. The survey defines SLMs in three categories:</p><blockquote><strong>pure SLMs: </strong>models of the distribution of speech, p(speech), typically trained on unlabeled tokenized speech data only with a next-token prediction objective (similarly to the pre-training phase in text LLMs).</blockquote><blockquote><strong>speech+text SLMs:</strong> models of the joint distribution of speech and the<br>corresponding text p(text, speech), typically trained using paired (speech, text transcription) data.</blockquote><blockquote><strong>speech-aware text LMs:</strong> models that combine text LLMs with pre-trained speech encoders to retain the instruction-following (IF) characteristics of the text LLMs and reason about the input speech or audio recordings. They model a conditional distribution, p(text|speech, text), of desired output text in response to the input speech and text instruction.</blockquote><figure><img alt="Overview of SLM Architecture" src="https://cdn-images-1.medium.com/max/1024/1*2x86SODz8HuJRKRleRW9BA.png" /><figcaption>Overview of SLM Architecture. Image Source: On The Landscape of Spoken Language Models:<br>A Comprehensive Survey, Arora et al. 2025</figcaption></figure><p>The diagram above shows the components that are combined to create these different types of SLMs. Let’s break down the key details of these modules:</p><p><strong><em>1. Speech Encoder</em></strong></p><p>Unlike text which can be tokenised into smaller sub-word units, speech is a continuous signal that does not have clear “tokens”. As such, the task of the speech encoder is to transform a continuous speech waveform into meaningful representations that can be processed by the model. The process begins with a <strong>speech representation model</strong> that converts the raw speech signal into continuous features (numerical vectors that represent the audio). These features could take the form of traditional spectrogram features (e.g mel filter bank) or hidden representation from self-supervised learning-based encoders (e.g wav2vec 2.0, HuBERT), supervised pre-trained models (e.g Whisper), or neural audio codec models (e.g SoundStream, EnCodec).</p><figure><img alt="Components of a speech encoder pipeline" src="https://cdn-images-1.medium.com/max/1024/1*L3YuFfc612M4qXDVop1lsg.png" /><figcaption>Components of a speech encoder pipeline. Image Source: On The Landscape of Spoken Language Models:<br>A Comprehensive Survey, Arora et al. 2025</figcaption></figure><p>Continuous speech features can be used directly by the model, however many SLMs adopt <strong>quantization</strong>, that transforms these continuous features into discrete units (like tokens). This is often achieved through methods like k-means clustering or <a href="https://huggingface.co/blog/ariG23498/understand-vq">VQ-VAE</a>. There are usually two types of discrete units — <strong>phonetic tokens </strong>(capturing linguistic information and correlate strongly to phonetic units) and <strong>audio codec tokens </strong>(capturing acoustic characteristics like pitch, loudness, timbre). Quantized speech feature sequences are usually long due to the high sampling rate of speech, hence <strong>temporal compression </strong>is applied, such as <strong>deduplication</strong> (merging consecutive identical tokens) or <strong>byte pair encoding</strong> (merging the most frequent pairs of characters or bytes).</p><p><strong><em>2. Modality Adapter</em></strong></p><p>Oftentimes for SLMs, the speech encoder and sequence model (e.g pretrained LLM) are “mixed and matched”, or developed separately and then combined. As such, <strong>alignment</strong> of the output of the speech encoder with expected input of the (usually text) sequence model is crucial. The modality adapter performs this key function. If the output of the speech encoder is continuous, the modality adapter applies temporal adjustments to shorten the speech sequence to achieve a consistent sequence length. If the speech encoder outputs discrete units, the modality adapter may convert the speech representation into the embedding space of the sequence model. Modality adapters range from simple linear transformations, convolution neural-networks (CNNs) with strides, to using a combination of CTC compression or Q-Former methods.</p><p><strong><em>3. Sequence Model</em></strong></p><p>The sequence model generates output in an auto-regressive manner. In pure SLMs, the output is a speech representation (a continuous vector or discrete unit). For speech+text LMs, the sequence model produces hybrid or combined speech and text representations. In speech-aware text LMs the sequence model generates a text token. Unlike LLMs which deal only with text tokens, the sequence model of an SLM must handle various audio tokens, which differ in terms of granularity. This is due to the multi-dimensional nature of speech, such that audio tokens capture different levels of detail. <strong>Phonetic tokens</strong> (discussed in the above Speech Encoder section) are examples of <strong>coarse tokens</strong>, while audio codec tokens are <strong>fine-grained tokens</strong>. To handle the generation of multiple speech tokens, SLMs may adopt <strong>hierarchical token generation</strong>, as illustrated below. Do give the survey paper a read if you would like a more in-depth understanding!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cIxVat3gk9Jcc_zjSUkNHw.png" /><figcaption>Hierarchical generation strategies. Image Source: On The Landscape of Spoken Language Models:<br>A Comprehensive Survey, Arora et al. 2025</figcaption></figure><p>Another method of sequence generation in SLMs is <strong>hybrid generation of text and speech</strong>. In this approach, the SLM uses knowledge from a pretrained text LM (trained on vast amounts of text data as compared to less available speech data). The model first produces text tokens (similar to an LLM), and follows this by generating the corresponding speech tokens, hence improving accuracy and quality of the generated speech. Alignment of the output sequences is addressed by adding <strong>fixed padding </strong>after the text token sequence, adding fixed or <strong>dynamic padding</strong> between text tokens or <strong>interleaving speech and text tokens</strong> in a single sequence.</p><p>The sequence model also functions as the <strong>text decoder</strong> for models that only output text, by ingesting aligned speech and text sequences and generating a text response.</p><p><strong><em>4. Speech Decoder</em></strong></p><p>Pure SLMs and speech+text SLMs produce speech as an output. Hence the speech decoder converts output speech representations (continuous, phonetic tokens or acoustic codec tokens) into the raw audio waveform. The three main types of decoders include the Vocoder (for continuous features) that are also used for traditional text-to-speech (TTS) systems, Unit-based Vocoder (for phonetic tokens), Codec Decoder (for audio codec tokens).</p><h4>MERaLiON: a speech-aware text LM for the Singaporean context</h4><p>A*STAR developed the <strong>M</strong>ultimodal <strong>E</strong>mpathetic <strong>R</strong>easoning <strong>a</strong>nd <strong>L</strong>earning <strong>i</strong>n <strong>O</strong>ne <strong>N</strong>etwork or MERaLiON, <a href="https://huggingface.co/MERaLiON/MERaLiON-AudioLLM-Whisper-SEA-LION">and released their first Audio-LLM </a>developed for Singapore’s multilingual environment in 2024. This was in collaboration with AI Singapore and supported by the Infocomm Media Development Authority (IMDA). At the ATxSummit this year, the upgraded <a href="https://huggingface.co/MERaLiON/MERaLiON-2-10B">MERaLiON version-2 was announced</a>, with three model variants. The flagship MERaLioN-2-10B shows comparable results to other state-of-the-art SLMs in a variety of tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*lNs3QhCEM99A3qGrzt2U_g.png" /><figcaption>Evaluation Scores for Speech Tasks. Image Source: <a href="https://huggingface.co/MERaLiON/MERaLiON-2-10B">https://huggingface.co/MERaLiON/MERaLiON-2-10B</a></figcaption></figure><p>From our understanding of SLMs above, MERaLiON falls into the category of speech-aware text LMs. The <a href="https://arxiv.org/pdf/2412.09818">MERaLiON technical report</a> illustrates the model architecture. MERaLiON-2–10B comprises of:</p><ul><li><strong><em>Speech Encoder:</em> </strong>Whisper-Large-V3 Speech Encoder</li><li><strong><em>Modality Adapter: </em></strong>MLP-100 (similar to the first MERaLiON-AudioLLM)</li><li><strong><em>Sequence Model or Text Decoder:</em></strong> Gemma-2–9b</li></ul><p>The modality adapter is a multi-layer perceptron (MLP) adaptor module with 2 hidden layers to transform the encoder outputs into 100 speech or audio token embeddings that can be used by the Sequence Model.</p><p>MERaLiON-2 was finetuned on 120,000 hours of speech and audio data across 6 diverse tasks — Automatic Speech Recognition (ASR), Spoken Question Answering (SQA), Spoken Dialogue Summarization (SDS), Audio Captioning (AC), Audio-Scene Question Answering (ASQA) and Paralinguistic Question Answering (PQA). Furthermore, besides support for English, Mandarin Chinese, and Singlish, it supports Malay, Tamil and other Southeast Asian languages such as Indonesian, Thai and Vietnamese.</p><p>We gave MERaLiON-2–10B a try on some sample clips — you can listen to the original clip below and check out the model’s response!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fw.soundcloud.com%2Fplayer%2F%3Furl%3Dhttps%253A%252F%252Fapi.soundcloud.com%252Ftracks%252F2108010195%26show_artwork%3Dtrue&amp;display_name=SoundCloud&amp;url=https%3A%2F%2Fsoundcloud.com%2Frachel-tan-227914696%2Ffootball-codeswitch-example%3Fsi%3D0506e688be214881b2afcddb85e34e32%26utm_source%3Dclipboard%26utm_medium%3Dtext%26utm_campaign%3Dsocial_sharing&amp;image=https%3A%2F%2Fsoundcloud.com%2Fimages%2Ffb_placeholder.png&amp;type=text%2Fhtml&amp;schema=soundcloud" width="800" height="166" frameborder="0" scrolling="no"><a href="https://medium.com/media/c801906d24c726ab13b8591cc5e1c15c/href">https://medium.com/media/c801906d24c726ab13b8591cc5e1c15c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*5cUqYTvejBc5OmEO6HFK8g.png" /><figcaption>Generated results from MERaLiON-2–10B, with prompt instructions in <strong>bold</strong></figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fw.soundcloud.com%2Fplayer%2F%3Furl%3Dhttps%253A%252F%252Fapi.soundcloud.com%252Ftracks%252F2108020101%26show_artwork%3Dtrue&amp;display_name=SoundCloud&amp;url=https%3A%2F%2Fsoundcloud.com%2Frachel-tan-227914696%2Fspca-clip%3Fsi%3Dc8bde8ac09974eb29627ea3441a7da53%26utm_source%3Dclipboard%26utm_medium%3Dtext%26utm_campaign%3Dsocial_sharing&amp;image=https%3A%2F%2Fsoundcloud.com%2Fimages%2Ffb_placeholder.png&amp;type=text%2Fhtml&amp;schema=soundcloud" width="800" height="166" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e463d693e3df64cfc339a058238ed8e/href">https://medium.com/media/6e463d693e3df64cfc339a058238ed8e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*xWNmpJI4kyZf9RnqQqX-CA.png" /><figcaption>Generated results from MERaLiON-2–10B, with prompt instructions in <strong>bold</strong></figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fw.soundcloud.com%2Fplayer%2F%3Furl%3Dhttps%253A%252F%252Fapi.soundcloud.com%252Ftracks%252F2108024400%26show_artwork%3Dtrue&amp;display_name=SoundCloud&amp;url=https%3A%2F%2Fsoundcloud.com%2Frachel-tan-227914696%2Fthe-hop-pod-clip%3Fsi%3Df6df7869efd8439c990331c8a8fc936d%26utm_source%3Dclipboard%26utm_medium%3Dtext%26utm_campaign%3Dsocial_sharing&amp;image=https%3A%2F%2Fsoundcloud.com%2Fimages%2Ffb_placeholder.png&amp;type=text%2Fhtml&amp;schema=soundcloud" width="800" height="166" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebdae347f2bffa48682f469945a72866/href">https://medium.com/media/ebdae347f2bffa48682f469945a72866/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*1uYCbd9hFt5L-b_eDCPBZA.png" /><figcaption>Generated results from MERaLiON-2–10B, with prompt instructions in <strong>bold</strong></figcaption></figure><p>We can see that the MERaLiON model is able to perform localised speech tasks! This is impressive, although the model does make some mistakes on more challenging clips (e.g there are actually four speakers, two male and two female, in the clip from The Hop Pod). For the <a href="https://www.htx.gov.sg/">Home Team Science and Technology Agency</a>, this unlocks the potential for a variety of Speech AI tasks. Oftentimes, Home Team officers must deal with complex speech tasks. These including code-switching and multilingual scenarios, synthetic speech detection, background noise or speaker emotions that can benefit from progress in speech technology. SLMs like MERaLiON will be a step forward in enhance the safety and security of Singapore.</p><h4>The MERaLiON Consortium</h4><p>The MERaLiON Consortium <a href="https://www.straitstimes.com/paid-press-releases/singapores-meralion-southeast-asias-empathetic-large-language-model-breaks-new-ground-with-multilingual-processing-and-emotional-intelligence-20250529">brings together local and global industry and research institutions to focus on developing practical AI applications</a>. As a consortium member, HTX will be working closely with A*STAR I²R to develop AI applications for homeland security use and in-domain context. We are excited for what’s to come :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Is5TUsFroNMLcymWedflJg.jpeg" /><figcaption>The HTX and A*STAR team at the launch of the MERaLiON Consortium</figcaption></figure><p><em>Many thanks to our partners at A*STAR I²R for the invitation to join the MERaLiON Consortium, and Angela and Ai Ti for collaborating with us. I’m grateful to the HTX xData team — Natasha Koh, Aloysius Tan, Clarence Teo and Calista Choy for their invaluable contributions and ACE Chee Wee and Director Kian Boon for their strong support.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94c55252f8c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/htx-dsai/htx-x-meralion-towards-a-spoken-language-model-for-singapore-and-the-home-team-94c55252f8c6">HTX x MERaLiON — towards a Spoken Language Model for Singapore and the Home Team</a> was originally published in <a href="https://medium.com/htx-dsai">HTX DSAI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finetuning Whisper for the Singaporean Home Team Context]]></title>
            <link>https://medium.com/htx-dsai/finetuning-whisper-for-the-singaporean-home-team-context-a3ae1a6ae809?source=rss-5557871b7f2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3ae1a6ae809</guid>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[whisper]]></category>
            <category><![CDATA[singapore]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <dc:creator><![CDATA[Rachel LW Tan]]></dc:creator>
            <pubDate>Fri, 13 Sep 2024 03:41:23 GMT</pubDate>
            <atom:updated>2024-09-30T17:58:00.144Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Introduction to Singlish and ASR</strong></h4><p>Automatic Speech Recognition (ASR) has been a key research capability for the <a href="https://www.htx.gov.sg/">Home Team Science and Technology Agency</a> (HTX)’s Enterprise Data (xData) Group, given its numerous applications in the Home Team. However, there is no one-size-fits-all solution for transcribing speech accurately for the local Singaporean context, and more specifically the MHA context.</p><p>From a linguistic perspective, colloquial Singaporean English or Singlish, is an informal way of conversation which often includes non-grammatical phrases. For example:</p><ul><li>The use of <strong>ellipsis or zero copula</strong> — ‘You eat already?’ (instead of ‘Have you eaten already?), ‘She my friend’ (instead of ‘She is my friend’)</li><li><strong>Loan-words</strong> from other languages — <em>makan</em> (Malay), <em>kiasu</em> (hokkien) etc.</li><li><strong>Particles</strong> for emphasis and nuance — ‘lah’, ‘eh’, ‘lor’</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/0*fG96Hr8kpec63Cgu" /><figcaption>Changing one particle in a sentence can change it’s whole meaning. Source: <a href="https://www.straitstimes.com/singapore/whats-the-difference-between-lah-and-lor-poet-gwee-li-suis-take-on-nuances-of-singlish">The Straits Times</a></figcaption></figure><p>Singaporeans who converse in colloquial Singapore English also natively <strong>code-switch</strong>, mixing languages at a sentence, phrase or even word level, which is a significant challenge for multilingual ASR. On top of this, the operational context of the Home Team often includes specific jargon and keywords as well as unique acoustic environments (background noises etc.) that require a custom solution in order for ASR to perform well. As such, this provide us with the opportunity to finetune our own ASR models!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/0*7r2OdG1hquS1sjew" /><figcaption>Codeswitching involves switching between languages, even at a phrase or word level. Source: <a href="https://thesmartlocal.com/read/singaporean-culture-quirks/">The Smart Local</a></figcaption></figure><p>HTX’s ASR journey started before 2020, where we used <a href="https://medium.com/r?url=https%3A%2F%2Fjonathan-hui.medium.com%2Fspeech-recognition-kaldi-35fec0320496">traditional ASR pipelines such as KALDI</a> to finetune and adapt language, acoustic and pronunciations models with Home Team data. Since then, ASR systems in the Machine Learning space have progressed significantly, and <a href="https://medium.com/@ManishChablani/asr-ml-systems-overview-and-latest-model-architectures-transducers-tdt-b547bf6db366">this post provides a good overview</a> of the key developments (from traditional pipelines to Whisper V3 and beyond!). On 21 September 2022, OpenAI released Whisper, a multilingual and multitask model trained on 680,000 hours of audio, followed shortly by Whisper V2 on 8 December 2022 and V3 on 6 November 2023.</p><p>The benchmarking and finetuning I will be focusing on this article is based on a (now completed) project that was developed using the first two versions of Whisper. However, xData has exciting upcoming work with V3 that we will hopefully share more about soon.</p><h4><strong>The Data: IMDA NSC Part 3</strong></h4><p>Collecting and preparing data for ASR oftentimes requires a significant amount of effort in order to record or gather speech recordings, annotate the ground truth transcriptions and prepare the corpus for machine learning. This is especially the case for low-resource languages like Singlish, where few large-scale datasets are available. xData uses a combination of open-source and commercial datasets to finetune our speech models, and also collects and prepares in-house datasets that are specific to Home Team operations.</p><p>One useful dataset is the <a href="https://www.imda.gov.sg/how-we-can-help/national-speech-corpus"><strong>National Speech Corpus</strong></a>, the first large-scale Singapore English Corpus made available by IMDA Singapore. The corpus consists of 6 parts of recordings of local English speakers:</p><blockquote><strong>Part 1</strong> — Prompted recordings of phonetically-balanced scripts</blockquote><blockquote><strong>Part 2</strong> — Prompted recordings of sentences randomly generated from words based on people, food, location, brands</blockquote><blockquote><strong>Part 3</strong> — Conversational data on topics covering daily life and playing games provided</blockquote><blockquote><strong>Part 4</strong> — Conversational code-switched data (from Singaporean English to various native languages)</blockquote><blockquote><strong>Part 5</strong> — Conversational data on debate, finance topics, with positive and negative emotion</blockquote><blockquote><strong>Part 6</strong> — Conversational data in 3 styles (holiday/restaurant/hotel, bank/telephone/insurance, HDB/MOE/MSF).</blockquote><p>Our team initially experimented finetuning whisper-small on subsets of NSC Part 1, 2 and 3, in combination with our commercially obtained and internal operational datasets. The NSC Part 3 was one of the open-source datasets we determined to best suited for our use case due to its conversational nature, whereas Part 1 and 2 were focused on phrase level utterances. In this article, we will focus on the NSC Part 3 as our main example to finetune Whisper.</p><h4><strong>Preparing the Data: </strong>🤗 <strong>Audio Datasets, Streaming and Preprocessing</strong></h4><p>NSC Part 3 contains an estimated 1,000 hours of conversational speech, which is a huge amount to load both storage-wise and computationally. Luckily, Hugging Face has <a href="https://huggingface.co/blog/audio-datasets">ample support for Audio Datasets</a> including the use of <a href="https://huggingface.co/docs/datasets/en/stream">streaming mode</a>, which loads data progressively while iterating over the dataset. This means that we do not need to load the whole dataset into memory, but rather stream only the audio samples that we need throughout the training process. Preparing our own audio dataset also gives us full control over how our dataset is split or configured, which is useful because the dataset is tagged based on various speaker genders and microphones. We adapted the <a href="https://github.com/huggingface/datasets/blob/main/templates/new_dataset_script.py">provided template</a> and <a href="https://huggingface.co/docs/datasets/en/audio_dataset#loading-script">wrote a custom loading script</a> for NSC Part3.</p><p>Loading a dataset in streaming mode creates IterableDataset objects that we can then use for finetuning. A quick example below:</p><pre>def prepare_dataset(batch):<br>    # load the audio <br>    audio = batch[&quot;audio&quot;]<br>    # perform feature extraction by computing log-Mel input features from input audio<br>    batch[&quot;input_features&quot;] = feature_extractor(audio[&quot;array&quot;], sampling_rate=audio[&quot;sampling_rate&quot;]).input_features[0]<br>    # tokenize the transcripts (convert text into numerical representations that the model can use) <br>    batch[&quot;labels&quot;] = tokenizer(batch[&quot;transcript&quot;]).input_ids<br>    return batch<br><br># use the custom loading script to load the data as an IterableDataset with streaming<br>imda3_train = load_dataset(&quot;local_loadingScript_imda_part3.py&quot;,&quot;all&quot;, split=&#39;train&#39;, streaming=True)<br>imda3_val = load_dataset(&quot;local_loadingScript_imda_part3.py&quot;,&quot;all&quot;, split=&#39;validation&#39;, streaming=True)<br>    <br>imda_dataset = IterableDatasetDict()<br>imda_dataset[&quot;train&quot;] = imda3_train<br>imda_dataset[&quot;val&quot;] = imda3_val<br><br>imda_processed = imda_dataset.map(prepare_dataset, remove_columns=next(iter(imda_dataset.values())).column_names)</pre><p>The NSC Part 3 recordings are split into two environments, each with two different microphones used for recording. In the first environment, where speakers were in the same room, we selected the recordings using the close-talk mic as this isolated the main speaker’s voice (without picking up background noise or the secondary speaker). For the second environment with speakers in different rooms, we chose to use the standing microphone recordings, as opposed to recordings via telephone.</p><p>The original NSC Part 3 dataset consists of WAV files and corresponding TextGrid transcript files. Each audio clip is approximately 1 hour long, so we preprocessed the data as follows:</p><p><strong>Firstly, by cleaning the transcripts via removing annotations for</strong>:</p><ul><li><strong>Paralinguistic phenomena</strong> (e.g., breathing, coughing, laughing) — this is represented in the text by annotations such as (ppo), (ppb), (ppl) etc.</li><li><strong>Fillers or unknown words</strong> &lt;FIL/&gt;, unclear words &lt;UNK&gt;, short pauses &lt;S&gt; etc. according to the NSC transcription guidelines</li><li><strong>Unique Singlish particles</strong>, we removed the annotations and kept the particles as part of the text e.g., ‘ok [lah] we go there’ → ‘ok lah we go there’</li></ul><p><strong>Secondly, normalising the transcript text</strong>. To avoid inconsistent casings and punctuation in the output of the eventual finetuned model, we removed punctuations and converted the text to lowercase. If required, appropriate sentence casing and punctuation can be reengineered during post-processing with python libraries such as <a href="https://pypi.org/project/punctuator/">Punctuator</a> or using a model like <a href="https://huggingface.co/felflare/bert-restore-punctuation">bert-restore-punctuation</a>. (Automatic punctuation restoration is actually an interesting challenge for the NLP community! Read more about it <a href="https://praneethbedapudi.medium.com/deepcorrection2-automatic-punctuation-restoration-ac4a837d92d9">here</a>).</p><p><strong>Lastly, we created 30s audio segments with their corresponding transcripts for training.</strong> Using the time segments from the TextGrid files we splice out the corresponding segments from the WAV files. Shorter consecutive segments were also combined, up to a length of 30s. This corresponds to Whisper’s intrinsic design where its feature extractor ensures all segments have a length of 30s before training.</p><h4>Baseline Evaluation</h4><p>We split approximately 20 hours of data to use for validation and hold out another 20 hours as a test set in order to evaluate the performance of the model during and after training. We also conduct a baseline evaluation of our test set using the Whisper Medium model (without finetuning).</p><p>Word Error Rate (WER) is a common evaluation metric for ASR that is a measure of the errors in a transcript, considering the number of words in the groundtruth reference:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g1eufXGCht6WV5X3.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/0*dHGuhrc94TcNSODz.png" /></figure><p>The baseline performance of Whisper Medium on our holdout test set is:</p><blockquote>whisper-medium (baseline): <strong>28.2%</strong> WER</blockquote><h4>Finetuning Whisper Medium</h4><p>It’s been exciting to see the growing number of resources and guides on finetuning Whisper over the past two year or so, as more and more developers give it a try. Back in mid 2023, the xData team relied on the Hugging Face blog on how to <a href="https://huggingface.co/blog/fine-tune-whisper">Fine-Tune Whisper for Multilingual ASR with 🤗 Transformers</a> with code adapted from this <a href="https://github.com/huggingface/community-events/blob/main/whisper-fine-tuning-event/fine-tune-whisper-non-streaming.ipynb">github notebook</a>. Some other key resources we used were:</p><ul><li>The <a href="https://github.com/huggingface/community-events/tree/main/whisper-fine-tuning-event#deepspeed">Github Repo of the Whisper Fine-Tuning Event</a> and medium post on <a href="https://medium.com/@bofenghuang7/what-i-learned-from-whisper-fine-tuning-event-2a68dab1862">What I Learned from Whisper Fine-Tuning Event</a></li><li>The <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/speech-recognition#whisper-model">Transformers Speech Recognition Github Repo</a> and t<a href="https://github.com/openai/whisper/discussions">he Whisper Github discussions</a></li><li>Examples on <a href="https://blog.ml6.eu/fine-tuning-whisper-for-dutch-language-the-crucial-role-of-size-dd5a7012d45f">Finetuning Whisper for Dutch Language</a> or <a href="https://colab.research.google.com/drive/1P4ClLkPmfsaKn2tBbRp0nVjGMRKR-EWz?usp=sharing">Japanese Kana</a></li></ul><p>The 🤗 guide provides a step-by-step code walk-through and explanation of how to finetune Whisper. Recently, I also enjoyed <a href="https://www.jensenlwt.com/blog/singlish-whisper-finetuning-asr-for-singapore-unique-english">this blog that does a similar work finetuning a “Singlish-Whisper”</a> (using whisper-small with IMDA NSC Part 2), that will give you a good idea of the full process.</p><p>As we convert our 30s audio chunks and corresponding transcripts into audio features and tokenized labels, we need to ensure that they are of the same lengths. Hence we can create a custom data collator that pads audio features and tokenized labels to the appropriate max length. The code below is taken from the 🤗 guide which demonstrates how to define the data collator. The function processes inputs and labels separately since they have to be of different lengths and require different padding methods. Also take note that the padding tokens are then replaced with -100, so that they are subsequently ignored in the loss calculations during finetuning.</p><pre>@dataclass<br>class DataCollatorSpeechSeq2SeqWithPadding:<br>    processor: Any<br>    def __call__(self, features: List[Dict[str, Union[List[int], torch.Tensor]]]) -&gt; Dict[str, torch.Tensor]:<br>        # first treat the audio inputs by returning torch tensors<br>        input_features = [{&quot;input_features&quot;: feature[&quot;input_features&quot;]} for feature in features]<br>        batch = self.processor.feature_extractor.pad(input_features, return_tensors=&quot;pt&quot;)<br>        # get the tokenized label sequences<br>        label_features = [{&quot;input_ids&quot;: feature[&quot;labels&quot;]} for feature in features]<br>        # pad the labels to max length<br>        labels_batch = self.processor.tokenizer.pad(label_features, return_tensors=&quot;pt&quot;)<br>        # replace padding with -100 to ignore loss correctly<br>        labels = labels_batch[&quot;input_ids&quot;].masked_fill(labels_batch.attention_mask.ne(1), -100)<br>        # remove begining-of-sequence (bos) tokens to remove redundancy as they are added later when needed<br>        if (labels[:, 0] == self.processor.tokenizer.bos_token_id).all().cpu().item():<br>            labels = labels[:, 1:]<br>        batch[&quot;labels&quot;] = labels<br>        return batch</pre><p>Furthermore, in order to monitor the model’s performance more effectively, we can also define a custom WER metric to use during evaluation. This provides a more direct comparison of the model’s performance as compared to our baseline, as opposed to only depending on the default loss metric.</p><pre>import evaluate <br>metric = evaluate.load(&quot;wer&quot;)<br><br>def compute_metrics(pred):<br>    pred_ids = pred.predictions<br>    label_ids = pred.label_ids<br>    # replace -100 with the original pad_token_id (since we had replaced padding in the DataCollator above) <br>    label_ids[label_ids == -100] = tokenizer.pad_token_id<br>    # convert the predictions and labels back into human readable text, ignoring special tokens <br>    pred_str = tokenizer.batch_decode(pred_ids, skip_special_tokens=True)<br>    label_str = tokenizer.batch_decode(label_ids, skip_special_tokens=True)<br>    wer = 100 * metric.compute(predictions=pred_str, references=label_str)<br>    return {&quot;wer&quot;: wer}</pre><p>We specified our training arguments as detailed below. The learning rate we selected is 40x smaller than what was used for pre-training, <a href="https://github.com/vasistalodagala/whisper-finetune?tab=readme-ov-file#hyperparameter-tuning">as suggested by Jong Wook Kim</a>, one of the authors of the Whisper paper. The following is what we found to work for our finetuning using NSC Part 3, but you will need to experiment with which specific parameters work for your own finetuning use case!</p><pre># Specify the base version of Whisper to fine-tune<br>model_name_base = &quot;openai/whisper-medium&quot;<br>model = WhisperForConditionalGeneration.from_pretrained(model_name_base)<br>model.config.forced_decoder_ids = None<br>model.config.suppress_tokens = []<br>model.config.use_cache = False<br><br># Use the custom data collator we defined above!<br>processor = WhisperProcessor.from_pretrained(model_name_base, language=&quot;English&quot;, task=&quot;transcribe&quot;)<br>data_collator = DataCollatorSpeechSeq2SeqWithPadding(processor=processor) <br><br># Define the training arguments<br>job_name = &#39;htx-medium-nscpart3&#39;<br>training_args = Seq2SeqTrainingArguments(<br>    output_dir=f&quot;/datadrive/{job_name}&quot;,<br>    per_device_train_batch_size=64,<br>    per_device_eval_batch_size=32,<br>    gradient_accumulation_steps=1,<br>    learning_rate=6.25e-6, # 40x smaller that what was used for pretraining<br>    warmup_steps=300,<br>    max_steps=3000,<br>    gradient_checkpointing=True,<br>    fp16=True,<br>    eval_strategy=&quot;steps&quot;,<br>    predict_with_generate=True,<br>    generation_max_length=225,<br>    save_steps=50,<br>    eval_steps=50, #smaller than usual, for initial experimentation<br>    logging_steps=25,<br>    load_best_model_at_end=True,<br>    metric_for_best_model=&quot;wer&quot;, # from our custom compute_metrics function above!<br>    greater_is_better=False,<br>)<br><br># Create the Seq2SeqTrainer<br>trainer = Seq2SeqTrainer(<br>    args=training_args,<br>    model=model,<br>    train_dataset=imda_processed[&quot;train&quot;],<br>    eval_dataset=imda_processed[&quot;val&quot;],<br>    data_collator=data_collator, <br>    compute_metrics=compute_metrics, # we defined the custom compute_metrics function above!<br>    tokenizer=processor.feature_extractor,<br>)</pre><p>We saved a model checkpoint and evaluated the model every 50 steps, which provided us with a fine-grained view of our training. However, this results in a longer overall finetuning duration, since the model is being evaluated constantly. We can consider increasing the save and evaluation steps for future training iterations. We finetune using an Azure Virtual Machine Standard_NC96ads_A100_v4, using 4 NVIDIA A100 GPUs, each with 80GB of memory.</p><h4>Evaluating our Finetuned Model</h4><p>We initially configure our training settings to finetune the model on 3000 steps, while we checkpoint and evaluate the model every 50 steps. However, based on the evaluation and loss curves we can early stop the training after 1000 steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*KACg79LazbxaPdUA72jeoQ.png" /></figure><p>We see a sharp drop in both evaluation and training loss during the initial phase of training (the first 200 steps), followed by a gradual and more stable decline from around 200–400 steps. Noticeably, the train loss begins to fluctuate from step 500, while the evaluation loss essentially plateaus, suggesting that the model may have begun to overfit from this point onwards. We can gain further insight by looking at the evaluation of WER during training:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*8HVg2L3rkFW9sR8yLyAkJQ.png" /></figure><p>Similarly, the WER drop sharply from 26<em>.</em>4 to 14.1 during the first 250 step and plateaus at around 13.8 at steps 400 to 500. WER continues to fluctuate after this point, however based on the loss and WER curves, we eventually select the model checkpoint at step 400 for our final evaluation.</p><p>Finally, we evaluate the model on our test set and compare it to the result of our baseline model.</p><blockquote>whisper-medium (baseline): <strong>28.2</strong>% WER</blockquote><blockquote>whisper-medium (finetuned NSC Part 3): <strong>14.5</strong>% WER</blockquote><p>We also evaluated the model on a range of HTX internal datasets, which provide us with a better understanding of how the model would perform on out of distribution Singlish data, specifically data related to Home Team operations. The data contains different acoustic environments, some more challenging than others, however we saw improvements in WER across the board using our finetuned model.</p><h4><strong>Qualitative Assessment and Final Reflections</strong></h4><p>We can compare the output of our fine-tuned Whisper model on some sample sentences:</p><pre>Groundtruth:  bojio the best place to chillax in singapore is i think for mine is my hall room eh got air con got bed i can just i can just you know nua there it is a place<br>Baseline:     the best place to chillax in singapore is home i think for me it is my hall room got aircon got bed i can just you know noah there it is a place  (WER 29.7%)<br>Finetuned:    bojio the best place to chillax in singapore is i think for mine is my hall room got aircon got bed i can just you know noah there it is a place  (WER 18.9%)<br><br>Groundtruth:  i think we are already a hub that bao ka liao already ya so i do not know if ya at i think singapore is really bao ka liao<br>Baseline:     i think we are already a hub that paka liao already yeah so i do not know if yeah i think singapore is already paka liao  (WER 27.6%) <br>Finetuned:    i think we are already a hub that baka liao already yeah so i do not know if yeah i think singapore is already baka liao  (WER 27.6%)<br><br>Groundtruth:  you want to go geylang geylang serai you know the pasar geylang the upstair<br>Baseline:     you want to go gelang gelang serai you know the pasar gelang the upstairs  (WER 28.6%)<br>Finetuned:    you want to go geylang geylang serai you know the pasar geylang the upstairs  (WER 7.1%) <br><br>Groundtruth:  kana what salted olives metaphor for miserly anyway poor person ya is giam siap lah basically that is what we know but i do not know what is this so what do you always stinge what do you always sting just splurge on<br>Baseline:     ghana what salted olives metaphor for miserly anyway poor person ya is kam siap lah basically that is what we know but i do not know what is this so what do you always stinge what do you always stinge or splurge on  (WER 9.3%)<br>Finetuned:    kana what salted olives metaphor for miserly anyway poor person ya is kiam siap lah basically that is what we know but i do not know what is this so what do you always stinge what do you always stinge or splurge on  (WER 7.0%)</pre><p>As we can see from comparing the transcribed outputs, our finetuned model does perform better on Singlish speech, although it still automatically removes hesitations or fillers, and corrects grammar ‘the upstair’ corrected to ‘the upstairs’). This is a result of the text normalization and pretraining of Whisper that effectively filters out filler words and gives it a good understanding of typical English grammar. Furthermore, our finetuned model also struggles with:</p><ul><li>Some local words and phrases, especially colloquial hokkien phrases (‘<em>nua’</em>, ‘<em>bao ka liao</em>’)</li><li>Spelling differences (‘<em>giam siap</em>’ vs ‘<em>kiam siap</em>’, ‘<em>ya</em>’ vs ‘<em>yeah</em>’)</li></ul><p>In the past, conventional ASR systems (with an acoustic, pronunciation and language model) could improve contextual biasing (inserting specific words or phrases) via an external language model. With end-to-end models, this is more challenging. Although the model is trained on a larger quantity of data, rare words may not be well represented within the model’s learnt vocabulary, even after fine tuning, and hence the model lacks this context specific information. In order to decode efficiently, end-to-end models often narrow down the most likely output sequence through beam search, and rare context-dependent words or phrases may not get captured.</p><p>There are a few ways we can consider to improve Whisper’s vocabulary and contextual understanding of specialized term, hence increasing its ability to recognize domain specific terms, names and jargon. For everyday local words and phrases, a dataset like NSC Part 2 (containing sentences randomly generated from words based on people, food, location and brands) may be more appropriate for finetuning. Or for xData’s case, a dataset containing specific Home Team related jargon. Methods to consider involve combining datasets, or a subsequent fine tuning stage (especially if the domain-specific dataset is small). Another area of research includes performing <a href="https://medium.com/@nadirapovey/shallow-fusion-298836dd693d">shallow fusion with a separate language model</a> to improve contextual biasing.</p><p>A neat feature of Whisper is also the ability to specify an initial prompt:</p><pre>model = whisper.load_model(&quot;htx-medium-nscpart3&quot;)<br>result = model.transcribe(audio_file) <br>prompt_result = model.transcribe(audio_file, initial_prompt=&quot;HTX, Rong Hui, Katelyn&quot;)<br><br>print(&quot;Original Result: &quot;, result[&quot;text&quot;]) <br>print(&quot;Prompted Result: &quot;, prompt_result[&quot;text&quot;]) </pre><p>Similar to the prompting of an LLM, this provides context that Whisper uses in its transcription. You can simply provide a list of words that can help whisper with specific jargon or unique spellings.</p><pre>Original Result: I went with my friends Rory and Caitlin to the HDX carnival<br>Prompted Result: I went with my friends Rong Hui and Katelyn to the HTX carnival</pre><p>Finally, there are a few considerations that we faced when implementing and testing our finetuned Whisper models for operational use cases, including:</p><ul><li><strong>Phrase/word level code switching</strong> — using Whisper to switch between languages</li><li><strong>Catastrophic forgetting</strong> — exploring the impact of finetuning and whether it degrades Whisper’s existing multilingual or translation capabilities</li><li><strong>Hallucinations</strong> — Whisper’s tendency to ‘fill the silence’ with hallucinated transcriptions</li></ul><p>All of this and more to be explored in subsequent articles :)</p><p><em>Many thanks to Aloysius Tan, Jason Ng, Clifton Teo, Clarence Teo and Calista Choy for their contributions to the finetuning work and this article.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3ae1a6ae809" width="1" height="1" alt=""><hr><p><a href="https://medium.com/htx-dsai/finetuning-whisper-for-the-singaporean-home-team-context-a3ae1a6ae809">Finetuning Whisper for the Singaporean Home Team Context</a> was originally published in <a href="https://medium.com/htx-dsai">HTX DSAI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>