Code-Switching and Mixed-Language Text › Modeling Code-Switched Text
Language AI HandbookAll chapters 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.
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
| Situation | Reasonable starting point |
|---|---|
| Plenty of in-language text, few labels | Direct multilingual fine-tune |
| Little in-language text, parallel data available | Synthesize + mix with any real CS data |
| Long segments, per-language tools already exist | Cascade with span segmentation |
| Token-level task on romanized text | Direct model; treat script as an explicit feature |
| Very low-resource language pair | Cross-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!