From 6dcc2228b4e589dd46da0c2b85fc9d189886c3b8 Mon Sep 17 00:00:00 2001 From: Rishit Sharma Date: Wed, 23 Sep 2026 22:58:08 +0530 Subject: [PATCH 1/3] fix(lang): identify plain-ASCII German instead of labelling it English Short German requests without umlauts were labelled English and routed to the English checkpoint (#54). The `de` stopword list held only 23 words and missed most of the function words assistant traffic is made of (ich, wie, mir, bitte, meinen, im, heute), while `in` and `was` counted for English alone. German needs a two-hit margin over English, so a sentence like "wie lautet die temperatur in fulda in hessen" scored de=1 against en=2 and fell through to "en". Add 38 high-frequency German function words that no other list claims, and list `in` and `was` for German too so they no longer count as evidence for English only. test_lang_guess pinned "Mein Konto wurde zweimal belastet, bitte erstatten Sie" to the English checkpoint; it now routes to multilingual. MASSIVE 1.1 test split, share routed to the English checkpoint: de-DE 0.507 -> 0.247 (accents stripped: 0.753 -> 0.364) en-US 1.000 -> 1.000; 0 of 16,521 en-US utterances change label or route every other locale unchanged, except af-ZA (-0.013) and one stripped vi-VN state, which move to multilingual German with no identified language and no umlauts still takes the router's `default` (English unless configured); that case is a separate follow-up agreed on #54. --- laya/lang.py | 8 +++++++- tests/test_lang_guess.py | 2 +- tests/test_router.py | 13 +++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/laya/lang.py b/laya/lang.py index a0e84637c..48f7cf874 100644 --- a/laya/lang.py +++ b/laya/lang.py @@ -64,7 +64,13 @@ "merci", "bonjour", "jour", "jours", "mois", "fois", "quand", "comment", "pourquoi", "alors", "donc"}, "de": {"der", "die", "das", "und", "ist", "ein", "eine", "den", "dem", "nicht", "mit", "für", - "auf", "von", "zu", "sich", "auch", "werden", "wurde", "haben", "sind", "oder", "aber"}, + "auf", "von", "zu", "sich", "auch", "werden", "wurde", "haben", "sind", "oder", "aber", + "ich", "wir", "mir", "mich", "dir", "dich", "uns", "mein", "meine", "meinen", + "meinem", "meiner", "diese", "dieser", "diesen", "dieses", "einen", "einem", "einer", + "wie", "wo", "wann", "welche", "im", "zum", "zur", "aus", "bei", "nach", "noch", "bitte", + "heute", "jetzt", "kann", "kannst", "habe", "gibt", "wird", + # shared with English on purpose: counted for English alone, they outvoted short German + "in", "was"}, "es": {"el", "los", "las", "que", "por", "con", "para", "una", "es", "se", "del", "como", "pero", "son", "está", "este", "esta", "todo", "más", "muy", "hay", "sus", # `de`/`en` are Spanish too, but they are common English tokens as well (`de facto`, diff --git a/tests/test_lang_guess.py b/tests/test_lang_guess.py index 75438c16b..17c20d69c 100644 --- a/tests/test_lang_guess.py +++ b/tests/test_lang_guess.py @@ -168,7 +168,7 @@ def _load(name): # `Router().route(...)` cannot fail, because both sides are the same pure call on an # equally configured router -- a regression would move both together. BEFORE = [("plain english", "I was charged twice and want a refund", "english"), - ("German with umlauts", "Mein Konto wurde zweimal belastet, bitte erstatten Sie", "english"), + ("German with umlauts", "Mein Konto wurde zweimal belastet, bitte erstatten Sie", "multilingual"), ("Hindi", "यह एक हिंदी वाक्य है", "multilingual"), ("empty", "", "english"), ("digits", "12345", "english")] diff --git a/tests/test_router.py b/tests/test_router.py index 5c79f5f4d..d0c0aed0e 100644 --- a/tests/test_router.py +++ b/tests/test_router.py @@ -462,6 +462,19 @@ def check(name, got, want): guess_latin_language("Ei nu sunt de acord cu factura, vreau o corecție"), "ro") +# --------------------------------------------------------------------- plain-ASCII German (#54) +# No umlaut for the diacritic rate to catch, and `in`/`was` counted for English alone, so these were +# labelled English and handed to the checkpoint that cannot read them. +for text in ["trage diesen termin in meinen kalender ein", + "wie lautet die temperatur in fulda in hessen", + "schalte das licht im wohnzimmer aus", + "was ist die aktuelle zeit"]: + check("latin_lang/ascii german " + text, guess_latin_language(text), "de") + check("route/ascii german " + text, _r_lat.route(text).model, "multilingual") +check("route/english control for #54", + _r_lat.route("I would like to book a flight to Berlin tomorrow").model, "english") + + # --------------------------------------------------------------------- temperature clamp (#35) # A fitted temperature below 1 sharpens logits. The shipped `choice:11+` bucket is 0.1006, which # turned a 0.24 top probability into 0.99 confidence on 13-option skill routing. From b22698ccf939375aaf12d7a073435ac325d090ef Mon Sep 17 00:00:00 2001 From: Rishit Sharma Date: Wed, 23 Sep 2026 22:58:22 +0530 Subject: [PATCH 2/3] test(lang): keep es and du out of the German stopwords `es` and `du` are German function words, but Spanish and French claim them too, and a word two lists share names neither language. With them in the German list, "que hora es en australia" and "baisse le volume du haut-parleur" are left undecided and routed to the English checkpoint, and the MASSIVE es-ES share routed to multilingual falls from 0.711 to 0.692 (0.488 to 0.447 with accents stripped; fr-FR 0.822 to 0.816). Pin both so a later German addition cannot bring them back. --- tests/test_router.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_router.py b/tests/test_router.py index d0c0aed0e..80b8fc8bd 100644 --- a/tests/test_router.py +++ b/tests/test_router.py @@ -473,6 +473,9 @@ def check(name, got, want): check("route/ascii german " + text, _r_lat.route(text).model, "multilingual") check("route/english control for #54", _r_lat.route("I would like to book a flight to Berlin tomorrow").model, "english") +# German words that Spanish (`es`) or French (`du`) also claim would stop naming those languages +check("latin_lang/spanish es stays evidence", guess_latin_language("que hora es en australia"), "es") +check("latin_lang/french du stays evidence", guess_latin_language("baisse le volume du haut-parleur"), "fr") # --------------------------------------------------------------------- temperature clamp (#35) From 5be6e111a92523047a215dcc9ac162c68e08776d Mon Sep 17 00:00:00 2001 From: Rishit Sharma Date: Wed, 23 Sep 2026 23:11:35 +0530 Subject: [PATCH 3/3] test(lang): pin English that shares words with the German list `in` and `was` now count for German as well as English, and `im` and `den` are English tokens too. Pin two English states that must keep routing to English: "turn off smart lamp in den", the en-US MASSIVE utterance nearest to flipping (de=2 against en=1, three needed), and a chat line with `im` that flips if any one of `am`, `an` or `so` joins the German list. Making `in`/`was` German-only flips both. --- tests/test_router.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_router.py b/tests/test_router.py index 80b8fc8bd..24d65d908 100644 --- a/tests/test_router.py +++ b/tests/test_router.py @@ -473,6 +473,11 @@ def check(name, got, want): check("route/ascii german " + text, _r_lat.route(text).model, "multilingual") check("route/english control for #54", _r_lat.route("I would like to book a flight to Berlin tomorrow").model, "english") +# English that shares words with the German list stays English. `in` and `den` leave the first, a real +# en-US MASSIVE utterance, one German hit short of flipping; the chat line carries `im` and flips if +# any one of the English words `am`, `an` or `so` joins the German list. +for text in ["turn off smart lamp in den", "im so sorry, am an hour late, stuck in traffic"]: + check("route/english sharing german words " + text, _r_lat.route(text).model, "english") # German words that Spanish (`es`) or French (`du`) also claim would stop naming those languages check("latin_lang/spanish es stays evidence", guess_latin_language("que hora es en australia"), "es") check("latin_lang/french du stays evidence", guess_latin_language("baisse le volume du haut-parleur"), "fr")