Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
fix(evals): compare committed Swedish detector sources
Daniel Nylanderf2477a6692e2
diff --git a/research/evals/massive_route_comparison.md b/research/evals/massive_route_comparison.mdindex f6fdd1db..bd980466 100644--- a/research/evals/massive_route_comparison.md+++ b/research/evals/massive_route_comparison.md@@ -18,12 +18,12 @@ named-language accuracy is reported separately: a detector can safely chooseincluding guess counts, are in[`../results/massive_route_comparison_swedish.json`](../results/massive_route_comparison_swedish.json).-Reproduce from the repository root, passing a baseline and candidate checkout:+Reproduce from the repository root, passing baseline and candidate commits:```shpython research/evals/massive_route_comparison.py \- --before-module /path/to/baseline/laya/lang.py \- --after-module laya/lang.py \+ --before-ref 6d942c92081fbc139e736bbd9ac0023223c29b7f \+ --after-ref ee499bb095587c8af17f2747dacd89a4c76c1ff1 \--out research/results/massive_route_comparison_swedish.json```@@ -34,29 +34,28 @@ downloads the split from Hugging Face on first run and needs `huggingface_hub` i| Measure | Baseline | Candidate | Change ||---|---:|---:|---:|-| Overall checkpoint route accuracy | 77.428% | 77.429% | +0.001 pp |-| Exact named-language accuracy | 8.837% | 8.841% | +0.004 pp |-| Swedish checkpoint route accuracy | 86.954% | 86.954% | 0.000 pp |+| Overall checkpoint route accuracy | 76.831% | 77.428% | +0.597 pp |+| Exact named-language accuracy | 8.243% | 8.837% | +0.594 pp |+| Swedish checkpoint route accuracy | 78.379% | 86.954% | +8.574 pp || Swedish named-language accuracy | 0.000% | 30.296% | +30.296 pp |-| Danish checkpoint route accuracy | 53.430% | 53.430% | 0.000 pp |-| Norwegian Bokmål route accuracy | 49.630% | 49.630% | 0.000 pp |+| Danish checkpoint route accuracy | 44.586% | 53.430% | +8.843 pp |+| Norwegian Bokmål route accuracy | 43.073% | 49.630% | +6.557 pp |-Checkpoint route accuracy changes only for `it` (+0.034 pp) and `pt` (+0.034 pp); no-locale decreased. The overall route gain is two examples out of 151,674. Named-language-accuracy also changes slightly for `de`, `it`, `pt`, and `ro`, reflecting shared evidence-rules rather than locale-specific language work. For the 51 locale rows and exact-before/after counts, use the JSON artifact rather than rounded percentages here.+No locale's checkpoint-routing accuracy decreased. Both detectors are loaded directly+from committed Git objects, with commit IDs and SHA-256 source hashes recorded in the+artifact. The local router implementation is also fingerprinted. This prevents modified+worktree files from being mislabeled as a baseline commit.## Interpretation and limits-MASSIVE measures intent classification utterances, not customer-support transcripts.-It supplies a broad per-locale routing check, not evidence that Swedish support-customers are served well end to end. On the pinned split, the Swedish change improves-named-language detection but barely changes which checkpoint is selected; the-configured default already sends most ambiguous examples to English.--Swedish, Danish, and Norwegian share short words. In the candidate results, four-Norwegian examples are named `sv`; all still route to the same multilingual checkpoint-as before. The detector does not claim that checkpoint-routing gains prove perfect-language identification. Broader Swedish support data and a focused false-positive-review remain useful follow-up work.+MASSIVE contains intent utterances, not customer-support transcripts. Routing accuracy+measures checkpoint selection, not model answer quality. Exact language identification+is reported separately; the detector does not name all 51 languages.++Four Norwegian Bokmål utterances and five Icelandic utterances are labeled Swedish by+the candidate. They still select the expected multilingual checkpoint. Shared Nordic+words therefore remain a limitation for downstream uses of the language label.++The benchmark was used during development and is not an untouched holdout. Real Swedish+support examples and end-to-end model evaluation are still needed for support-quality+claims.diff --git a/research/evals/massive_route_comparison.py b/research/evals/massive_route_comparison.pyindex c848a7ca..83d395fa 100644--- a/research/evals/massive_route_comparison.py+++ b/research/evals/massive_route_comparison.py@@ -6,8 +6,8 @@ and after a proposed change to ``laya.lang``. It evaluates the full test split fRun from the repository root:python research/evals/massive_route_comparison.py \- --before-module /path/to/baseline/laya/lang.py \- --after-module laya/lang.py --out research/results/massive_route_comparison.json+ --before-ref BASELINE_COMMIT \+ --after-ref CANDIDATE_COMMIT --out research/results/massive_route_comparison.jsonNo model weights are loaded. A non-English MASSIVE locale should route to ``multilingual``;English should route to ``english``. Named-language accuracy is reported separately because the@@ -17,7 +17,8 @@ from __future__ import annotationsimport argparseimport gzip-import importlib.util+import hashlib+import typesimport jsonimport subprocessimport sys@@ -33,38 +34,22 @@ REVISION = "940fd47a81eaa7f2cc7b129674d945d618ac38c2"REPO_ROOT = Path(__file__).resolve().parents[2]-def load_detector(path: Path, name: str):- """Load a standalone Laya language module from an arbitrary checkout."""- spec = importlib.util.spec_from_file_location(name, path)- if spec is None or spec.loader is None:- raise RuntimeError("cannot load language detector: %s" % path)- module = importlib.util.module_from_spec(spec)- sys.modules[name] = module- spec.loader.exec_module(module)- return module---def route(detector: Any, router_module: Any, text: str) -> tuple[str, str]:- """Use the repository's real Router._route decision path without loading a checkpoint."""- router = router_module.Router(default="english")- decision = router._route(text)- return decision.model, (decision.get("detection") or {}).get("language") or "undecided"+def git_bytes(*args: str) -> bytes:+ return subprocess.check_output(["git", "-C", str(REPO_ROOT), *args])-def source_revision(path: Path) -> str:- """Return the Git revision owning a detector source file."""- source = path.resolve()- root = next((parent for parent in source.parents if (parent / ".git").exists()), source.parent)- try:- return subprocess.check_output(- ["git", "-C", str(root), "rev-parse", "HEAD"], text=True,- stderr=subprocess.DEVNULL,- ).strip()- except (OSError, subprocess.CalledProcessError):- return "unknown"+def load_detector(ref: str, name: str):+ """Load committed bytes; never label a modified worktree file as its HEAD."""+ revision = git_bytes("rev-parse", "--verify", ref + "^{commit}").decode().strip()+ source = git_bytes("show", revision + ":laya/lang.py")+ module = types.ModuleType(name)+ sys.modules[name] = module+ exec(compile(source, revision + ":laya/lang.py", "exec"), module.__dict__)+ return module, {"revision": revision, "path": "laya/lang.py",+ "sha256": hashlib.sha256(source).hexdigest()}-def score_locale(detector: Any, router_module: Any, locale: str, path: Path) -> Dict[str, Any]:+def score_locale(router: Any, locale: str, path: Path) -> Dict[str, Any]:routes: Counter[str] = Counter()named_languages: Counter[str] = Counter()named_correct = 0@@ -72,7 +57,9 @@ def score_locale(detector: Any, router_module: Any, locale: str, path: Path) ->with gzip.open(path, "rt", encoding="utf-8") as source:for line in source:row = json.loads(line)- model, named_language = route(detector, router_module, row["text"])+ decision = router._route(row["text"])+ model = decision.model+ named_language = (decision.get("detection") or {}).get("language") or "undecided"routes[model] += 1named_languages[named_language] += 1named_correct += named_language == locale@@ -90,10 +77,8 @@ def score_locale(detector: Any, router_module: Any, locale: str, path: Path) ->def main(argv=None) -> int:parser = argparse.ArgumentParser(description=__doc__)- parser.add_argument("--before-module", required=True, type=Path,- help="path to baseline laya/lang.py")- parser.add_argument("--after-module", required=True, type=Path,- help="path to candidate laya/lang.py")+ parser.add_argument("--before-ref", required=True, help="baseline Git commit")+ parser.add_argument("--after-ref", required=True, help="candidate Git commit")parser.add_argument("--out", type=Path, help="write the JSON report to this path")args = parser.parse_args(argv)@@ -102,14 +87,14 @@ def main(argv=None) -> int:if name.startswith("test/") and name.endswith(".json.gz"))if not locales:raise RuntimeError("no per-locale MASSIVE test files at pinned revision")- before_path = args.before_module.resolve()- after_path = args.after_module.resolve()- before = load_detector(before_path, "laya_lang_before")- after = load_detector(after_path, "laya_lang_after")- # Use this checkout's Router implementation and replace only its pure detector function for- # each pass; all checkpoint-selection rules remain the repository code.+ before, before_source = load_detector(args.before_ref, "laya_lang_before")+ after, after_source = load_detector(args.after_ref, "laya_lang_after")+ sys.path.insert(0, str(REPO_ROOT))from laya import router as router_module+ router = router_module.Router(default="english")+ original_analyse = router_module.analyse+report: Dict[str, Any] = {"dataset": DATASET,"revision": REVISION,@@ -117,10 +102,10 @@ def main(argv=None) -> int:"model_free": True,"routing_policy": "english locale -> english checkpoint; every other locale -> multilingual","routing_metric_note": "Router._route decisions are recorded; route accuracy uses expected checkpoint by MASSIVE locale, including Router's configured default for undecided text.",- "before_module": str(before_path),- "before_revision": source_revision(before_path),- "after_module": str(after_path),- "after_revision": source_revision(after_path),+ "before_source": before_source,+ "after_source": after_source,+ "router_source": {"path": "laya/router.py",+ "sha256": hashlib.sha256(Path(router_module.__file__).read_bytes()).hexdigest()},"locales": {},"overall": {},}@@ -134,9 +119,9 @@ def main(argv=None) -> int:revision=REVISION,))router_module.analyse = before.analyse- old = score_locale(before, router_module, locale, local_path)+ old = score_locale(router, locale, local_path)router_module.analyse = after.analyse- new = score_locale(after, router_module, locale, local_path)+ new = score_locale(router, locale, local_path)expected_model = "english" if locale == "en" else "multilingual"for item in (old, new):item["expected_checkpoint"] = expected_model@@ -150,6 +135,7 @@ def main(argv=None) -> int:total["route_correct"] += item["route_correct"]total["named_language_correct"] += item["named_language_correct"]+ router_module.analyse = original_analysefor name, total in (("before", before_total), ("after", after_total)):count = total["examples"]report["overall"][name] = {diff --git a/research/results/massive_route_comparison_swedish.json b/research/results/massive_route_comparison_swedish.jsonindex 20c7862b..91971019 100644--- a/research/results/massive_route_comparison_swedish.json+++ b/research/results/massive_route_comparison_swedish.json@@ -1,8 +1,14 @@{- "after_module": "/Users/danielnylander/Documents/Codex/2026-09-28/kan/work/laya/laya/lang.py",- "after_revision": "75f2a04a80dbf7dee874addc29c77a7539860ccd",- "before_module": "/Users/danielnylander/Documents/Codex/2026-09-28/kan/work/laya-split/laya/lang.py",- "before_revision": "6d942c92081fbc139e736bbd9ac0023223c29b7f",+ "after_source": {+ "path": "laya/lang.py",+ "revision": "ee499bb095587c8af17f2747dacd89a4c76c1ff1",+ "sha256": "9a19b93dda8e784dfc8e326a1d29b67b14e170280ac0327171fc68fd2b76d1c9"+ },+ "before_source": {+ "path": "laya/lang.py",+ "revision": "6d942c92081fbc139e736bbd9ac0023223c29b7f",+ "sha256": "0c336dd6ab96ad592c5e8a6ec132ad9f9c9a5a0e811f40f5bce8292f8304ab1f"+ },"dataset": "mteb/amazon_massive_intent","locales": {"af": {@@ -37,19 +43,19 @@"en": 734,"fr": 1,"it": 4,- "nl": 177,- "pt": 25,- "undecided": 1911+ "nl": 176,+ "pt": 27,+ "undecided": 1910},- "route_accuracy": 0.167787,- "route_correct": 499,+ "route_accuracy": 0.142569,+ "route_correct": 424,"routed_to": {- "english": 2475,- "multilingual": 499+ "english": 2550,+ "multilingual": 424}},"named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "route_accuracy_delta": 0.025218},"am": {"after": {@@ -273,28 +279,28 @@"ro": 1,"undecided": 2387},- "route_accuracy": 0.534297,- "route_correct": 1589,+ "route_accuracy": 0.445864,+ "route_correct": 1326,"routed_to": {- "english": 1385,- "multilingual": 1589+ "english": 1648,+ "multilingual": 1326}},"named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "route_accuracy_delta": 0.088433},"de": {"after": {"examples": 2974,"expected_checkpoint": "multilingual",- "named_language_accuracy": 0.655346,- "named_language_correct": 1949,+ "named_language_accuracy": 0.65501,+ "named_language_correct": 1948,"named_language_guesses": {- "de": 1949,+ "de": 1948,"en": 82,"fr": 3,"pt": 1,- "undecided": 939+ "undecided": 940},"route_accuracy": 0.752186,"route_correct": 2237,@@ -322,7 +328,7 @@"multilingual": 2237}},- "named_language_accuracy_delta": 0.000336,+ "named_language_accuracy_delta": 0.0,"route_accuracy_delta": 0.0},"el": {@@ -495,17 +501,18 @@"named_language_correct": 0,"named_language_guesses": {"en": 97,- "undecided": 2877+ "pt": 9,+ "undecided": 2868},- "route_accuracy": 0.667787,- "route_correct": 1986,+ "route_accuracy": 0.654338,+ "route_correct": 1946,"routed_to": {- "english": 988,- "multilingual": 1986+ "english": 1028,+ "multilingual": 1946}},"named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "route_accuracy_delta": 0.013449},"fr": {"after": {@@ -770,37 +777,36 @@"az": 2,"en": 3,"pt": 7,- "sv": 5,- "undecided": 2957+ "undecided": 2962},- "route_accuracy": 0.909213,- "route_correct": 2704,+ "route_accuracy": 0.89879,+ "route_correct": 2673,"routed_to": {- "english": 270,- "multilingual": 2704+ "english": 301,+ "multilingual": 2673}},"named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "route_accuracy_delta": 0.010423},"it": {"after": {"examples": 2974,"expected_checkpoint": "multilingual",- "named_language_accuracy": 0.590787,- "named_language_correct": 1757,+ "named_language_accuracy": 0.589778,+ "named_language_correct": 1754,"named_language_guesses": {"en": 159,- "es": 19,- "fr": 4,- "it": 1757,- "undecided": 1035+ "es": 20,+ "fr": 5,+ "it": 1754,+ "undecided": 1036},- "route_accuracy": 0.635508,- "route_correct": 1890,+ "route_accuracy": 0.635171,+ "route_correct": 1889,"routed_to": {- "english": 1084,- "multilingual": 1890+ "english": 1085,+ "multilingual": 1889}},"before": {@@ -822,8 +828,8 @@"multilingual": 1889}},- "named_language_accuracy_delta": 0.001009,- "route_accuracy_delta": 0.000337+ "named_language_accuracy_delta": 0.0,+ "route_accuracy_delta": 0.0},"ja": {"after": {@@ -1068,18 +1074,18 @@"bn": 2,"en": 3,"es": 23,- "pt": 1,- "undecided": 2945+ "pt": 3,+ "undecided": 2943},- "route_accuracy": 0.933759,- "route_correct": 2777,+ "route_accuracy": 0.933423,+ "route_correct": 2776,"routed_to": {- "english": 197,- "multilingual": 2777+ "english": 198,+ "multilingual": 2776}},"named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "route_accuracy_delta": 0.000336},"ml": {"after": {@@ -1256,18 +1262,17 @@"fr": 10,"it": 12,"pt": 1,- "sv": 4,- "undecided": 2471+ "undecided": 2475},- "route_accuracy": 0.496301,- "route_correct": 1476,+ "route_accuracy": 0.430733,+ "route_correct": 1281,"routed_to": {- "english": 1498,- "multilingual": 1476+ "english": 1693,+ "multilingual": 1281}},"named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "route_accuracy_delta": 0.065568},"nl": {"after": {@@ -1305,15 +1310,15 @@"pt": 6,"undecided": 1520},- "route_accuracy": 0.283457,- "route_correct": 843,+ "route_accuracy": 0.271352,+ "route_correct": 807,"routed_to": {- "english": 2131,- "multilingual": 843+ "english": 2167,+ "multilingual": 807}},"named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "route_accuracy_delta": 0.012105},"pl": {"after": {@@ -1325,8 +1330,8 @@"de": 1,"en": 53,"es": 1,- "pt": 142,- "undecided": 2777+ "pt": 135,+ "undecided": 2784},"route_accuracy": 0.813046,"route_correct": 2418,@@ -1344,38 +1349,38 @@"de": 1,"en": 53,"es": 1,- "pt": 135,- "undecided": 2784+ "pt": 137,+ "undecided": 2782},- "route_accuracy": 0.813046,- "route_correct": 2418,+ "route_accuracy": 0.812038,+ "route_correct": 2415,"routed_to": {- "english": 556,- "multilingual": 2418+ "english": 559,+ "multilingual": 2415}},"named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "route_accuracy_delta": 0.001008},"pt": {"after": {"examples": 2974,"expected_checkpoint": "multilingual",- "named_language_accuracy": 0.53228,- "named_language_correct": 1583,+ "named_language_accuracy": 0.531944,+ "named_language_correct": 1582,"named_language_guesses": {"en": 62,"es": 14,"fr": 1,"it": 8,- "pt": 1583,- "undecided": 1306+ "pt": 1582,+ "undecided": 1307},- "route_accuracy": 0.765636,- "route_correct": 2277,+ "route_accuracy": 0.765299,+ "route_correct": 2276,"routed_to": {- "english": 697,- "multilingual": 2277+ "english": 698,+ "multilingual": 2276}},"before": {@@ -1391,30 +1396,30 @@"pt": 1582,"undecided": 1307},- "route_accuracy": 0.765299,- "route_correct": 2276,+ "route_accuracy": 0.764963,+ "route_correct": 2275,"routed_to": {- "english": 698,- "multilingual": 2276+ "english": 699,+ "multilingual": 2275}},- "named_language_accuracy_delta": 0.000336,- "route_accuracy_delta": 0.000337+ "named_language_accuracy_delta": 0.0,+ "route_accuracy_delta": 0.000336},"ro": {"after": {"examples": 2974,"expected_checkpoint": "multilingual",- "named_language_accuracy": 0.151311,- "named_language_correct": 450,+ "named_language_accuracy": 0.150975,+ "named_language_correct": 449,"named_language_guesses": {"bn": 2,"en": 221,"es": 10,"fr": 120,- "it": 98,+ "it": 99,"pt": 24,- "ro": 450,+ "ro": 449,"undecided": 2049},"route_accuracy": 0.533289,@@ -1446,7 +1451,7 @@"multilingual": 1586}},- "named_language_accuracy_delta": 0.000336,+ "named_language_accuracy_delta": 0.0,"route_accuracy_delta": 0.0},"ru": {@@ -1517,15 +1522,15 @@"pt": 108,"undecided": 2731},- "route_accuracy": 0.573638,- "route_correct": 1706,+ "route_accuracy": 0.572293,+ "route_correct": 1702,"routed_to": {- "english": 1268,- "multilingual": 1706+ "english": 1272,+ "multilingual": 1702}},"named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "route_accuracy_delta": 0.001345},"sq": {"after": {@@ -1538,8 +1543,8 @@"fr": 10,"it": 94,"nl": 1,- "pt": 42,- "undecided": 2812+ "pt": 39,+ "undecided": 2815},"route_accuracy": 0.914929,"route_correct": 2721,@@ -1558,8 +1563,8 @@"fr": 10,"it": 94,"nl": 1,- "pt": 39,- "undecided": 2815+ "pt": 42,+ "undecided": 2812},"route_accuracy": 0.914929,"route_correct": 2721,@@ -1595,25 +1600,24 @@"before": {"examples": 2974,"expected_checkpoint": "multilingual",- "named_language_accuracy": 0.302959,- "named_language_correct": 901,+ "named_language_accuracy": 0.0,+ "named_language_correct": 0,"named_language_guesses": {- "de": 7,- "en": 43,- "fr": 4,+ "de": 11,+ "en": 47,+ "fr": 7,"ro": 1,- "sv": 901,- "undecided": 2018+ "undecided": 2908},- "route_accuracy": 0.869536,- "route_correct": 2586,+ "route_accuracy": 0.783793,+ "route_correct": 2331,"routed_to": {- "english": 388,- "multilingual": 2586+ "english": 643,+ "multilingual": 2331}},- "named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "named_language_accuracy_delta": 0.302959,+ "route_accuracy_delta": 0.085743},"sw": {"after": {@@ -1791,15 +1795,15 @@"pt": 77,"undecided": 2320},- "route_accuracy": 0.114997,- "route_correct": 342,+ "route_accuracy": 0.11466,+ "route_correct": 341,"routed_to": {- "english": 2632,- "multilingual": 342+ "english": 2633,+ "multilingual": 341}},"named_language_accuracy_delta": 0.0,- "route_accuracy_delta": 0.0+ "route_accuracy_delta": 0.000337},"tr": {"after": {@@ -1997,21 +2001,25 @@"model_free": true,"overall": {"after": {- "examples": 151674,- "named_language_accuracy": 0.088407,- "named_language_correct": 13409,- "route_accuracy": 0.774292,- "route_correct": 117440- },- "before": {"examples": 151674,"named_language_accuracy": 0.088367,"named_language_correct": 13403,"route_accuracy": 0.774279,"route_correct": 117438+ },+ "before": {+ "examples": 151674,+ "named_language_accuracy": 0.082427,+ "named_language_correct": 12502,+ "route_accuracy": 0.768312,+ "route_correct": 116533}},"revision": "940fd47a81eaa7f2cc7b129674d945d618ac38c2",+ "router_source": {+ "path": "laya/router.py",+ "sha256": "df3b5de7d91ead9a27b3ca3abf92aef5aa350c176b70d4411af5319a20b8d962"+ },"routing_metric_note": "Router._route decisions are recorded; route accuracy uses expected checkpoint by MASSIVE locale, including Router's configured default for undecided text.","routing_policy": "english locale -> english checkpoint; every other locale -> multilingual","split": "test"diff --git a/tests/test_router.py b/tests/test_router.pyindex d243aafa..a741cd76 100644--- a/tests/test_router.py+++ b/tests/test_router.py@@ -714,16 +714,74 @@ check("latin_lang/accented german stays non-english",is_english("Grüße aus Köln, wir melden uns wegen der Rechnung"), False)check("route/accented german stays multilingual",_r_lat.route("Grüße aus Köln, wir melden uns wegen der Rechnung").model, "multilingual")-# Danish and Swedish hold no list here, and their accented function-word sentences pick up just-# one or two English-shaped words (`i`, `at`, `for`, `have`), which is not the two-distinct-word-# English the rescue requires -- a rescue that counted them sent plain Danish to the English-# checkpoint on the MASSIVE splits.+# Danish still has no list here, and its accented sentences pick up just one or two English-shaped+# words (`i`, `at`, `for`, `have`), which is not the two-distinct-word English the rescue requires.for text in ["sluk lyset i soveværelset", # da"kan jeg få en refundering for det dobbelte beløb", # da- "stäng av ljuset i sovrummet", # sv- "jag vill ha en återbetalning för den dubbla avgiften"]: # sv+ "stäng av ljuset i sovrummet"]: # svcheck("latin_lang/nordic accented stays non-english " + text, is_english(text), False)check("route/nordic accented stays multilingual " + text, _r_lat.route(text).model, "multilingual")++# Swedish-specific words now identify both normal text and ASCII-normalised support prose. The+# second sample is the real false-negative shape: `få` alone was too weak to stop its two English-+# shaped words (`i`, `kan`) from pulling the request onto the English checkpoint.+for text in ["Om ni inte kan få tillbaka de raderade filerna i dag avslutar jag mitt abonnemang.",+ "Om ni inte kan fa tillbaka de raderade filerna i dag avslutar jag mitt abonnemang.",+ "jag vill att ni hjalper mig med detta"]:+ check("latin_lang/swedish is named " + text, guess_latin_language(text), "sv")+ check("route/swedish uses multilingual " + text, _r_lat.route(text).model, "multilingual")+ check("route/swedish detection reports sv " + text, _r_lat.route(text)["detection"]["language"], "sv")+# Common Swedish support phrasing should identify the language across billing, account, technical+# and delivery messages, both with and without Swedish diacritics.+for text in ["Kan ni hjälpa mig?", "Min faktura är fel", "Jag behöver hjälp med betalningen",+ "Kan ni skicka kvittot igen?", "Jag vill byta lösenord",+ "Appen kraschar när jag öppnar inställningarna",+ "Var hittar jag inställningen för tvåfaktorsinloggning?",+ "Vi har debiterats två gånger för mars",+ "Var är mitt paket? Spårningen har inte uppdaterats"]:+ check("latin_lang/swedish support is named " + text, guess_latin_language(text), "sv")+ check("route/swedish support uses multilingual " + text,+ _r_lat.route(text).model, "multilingual")+for text in ["min faktura ar fel", "jag behover hjalp med betalningen",+ "kan ni skicka kvittot igen", "jag vill byta losenord",+ "appen kraschar nar jag oppnar installningarna",+ "var hittar jag installningen for tva faktorsinloggning",+ "vi har blivit debiterade tva ganger for mars",+ "var ar mitt paket sparningen har inte uppdaterats"]:+ check("latin_lang/ascii swedish support is named " + text, guess_latin_language(text), "sv")+ check("route/ascii swedish support uses multilingual " + text,+ _r_lat.route(text).model, "multilingual")+# Short login failures often contain English technical vocabulary and can arrive without Swedish+# diacritics. Swedish `kan` + `inte` must outweigh the incidental English token `in`.+for text in ["Kan inte logga in", "kan inte logga in", "Jag kan inte logga in", "Vi kan inte logga in"]:+ check("latin_lang/short swedish login is named " + text, guess_latin_language(text), "sv")+ check("route/short swedish login uses multilingual " + text,+ _r_lat.route(text).model, "multilingual")+ check("route/short swedish login detection reports sv " + text,+ _r_lat.route(text)["detection"]["language"], "sv")+# Two- and three-word Swedish support fragments do not reach the general four-word evidence+# threshold. Only distinctly Swedish terms should name them; generic words and Nordic controls+# remain undecided rather than being guessed as Swedish.+for text in ["Ingen åtkomst", "Ingen atkomst", "Fakturan är fel", "Betalningen nekades",+ "Behöver hjälp", "Behover hjalp", "Glömt lösenord", "Glomt losenord",+ "Felmeddelande igen", "Kvitto saknas", "Inloggningen fungerar"]:+ check("latin_lang/short Swedish support is named " + text, guess_latin_language(text), "sv")+ check("route/short Swedish support uses multilingual " + text,+ _r_lat.route(text).model, "multilingual")+ check("route/short Swedish support detection reports sv " + text,+ _r_lat.route(text)["detection"]["language"], "sv")+for text in ["Ingen adgang", "Fakturaen feil", "Glemt passord", "Pakken forsinket",+ "No account access", "Password forgotten"]:+ check("latin_lang/short non-Swedish stays undecided " + text,+ guess_latin_language(text), None)+check("latin_lang/english login stays english",+ guess_latin_language("I cannot login to my account"), "en")+check("route/english login stays english",+ _r_lat.route("I cannot login to my account").model, "english")+check("latin_lang/danish login is not called swedish",+ guess_latin_language("Jeg kan ikke logge inn"), None)+check("latin_lang/danish account login is not called swedish",+ guess_latin_language("Jeg kan ikke logge ind på min konto"), None)# Two non-English-letter words is a running non-English vocabulary, not one loanword: the rescue# does not fire even with English function words present.check("latin_lang/two diacritic words are not one loanword",