Code-Switching and Mixed-Language Text

Michael BrenndoerferNovember 26, 20262 min read
Language AI HandbookAll chapters
Part 26 of 67Multilingual Language Models and Cross-Lingual Transfer
Chapter 188Code-Switching and Mixed-Language Text
Reading section 1 of 13 · Code-Switching and Mixed-Language Text · 2 minSection 1 of 13 · 2 min

Section 1 of 13 · 2 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Consider a message you might hear between friends in Delhi. "Yaar, I'll call you back, mujhe ek call aaya." Both Hindi and English appear in one turn. A Spanish-English conversation might place an English noun inside a Spanish clause, and a Korean commit message might retain English identifiers from the codebase.

Code-switching is the use of more than one language in a conversation or utterance. If a system uses one language label to route this entire message, the selected pipeline may only handle part of it. The system can return an ordinary-looking result even when its language label has lost information the next step needs.

This chapter looks at what breaks when that assumption fails. It covers:

  • The linguistics of code-switching, because the categories matter for how you design and evaluate a system.
  • Language identification at sentence and word resolution. A sentence label can represent a monolingual segment but cannot locate a switch within it.
  • Mixed scripts, including romanization, transliteration, homoglyphs, and Unicode normalization traps that silently corrupt data.
  • Tokenization economics, showing how the same meaning can cost very different numbers of tokens depending on script and vocabulary.
  • Generation, where models drift into a single language even when asked not to.
  • Evaluation, where BLEU, accuracy, and single-label LID all give misleading results.
  • Deployment failure modes, the silent problems that rarely show up in a demo but appear at scale.

The examples build on language identification and the Part V: Subword Tokenization. We use small labeled examples to show what happens when a sentence crosses a language boundary.

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