Adapting Language Balance in Code-Switching Speech

Enes Yavuz Ugan, Ngoc-Quan Pham, Alexander WaibelarXiv 2025

TL;DR

Large foundational speech models often fail at "code-switching"—switching languages mid-sentence—because tokens from the embedded (secondary) language are heavily outnumbered by the matrix (dominant) language during training. This paper introduces a simple, script-aware token-weighted cross-entropy loss that dynamically boosts the importance of underrepresented language tokens. This lightweight modification guides the model to accurately recognize language transition points without adding any architectural complexity or inference overhead.

What Problem Does This Paper Address?

In multilingual communities, speakers frequently alternate between languages within a single conversation or sentence, a phenomenon known as code-switching. While state-of-the-art automatic speech recognition (ASR) models like Whisper perform exceptionally well on monolingual benchmarks, they struggle at these language boundaries.

The root cause isn't necessarily a lack of data, but a severe data imbalance. Within a code-switched sentence, the dominant ("matrix") language vastly outnumbers the secondary ("embedded") language. Standard training objectives treat every token equally, meaning the loss function is dominated by matrix-language errors. Consequently, the model develops a strong context bias, often ignoring subtle acoustic cues and failing to switch languages when it should. Standard evaluation metrics like Word Error Rate (WER) mask this issue because overall accuracy remains high even if the model misses every single code-switched word.

Methods

The authors propose a Point-of-Interest (POI) guided training approach using a script-aware loss weighting mechanism. Instead of treating all tokens equally, they reformulate the standard cross-entropy loss function to apply a multiplier ($\alpha > 1$) to tokens belonging to the embedded language:

$$\mathcal{L}_{\text{weighted}} = -\frac{1}{\sum_{i,t} w(s_{i,t})} \sum_{i=1}^N \sum_{t=1}^T w(s_{i,t}) \log p(y_{i,t} \mid x_i)$$

Where $s_{i,t}$ is a binary script label ($0$ for matrix language, $1$ for embedded language), and $w(1) = \alpha$, $w(0) = 1$.

To implement this efficiently without manual token tagging, the authors leverage the fact that different languages often use different written scripts (e.g., Latin vs. Arabic or Chinese Han characters). During training, target token IDs are decoded into strings, and regular expressions automatically categorize them by script. A vectorized lookup table maps these token IDs to their respective weights on the fly, introducing negligible runtime overhead and requiring no extra neural network modules.

Datasets

The approach was evaluated on two distinct code-switching language pairs across three datasets:

  • ArzEn: A clean Egyptian Arabic-English code-switched speech corpus.
  • ASCEND: A spontaneous Mandarin-English dataset used for in-domain evaluation.
  • SEAME: A Mandarin-English code-switching corpus used to test out-of-domain cross-corpus generalization.

Key Insights and Ideas

  • Overcoming Context Bias: By scaling up the gradient updates for embedded tokens, the model is forced to prioritize acoustic boundaries over textual context, preventing it from getting "stuck" in the dominant language.
  • The Multi-Task Pitfall: The authors compared their method against an auxiliary multi-task learning baseline that predicts language identification (LID) tags. Surprisingly, explicit multi-tasking degraded performance compared to standard fine-tuning, proving that direct loss reweighting on the primary task is a more effective strategy.
  • The Return-Trip Dilemma: There is a strict upper bound on how much you can weight the embedded language. If $\alpha$ is set too high (e.g., $\alpha = 2.0$), the model struggles to "return" to the matrix language, leading to severe deletion errors in longer utterances and poor performance on monolingual segments.

Key Results

The weighted loss (WL) approach was tested using Whisper (large-v3-turbo) as the foundational model.

Arabic-English (ArzEn)

As shown in the fine-tuning results, setting $\alpha=1.7$ ($WL_{1.7}$) yielded a relative improvement of 10.03% in Point-of-Interest Error Rate (PIER), dropping it from 19.55% to 17.59%, while keeping overall WER stable.

ArzEn Fine-Tuning Results

An error breakdown reveals that the weighted loss specifically targets and reduces substitution and deletion errors for embedded words.

Fig. 1. Breakdown of insertion (I), deletion (D), and substi- tution (S) error counts on Arzen. We compare the baseline fine-tuned model (FT) with our WL1.5, separately for embed- ded and matrix words.

Mandarin-English (ASCEND & SEAME)

Standard fine-tuning on ASCEND caused severe hallucinations in short utterances, inflating the Mixed Error Rate (MER) to 58.66%. The $WL_{1.5}$ configuration successfully mitigated these hallucinations, achieving the lowest overall MER of 15.6% (a 23.53% absolute improvement over the baseline) while simultaneously reducing PIER. It also demonstrated strong cross-corpus robustness when evaluated on SEAME.

Mandarin-English Results

Limitations and Future Work

The primary limitation of this method is its reliance on distinct writing scripts to differentiate languages. For language pairs that share the same alphabet (such as Spanish-English or French-German), regex-based script classification will fail. In these scenarios, researchers would have to rely on external word-level language identification tools, which can introduce errors.

Additionally, the weighting hyperparameter $\alpha$ currently requires manual tuning. The authors note that future work will focus on developing adaptive strategies to dynamically adjust token weights during training.

Summary updated

BibTeX
@misc{ugan2025adapting,
  author = {Enes Yavuz Ugan and Ngoc-Quan Pham and Alexander Waibel},
  title = {{Adapting Language Balance in Code-Switching Speech}},
  year = {2025},
  eprint = {2510.18724},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.18724},
}
Figure