Modeling Code-Switch Languages Using Bilingual Parallel Corpus

Grandee Lee, Haizhou Li

Abstract: Code-switching (CS), the linguistic phenomenon where speakers alternate between two or more languages, presents a significant challenge for natural language processing due to the scarcity of annotated conversational data. This paper introduces the Bilingual Attention Language Model (BALM), which leverages abundant bilingual parallel corpora to train effective code-switching models. BALM incorporates a quasi-translation objective and a bilingual attention mechanism while omitting traditional positional embeddings to better accommodate varying syntactic structures. Evaluation on the SEAME corpus shows that BALM achieves a 20.5% reduction in perplexity over previous state-of-the-art models and significantly improves performance at language switch points.

Introduction

Code-switching is a prevalent linguistic practice in multilingual communities worldwide. Despite its commonality, building language models that can accurately process mixed-language input—such as "I want to eat 晚餐 (dinner) tonight"—remains difficult. The primary hurdle is data scarcity; while monolingual corpora are vast, natural code-switching data is rare, predominantly spoken, and costly to transcribe. Furthermore, code-switching is not random but follows complex syntactic constraints. Existing approaches, such as cross-lingual word embeddings, often fail to capture word order effectively, and models relying on synthetic data frequently lack the nuance of real-world usage.

The BALM Architecture

The authors propose BALM, an auto-regressive Transformer-based model designed to simultaneously learn monolingual patterns and cross-lingual dependencies. BALM's design is predicated on the idea that bilingual parallel data can serve as a proxy for code-switching data.

Key technical innovations include:

  1. Quasi-Translation Objective: BALM is trained to predict a word in Language A given a context that includes its translation in Language B. This forces the model to learn latent alignments between equivalent concepts across languages.
  2. Bilingual Attention: The model attends to the entire translated sentence while predicting the next word in the target sequence, allowing it to bridge gaps between differing syntactic structures.
  3. Removal of Positional Embeddings: In a departure from standard Transformer architectures, the authors found that removing positional embeddings improved performance. They argue that the attention mechanism in an auto-regressive setup already captures sufficient sequential information, and removing rigid position markers allows the model to better integrate bilingual contexts where word orders may conflict.
Training BALM on bilingual parallel data using the quasi-translation objective.

Datasets and Methodology

BALM was trained on a bilingual parallel corpus of 3.6 million lines from TED and OpenSubtitle (Mandarin-English). It was evaluated using the SEAME (South East Asia Mandarin-English) corpus, a benchmark for spontaneous conversational code-switching. The training process involved joint optimization across four pairs: $l_1 \to l_1$, $l_2 \to l_2$, $l_1l_2 \to l_1$, and $l_1l_2 \to l_2$. This approach ensures the model treats code-switching as a natural extension of bilingualism rather than a separate linguistic anomaly.

Experimental Results

BALM demonstrated superior performance across several key metrics:

  • Perplexity (PPL): The model achieved a PPL of 103.20 on the SEAME evaluation set, a 20.5% reduction from the previous best-reported result of 129.85.
  • Switch Point Accuracy: BALM significantly improved prediction at the exact moments of language switching, reducing PPL from 650.82 in standard models to 477.78.
  • Bilingual Lexicon Induction (BLI): BALM outperformed specialized tools like VecMap in Chinese-to-English word translation tasks, achieving 55.87% accuracy compared to 48.46%.
  • Language Normalization: In a task to "translate" code-switched text back into a single matrix language, BALM achieved a Word Error Rate (WER) of 19.73%.
BALM's application in estimating word probabilities and performing language normalization.

Conclusion and Future Work

The success of BALM indicates that real code-switching data is not a prerequisite for building effective CS language models. By utilizing parallel corpora and a flexible attention-based architecture, BALM achieves state-of-the-art results. Future research could extend this framework to document-level contexts or trilingual environments, and explore its potential for generating high-quality synthetic code-switching data.

Summary updated

BibTeX
@inproceedings{lee2020modeling,
  author = {Grandee Lee and Haizhou Li},
  title = {{Modeling Code-Switch Languages Using Bilingual Parallel Corpus}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2020},
  doi = {10.18653/v1/2020.acl-main.80},
}
Figure