Training a code-switching language model with monolingual data

Shun-Po Chuang, Tzu-Wei Sung, Hung-yi LeearXiv 2019

Abstract: A lack of code-switching data complicates the training of code-switching (CS) language models. We propose an approach to train such CS language models on monolingual data only. By constraining and normalizing the output projection matrix in RNN-based language models, we bring embeddings of different languages closer to each other. Numerical and visualization results show that the proposed approaches remarkably improve the performance of CS language models trained on monolingual data. The proposed approaches are comparable or even better than training CS language models with artificially generated CS data. We additionally use unsupervised bilingual word translation to analyze whether semantically equivalent words in different languages are mapped together.

Introduction

Code-switching (CS)—the practice of alternating between two or more languages in a single conversation—is common in multilingual societies. However, building language models (LMs) for CS is difficult because high-quality, transcribed code-switching data is extremely scarce compared to pure monolingual data. Standard LMs trained on monolingual data struggle with CS because the latent representations (embeddings) for each language often drift into disjoint regions of the vector space. Without seeing "switch points" in the training data, the model lacks a mathematical bridge to transition between languages.

Methodology

We propose three main techniques to align language embeddings within a standard RNN-based (LSTM) language model by applying geometric constraints and normalization to the model's output projection matrix.

Conceptual diagram of the proposed RNN-based language model with and without geometric constraints on language distributions.
  1. Symmetric Kullback–Leibler Divergence (SKLD): Assuming word embeddings for each language follow a multivariate Gaussian distribution, we minimize the SKLD between the distributions of Language 1 ($W_1$) and Language 2 ($W_2$). This forces the two "clouds" of words to occupy the same semantic space.
  2. Cosine Distance (CD) Constraint: A simpler geometric approach where the model minimizes the distance between the mean vectors of the two language embedding sets, ensuring a shared "center of gravity."
  3. Output Projection Matrix Normalization: By dividing each word vector by its $L_2$ norm during training, the model's predictions are based purely on the orientation of the vectors. This makes it easier for semantically similar words across languages to achieve similar probabilities.

Experimental Setup and Results

We utilized the SEAME corpus, a Mandarin-English code-switching corpus. Crucially, the model was trained only on the monolingual portions, while actual CS sentences were reserved for evaluation. Performance was measured using Perplexity (PPL) and Code-Switching Point Perplexity (CSP-PPL).

Visualization of Mandarin and English word embeddings for (a) baseline monolingual training, (b) word substitution, and (c) the proposed SKLD method.

As shown in the embedding visualizations, the baseline model maintains strictly separated clusters for Mandarin and English. The proposed SKLD method successfully forces these distributions to overlap. Quantitatively, the SKLD + Normalization approach dropped the CSP-PPL from a baseline of 1118.88 to 601.58. Notably, this method trained on monolingual data only (Overall PPL: 197.15) outperformed a baseline model trained on synthetic code-switching data (Overall PPL: 246.41).

Conclusion

Our results demonstrate that well-aligned latent spaces are more critical for code-switching than exposure to noisy, synthetic examples. By enforcing geometric constraints, we can develop effective CS language models using only monolingual data. Future work will investigate the scalability of these techniques to larger vocabularies and more diverse language pairs.

Summary updated

BibTeX
@misc{chuang2019training,
  author = {Shun-Po Chuang and Tzu-Wei Sung and Hung-yi Lee},
  title = {{Training a code-switching language model with monolingual data}},
  year = {2019},
  eprint = {1911.06003},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1911.06003},
}
Figure