Skip to content

Language of every word

Tells you the language of every word in mixed-language text: a message that moves between a local language and English or French mid-sentence. Numbers, punctuation and symbols get other.

words = ym.switch("Yaar aaj office mein bahut meetings thi", langs=["hin_Latn", "eng_Latn"])
for w in words:
    print(w.text, w.lang, round(w.score, 2))
const words = await ym.switch("Niko busy sana leo", { langs: ["swh_Latn", "eng_Latn"] });

Name the user's languages

Pass langs=[...] with the languages your user writes whenever your app knows them (from settings, the keyboard, or earlier messages). It is much more accurate than choosing among every language of a region, which is hard for near-twins such as Malay and Indonesian, or Hindi and Fiji Hindi.

  • With langs, the model's answers are limited to those languages plus other.
  • Without langs, give region= (WA, ESA, AMR, AP, EU, AR, INN, INS, CY, ET, OA, SEA). For non-Latin scripts the region is picked from the script of the text; Latin script spans five regions, so it needs langs or region.

More or fewer switches

sensitivity (0–1) sets how readily a word is marked as switching away from the text's main language. At 0.5 the model decides alone; at 1 the other languages' odds are multiplied by 4 (more switches caught, more false alarms); at 0 they are divided by 4. score stays the model's own probability for the chosen label.

ym.switch("Yaar aaj office mein bahut meetings thi", langs=["hin_Latn", "eng_Latn"], sensitivity=0.3)
await ym.switch(text, { langs: ["hin_Latn", "eng_Latn"], sensitivity: 0.3 });

Where the model is unsure of the main language (Hinglish words at 55–70%), high values flip those words too: start near 0.5 and move in small steps.

How good is it

On real code-switched text from the LinCE benchmark (word accuracy, with the pair named):

Pair YellowMIST
Spanish–English 95.2%
Hindi–English (romanised) 94.1%
Nepali–English 84.2%
Arabic–Egyptian Arabic 77.2%

On short hand-written messages of the kind people send, mostly a local language with English words dropped in (word accuracy with the languages named): North Indic 98.2%, Europe 92.3%, Cyrillic 91.3%, West Africa 88.2%, Central, East and Southern Africa 84.9%. These test sets are small, so treat a few points as noise.

Each model card gives the full results: olaverse/YellowMIST-Switch-1.0-<REGION>.