From 6ab7fd5c7f96fa12a6e64dea569a10a270c428e9 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 9 Jul 2026 16:40:02 -0400 Subject: [PATCH] tune(translation): set latin acceptance floor to 0.80 (#1376) Calibrated against fresh probes once Interpreter returned real langdetect confidence: genuine German detected at 1.0, a correctly-detected but ambiguous latin string at 0.86. Set _MIN_LATIN_CONFIDENCE to 0.80 (below that band) so legitimate ambiguous non-English still translates while genuinely-unsure guesses are rejected. Real langdetect also fixed the original mis-flag at the source, so this floor is a safety net, not the primary fix. Pin 0.86-accepted in the gate test to guard against bumping the floor back up. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01CgZP9v2otxVJymiYsnVuMy --- backend/app/tasks/translation.py | 11 +++++++++-- tests/test_translation_gate.py | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/app/tasks/translation.py b/backend/app/tasks/translation.py index 9598afd..42871c9 100644 --- a/backend/app/tasks/translation.py +++ b/backend/app/tasks/translation.py @@ -58,9 +58,16 @@ _INTERRUPT_BACKOFF_MAX = 900 # correctly translated). Latin-script detection is a real statistical # probability, so a short English title Interpreter mis-labels as a European # language scores low; require it to clear this floor, else keep the original. -# Tune the floor against real titles via the Settings "Test translation" box. +# Calibrated 2026-07-09 against fresh (uncached) probes once Interpreter returned +# real langdetect confidence: genuine German detected at 1.0, while a correctly- +# detected but ambiguous latin string dipped to 0.86 — so the floor sits at 0.80, +# below that band, to keep legitimate ambiguous non-English while still rejecting +# genuinely-unsure guesses. Real langdetect also fixed the original mis-flag at +# the source (short English titles now detect as English → passthrough), so this +# floor is a safety net, not the primary fix. Re-tune via the "Test translation" +# box (send fresh text — cache hits report 1.0). _CJK_LANGS = frozenset({"ja", "ko", "zh"}) -_MIN_LATIN_CONFIDENCE = 0.90 +_MIN_LATIN_CONFIDENCE = 0.80 def _interrupt_backoff(retry_after) -> int: diff --git a/tests/test_translation_gate.py b/tests/test_translation_gate.py index c78c247..2e226b7 100644 --- a/tests/test_translation_gate.py +++ b/tests/test_translation_gate.py @@ -17,6 +17,7 @@ def test_accept_trusts_cjk_regardless_of_confidence(): def test_accept_requires_floor_for_latin(): assert _accept("de", 0.98) is True + assert _accept("de", 0.86) is True # calibrated: ambiguous-but-correct German stays assert _accept("de", _MIN_LATIN_CONFIDENCE) is True # exactly at floor assert _accept("de", _MIN_LATIN_CONFIDENCE - 0.01) is False assert _accept("fr", 0.40) is False # short mis-flag