跳到正文
DEV Community· Sargis Mesropyan·· 1 小時前AI 評分56

Samevia 如何用確定性閘門攔截 LLM 產生的錯誤亞美尼亞語

How we stopped LLMs from writing fake Armenian: a deterministic gate for AI-translated lessons

AI 導讀

Samevia 以確定性檢查閘門篩除 AI 翻譯課程中的錯誤亞美尼亞語輸出,未通過的內容會交由下一個模型供應商處理。檢查涵蓋空白或長度異常、拉丁或西里爾字母混入,以及仍是英文原文的內容;數字加單位和原文已有的程式碼識別符則設有例外。系統按模型記錄每次翻譯結果,並在每小時成功率低於 80% 時發出警示,曾藉此發現鏈中兩個模型大多產出無效亞美尼亞語。

正文

Sargis Mesropyan

I'm building Samevia from Stepanavan, a small town in northern Armenia. It teaches whole fields of knowledge, from mathematics to psychology, as short lessons in your own language, on the web and on Android. It is free to start and works offline.

Today it has 460 lessons across 16 fields. 429 are published in English and 269 in Armenian. Every one of them was drafted and translated by LLMs. This post is about the part that made that possible without shipping garbage: a small, boring, deterministic gate.

The problem: output that looks fine to everyone except a reader

Armenian has its own alphabet. When we started translating lessons with smaller models, many outputs looked like translations to anyone who doesn't read Armenian, and were unusable to anyone who does:

  • Armenian words transliterated into Latin letters
  • Cyrillic letters mixed into Armenian words
  • English sentences left untranslated in the middle of a paragraph
  • empty or truncated leaves that still "passed"

An LLM judge did not catch these reliably. A regex did.

The gate

Every translated leaf (a heading, a paragraph, a quiz option) goes through the same checks before it is accepted:

  1. Not empty, and not suspiciously short or long compared with the source (a length-ratio window).
  2. Script purity: in an Armenian target, no Latin or Cyrillic letters leaking into Armenian text.
  3. Untranslated detection: a leaf that is still the English source is rejected.

If a check fails, the leaf is not "fixed up". It is sent to the next provider in the chain. Free-tier models go first; a paid model is only a backstop at the end. That ordering is why the product can be free.

The bugs the gate had to learn

A strict gate is only useful if it rejects the right things. Two real cases from this month:

  • Units. 5 ppm or 120 mm/yr were flagged as untranslated English. They are units, not prose, so a number followed by a unit is now allowed.
  • Code in lessons. A lesson about testing in Python contains pytest, assert and fixture. The gate rejected the Armenian translation five times as "foreign script" and the pipeline kept paying for retries on the same leaf. The fix: an identifier that appears literally in the source (in code or a diagram) is a name, not a translation failure. Each fix shipped with a negative test, so the old wrong rejection is pinned as a failing case.

What we measure

We log every translation attempt with its outcome (ok, still_invalid, script_leak, error) and the model that produced it, and alert when the hourly success rate drops below 80%. That alert is how we noticed, yesterday, that two models in the chain had started producing mostly invalid Armenian, while others were fine. Without per-model outcomes it would have looked like "translation is flaky".

Takeaways

  • For low-resource languages, a cheap deterministic check beats an expensive LLM judge for the failures that matter most.
  • Never repair a bad output in place. Reject it and let the next provider try.
  • Every false rejection is a bug with a test, not an exception in a config file.
  • Log outcomes per model, or you will blame the wrong thing.

If you read Armenian, or another language that LLMs tend to mangle, I'd value your feedback on the lessons: https://samevia.com

來源:DEV Community · dev.to