BroadRouter
Get started

Code-switching

Updated

Code-switching is the use of two or more languages, or varieties of one language, within the same conversation or sentence, in speech or writing. Examples include Arabic speakers mixing English words into dialect, or moving between Modern Standard Arabic and their dialect.

Also called: code switching, code-mixing, code mixing, language mixing, mixed-language text

Code-switching is normal speech for bilingual people. For software that expects one language per input, it is a common source of errors.

How it works

Solorio et al. (2014), in the first shared task on code-switched data, define it broadly as a communication act, “spoken or written, where two or more languages are being used interchangeably”. Their task labelled each word of Twitter posts with its language across four pairs: Modern Standard Arabic-Dialectal Arabic, Mandarin-English, Nepali-English and Spanish-English. Seven teams submitted 42 runs. Word-level identification was hardest for MSA versus dialect, because the two are closely related, and easiest for Spanish-English and Nepali-English.

Arabic users switch in several ways at once:

  • Dialect and MSA. The MADAR paper notes that in unscripted settings where MSA is expected, such as TV talk shows, speakers repeatedly switch between their dialect and MSA.
  • Arabic and English or French. Darwish (2014) observes that many Arabic speakers are bilingual and mix English or French with Arabic inside sentences.
  • Scripts. Typed messages can mix Arabic script, Latin script and Arabizi in one line.

A typical Gulf chat message mixes all of these:

عندي meeting بكرة الساعة 3، can we move it?
("I have a meeting tomorrow at 3, can we move it?")

The Arabic words are dialect, “meeting” is English inside an Arabic clause, and the sentence ends in English. A language detector, a tokenizer and a speech model each have to cope with that switch.

Why it matters

  • Speech-to-text. A transcription request usually takes one language. An English product name inside Arabic speech may come out in Arabic script, in Latin script or misheard. Agree a convention and score word error rate against it, or you will count style differences as errors.
  • Routing and search. A language detector that picks one label per message will mislabel mixed messages, so Arabic intents can land in the English flow.
  • LLM prompts. Tell the model the input may mix languages and say which language to answer in. Otherwise it may mirror whatever language came last.

On BroadNet Inference

BroadNet’s docs say to always send language with transcription, ar for Arabic and en for English, and warn that without it Arabic can be transliterated into Latin letters. They do not document a mixed-language setting. For Arabic speech with English words, send language=ar to BroadNet Transcribe Arabic and test on real recordings; the dialect speech recognition article covers building that test set. For mixed text in chat, Qwen3.8 27B is the model BroadNet reports testing on Arabic dialects.

Questions

Is code-switching the same as code-mixing?

In practice both names describe more than one language in a single message or conversation, and they cause the same problems for language tools. This glossary treats them as one term.

Which language do I send for Arabic audio with English words in it?

On BroadNet, send language=ar for audio that is mainly Arabic. Decide in advance whether English words should stay in Latin script, and check a sample of transcripts.

Can LLMs understand code-switched text?

Usually, for common pairs such as Arabic and English, but quality varies by model and dialect. Say in the prompt that input may mix languages, name the reply language, and test with real messages from your users.

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity