Code-Switching and Mixed-Language Text › Modeling Code-Switched Text

Michael BrenndoerferNovember 26, 20263 min read
Language AI HandbookAll chapters
Part 26 of 67Multilingual Language Models and Cross-Lingual Transfer
Chapter 188Code-Switching and Mixed-Language Text › Modeling Code-Switched Text
Reading section 7 of 13 · Modeling Code-Switched Text · 3 minSection 7 of 13 · 3 min

Section 7 of 13 · 3 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Consider three starting points for mixed-language models: a direct model, augmentation, or a cascade. Compare them on the same task and sampled data, and track annotation and serving costs alongside quality.

Direct multilingual pretraining

Train or fine-tune one model to accept the whole input without routing it through a language-specific model for each span. mBERT uses Wikipedia across languages, and XLM-R and mT5 use multilingual web corpora. Check the training data for examples that match your deployment inputs. If you expect Hindi in Devanagari, romanized Hindi, and Hindi–English mixtures, include each in your evaluation and measure whether fine-tuning on matched examples helps.

mT5 uses a shared vocabulary and pretrained parameters across languages. Inspect actual subword segmentations and evaluate transfer in both directions on the text and task you intend to support.

Check where the corpus has gaps in script and topic coverage. If almost all your mixed-language training examples come from casual conversation, measure performance on formal or technical samples before using the model for those inputs.

Data augmentation and synthetic code-switching

With parallel examples, generate mixed candidates by substituting aligned spans. Pratapa et al. study synthesis guided by linguistic constraints. Winata et al. use aligned parallel sentences to build synthetic examples. State which alignment and constraints your implementation uses.

Compare the resulting switch positions, span lengths, and registers against a naturally occurring sample. Test whether any repeated alignment heuristic changed the generated distribution.

Compare real-only, synthetic-only, and mixed training sets at specified sizes. Use naturally occurring held-out examples for the comparison and report the language pair, task, and acquisition conditions.

Translationese

Use translated and naturally occurring examples as separate data sources. Inspect the converted examples for word order, discourse markers, and register. State which source supplies your evaluation and verify that the reported score applies to your intended setting.

Cascaded pipelines

A cascade segments the input, routes each segment to its assigned model, then merges the results. Evaluate that full path separately on reliable long spans and ambiguous short spans.

Test whether segmentation errors propagate by comparing a cascade with annotated spans and with predicted spans. Inspect entity spans that cross a boundary and compare translation and retrieval independently. Recovery depends on which information reaches the next stage.

A rough decision guide

Candidate modeling approaches by task and data availability.
SituationReasonable starting point
Plenty of in-language text, few labelsDirect multilingual fine-tune
Little in-language text, parallel data availableSynthesize + mix with any real CS data
Long segments, per-language tools already existCascade with span segmentation
Token-level task on romanized textDirect model; treat script as an explicit feature
Very low-resource language pairCross-lingual transfer from a high-resource relative

None of these is a substitute for measuring on real code-switched evaluation data. The next section shows why.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy