Abstract
This work focuses on building language models (LMs) for code-switched text. We propose two techniques that significantly improve these LMs: 1) A novel recurrent neural network unit with dual components that focus on each language in the code-switched text separately 2) Pretraining the LM using synthetic text from a generative model estimated using the training data. We demonstrate the effectiveness of our proposed techniques by reporting perplexities on a Mandarin-English task and derive significant reductions in perplexity.
Introduction
Code-switching—the practice of alternating between two or more languages in a single conversation—is a natural human behavior but presents a significant challenge for machine modeling. Standard Recurrent Neural Networks (RNNs) often struggle with code-switched (CS) data due to two primary factors: data scarcity and structural complexity. Transitions between languages are often abrupt, and a standard RNN attempts to model the syntax and vocabulary of two distinct languages using a single set of parameters, leading to "confusion" at switching boundaries.
Proposed Methods
Dual RNN Language Model (D-RNNLM)
To address the structural complexity of CS text, we propose the Dual RNN Language Model (D-RNNLM). Unlike a standard LSTM, the D-RNNLM utilizes a "Dual LSTM cell" architecture.
The architecture features two separate LSTM units ($L_0$ and $L_1$), each specialized for one of the two languages. A language ID bit directs incoming tokens to the corresponding "upstream" LSTM. This unit processes the token and passes its internal state to the "downstream" unit, ensuring that global context is preserved across language switches while allowing specialized neurons to handle language-specific vocabulary and syntax.
Same-Source Pretraining
To mitigate data scarcity, we introduce "Same-Source Pretraining." Instead of relying solely on massive external datasets, we use a Generative Adversarial Network (SeqGAN) to learn the distribution of the existing small CS dataset. We generate a large volume of synthetic code-switched text to pretrain the LM before fine-tuning it on the original real training data. This approach helps the model overcome exposure bias and provides a smoother probability landscape for learning.
Experimental Setup
We evaluated our methods on the SEAME corpus, a conversational Mandarin-English code-switched speech dataset. Experiments were conducted using an 80-10-10 split for training, development, and testing. We also explored the impact of incorporating external monolingual data (Switchboard for English, AIShell/THCHS30 for Mandarin) and syntactic features such as Part-of-Speech (POS) tags.
Results
The performance of the models was measured using perplexity, where lower values indicate better predictive performance.
As shown in the results table, the D-RNNLM alone improves upon the baseline RNNLM. The most significant gains are achieved when combining the D-RNNLM with SeqGAN pretraining, reaching a test perplexity of 65.41 compared to the baseline's 74.87. When further augmented with monolingual data and syntactic features, the perplexity is reduced to 55.60. Analysis indicates that the D-RNNLM is particularly effective at predicting "switching tokens"—the first word after a language change.
Conclusion and Future Work
The D-RNNLM and Same-Source Pretraining techniques offer a robust framework for modeling code-switched language. By allowing specialized neurons to coordinate across language boundaries and leveraging synthetic data for pretraining, we achieve substantial reductions in perplexity.
Future work includes addressing the dependency on language ID bits during inference and scaling the architecture to handle more than two languages. Additionally, the dual-stream approach may be applicable to other multi-stream tasks such as speaker diarization.
Summary updated