Code and dense tables are folded away. Open any of them on demand.
What is language routing?
Language routing is a step that detects the script and language of each input and sends it to the model most likely to read it correctly. Laya uses it to choose between its English checkpoint and its multilingual checkpoint, because an English model given text it cannot read still answers with high confidence instead of failing.
The simplest multilingual system is one multilingual model for everything. It works, but it gives up quality on the dominant language: a model whose capacity is shared across 100+ languages is usually weaker on English than a model of similar size dedicated to English.
The opposite, one English model for everything, fails silently on everything else. The failure is the problem. Laya's model card reports that its English checkpoint, on 20-option MASSIVE intent classification, scores 0.100 on Hindi and 0.103 on Korean (random is 0.050) and 0.000 on Khmer at 0.952 confidence. The model does not know it cannot read the text. As the card puts it: "Because the model stays confident while being wrong, confidence gating cannot save you."
Routing takes the better of both: a detector inspects the input and chooses the model most likely to handle it. When the detector is cheap and reliable, the system gets each model's strength without its blind spot.
What routing buys: Laya's numbers
Measured on a shared benchmark of 17,416 questions on one T4 GPU, identical questions per model:
Show technical detailsHide technical details· 6 rows × 4 columns
| Benchmark | English checkpoint | Multilingual checkpoint | Router |
|---|---|---|---|
| MASSIVE intent, English | 0.783 | 0.657 | 0.783 |
| MASSIVE intent, 13 other languages | 0.306 | 0.451 | 0.451 |
| XNLI, English | 0.860 | 0.843 | 0.860 |
| XNLI, 14 other languages | 0.521 | 0.731 | 0.731 |
| Languages usable (> 3x random), of 51 | 23 | 45 | 45 |
| Latency, 1 question (T4) | 39.5 ms | 32.8 ms | 32.8 ms (non-English) |
The router matches the best column in every row. Detection itself costs under 0.5 ms in pure Python, according to the card.
How Laya's router decides
The router needs one bit of information, not a language label: can the English checkpoint read this? Its decision follows a fixed precedence (from Router.route in the source):
- Explicit model (
model="english"etc.) always wins. - Explicit task (
task="typed_decisions"). - Detected typed-decisions workflow, only if
auto_task_detectionis enabled and the question ids exactly match one of the four workflows. - Explicit language code (
lang="pt-BR"): English codes go to English, anything else to multilingual. - A caller-supplied language guess, such as your own language-ID model; if it abstains, fall through.
- Built-in detection of script and language.
- Default, which is English unless configured otherwise.
Step 6 in detail: script first
Detection flattens the state to its string values (object keys are ignored, since they are usually English field names) and counts letters by Unicode block. Latin characters are counted as Latin; Greek, Cyrillic, Arabic, Devanagari, Hangul, Han, Kana, Thai, Khmer and about twenty other scripts have explicit ranges. Any alphabetic character that matches no listed range counts as "other", which is non-Latin. That last rule is a deliberate safety choice: an unlisted script must never be treated as English.
If the dominant script is not Latin, the request goes to the multilingual checkpoint. This part is exact.
Latin script: the hard case
French, Portuguese, Romanian and English share an alphabet, so script alone cannot separate them. For Latin text the router uses:
- Function-word lists for English, French, German, Spanish, Portuguese, Italian, Dutch and Romanian. A non-English language must beat English by a margin (at least two hits more) to be named.
- Unique-word evidence. Words shared by several lists (
la,e,que) cannot name a language on their own. A language needs at least one word no other list claims. - Diacritic rate. If at least 2% of characters are letters ordinary English does not use (ç, ã, ș, ł, ő and others), the text is treated as non-English even when no list identifies it. This catches Polish, Czech, Turkish and other languages without stopword lists.
- Identifier stripping. URLs, email addresses and dotted names are removed first, because fragments like
comandocollide with Portuguese words. - Unaccented forms. Romance lists include unaccented spellings, because mail clients and ticket systems often strip accents. The card reports this raised correct routing of accent-stripped Italian utterances of six or more words from 39% to 80%, with no change across 20,000 English texts.
When nothing identifies the language (very short text, or only content words like "Quero cancelar") and no non-English letters appear, the state is undecided and goes to the default. The source is explicit that undecided is not the same as English; it just has no evidence either way.
Reading routing reasons
Every response carries a routing object explaining the choice. These are real outputs from the open-source router:
| State | Model | Reason |
|---|---|---|
| "I was charged twice" | english | English Latin text |
| "Mein Konto wurde zweimal belastet. Bitte erstatten Sie den doppelten Betrag." | multilingual | Latin script but language looks like 'de', not English |
| "Voce pode me mandar a nota fiscal?" | multilingual | Latin script but language looks like 'pt', not English |
| "मुझसे दो बार शुल्क लिया गया" | multilingual | non-Latin script (devanagari, 100% of letters); the English checkpoint cannot read it |
| "Quero cancelar" | english | Latin script, language not identified and no non-English letters; using default (english) |
The last row is the router's known blind spot: two Portuguese words carry no evidence. If your traffic is mostly non-English and messages are short, pin the multilingual checkpoint or pass a language code you already know.
Routing on Laya Studio
Laya Studio runs this router on every request unless you pin a checkpoint with model. The typed-decisions checkpoint is never chosen automatically; request it explicitly.
Show technical detailsHide technical details· bash sample
The routing block for this Hindi message:
Show technical detailsHide technical details· json sample
Log routing.model and routing.reason with every decision: they make misroutes easy to find. Routing is free; you pay the input tokens read, whichever checkpoint answers. See the docs and sign up.
Frequently asked questions
How accurate is Laya's language detection?
Can I override the router?
Does the router look at my JSON keys?
Why not use a proper language-ID model like fastText?
What happens with mixed-language text?
Why does language detection matter for AI classification?
How do I know which model answered my request?
Sources
- Laya model card: Why Route
- Laya source code (router.py, lang.py)
- Unicode Standard Annex #24: Unicode Script Property
- Joulin et al. (2016), Bag of Tricks for Efficient Text Classification (fastText, used for language ID)
- fastText language identification models
- FitzGerald et al. (2022), MASSIVE multilingual NLU dataset
Last updated . Laya Studio is an independent hosted service for the open-source Laya model (Apache-2.0, © Convai Innovations) and is not affiliated with Convai Innovations or TypeSafe.
Next articleDecision models for AI agents: fast judgements around a slow plannerWhy AI agents need a separate decision model for guardrails, intent, tool choice and escalation, how it fits beside the LLM, and where Laya's limits are.