tm-rag-copilot

A small, honest demo that embeds a synthetic translation memory and term base, retrieves by meaning, translates with a local model and checks every output with deterministic QA.

简体中文:把虚构的翻译记忆(TMX)和术语库(TBX)向量化存入本地索引,按语义检索最相似的句段,用本地模型生成译文,并用确定性规则逐条做质量检查。

繁體中文:把虛構的翻譯記憶(TMX)和術語庫(TBX)向量化存入本地索引,依語義檢索最相似的句段,用本地模型產生譯文,並以確定性規則逐條進行品質檢查。

What this shows

Headline numbers

97.6%
QA pass with a real model (Qwen)80.5% with the retrieval-only baseline
82.9%
Right match in the top 10 (zh-CN filter)
58.5%
Right match first (zh-CN filter)
0
Bad JSON replies in 41 runs

Sources: eval_qwen.json: qwen2.5-coder:14b served locally, prompt v2.0, 41 gold items, 544 s wall time; eval.json: retrieval-only baseline, mock provider; eval_zhcn.json: zh-CN target-language filter.

Pipeline

TMX + TBXdata files parsetmx.py, tbx.py embed + indexMiniLM, Qdrant retrievevector, +BM25 RRF promptv1.0 text, v2.0 JSON modelmock or Qwen via Ollama QAdeterministic rules evaluaterecall@k, MRR, QA
TMX and TBX go in; segments are embedded and indexed, retrieved, prompted, generated, QA-checked and evaluated. Retrieval options: target-language filter and hybrid BM25 + RRF.

Recall@k by configuration

0.0 0.2 0.4 0.6 0.8 1.0 k=1 k=3 k=5 k=10 recall@k zh-CN filter baseline hybrid zh-CN + hybrid
Same gold set (data/gold.jsonl, 41 queries), same embedding model; only the retrieval options differ. Best measured configuration: target-lang zh-CN.

Cross-language check: 10 Chinese queries from gold_zh.jsonl searched against the English sources: recall@10 80.0%, MRR 55.9% (eval_crosslang.json).

QA by check: mock vs real model

placeholder_preservation
90.2%
100.0%
required_term_used
85.4%
97.6%
character_limit
100.0%
100.0%
forbidden_term_absent
100.0%
100.0%
number_preservation
100.0%
100.0%
tag_preservation
100.0%
100.0%

Each check has two thin bars: mock (grey bar, mock that copies the closest TM match) and Qwen (accent bar, real model). Percentages are the share of the 41 gold items passing that check; checks where the two runs differ are listed first.

From eval.json, eval_qwen.json.

Real examples

SourceClosest matchzh-CNzh-TWthOutput (Qwen)QA
New Gamequery: start a brand new playthroughui-new-game新游戏新游戏新遊戲เกมใหม่新游戏pass
Continuequery: resume my saved adventurehud-xp经验值继续游戏-เริ่มต่อ继续游戏pass
Healthquery: how much health do I have lefthud-hp生命值生命值--生命值pass
%d damage dealtquery: how much damage did I dealcombat-damage造成 %d 点伤害造成 %d 点伤害--造成 %d 点伤害pass
Health Potionquery: use a red potion in battleitem-health-potion生命药水生命药水--生命药水fail: required_term_used
Welcome to Emberveil Legends, {name}!query: welcome message shown to a new playerui-new-game@thเกมใหม่欢迎来到烬堇传说,{name}!--欢迎来到烬堇传说,{name}!pass

The zh-CN, zh-TW and th columns are the stored translations of that unit in the translation memory (a dash means the TM holds no variant in that language). The output column is what Qwen produced for the query; QA ran on the source segment.

What we tried

configurationrecall@1recall@3recall@5recall@10MRRQA pass (provider)kept
baseline51.2%68.3%73.2%80.5%61.5%80.5% (mock)no, reference
target-lang zh-CN58.5%73.2%75.6%82.9%67.5%82.9% (mock)yes, best
hybrid RRF+BM2553.7%56.1%61.0%65.8%56.3%87.8% (mock)option only, worse recall
zh-CN + hybrid53.7%58.5%61.0%65.8%56.6%87.8% (mock)no
zh queries, cross-language50.0%50.0%70.0%80.0%55.9%70.0% (mock)standing check
baseline retrieval + ollama qwen2.5-coder:14b51.2%68.3%73.2%80.5%61.5%97.6% (ollama)yes, real model run

One row per run in results/: eval.json, eval_crosslang.json, eval_hybrid.json, eval_qwen.json, eval_zhcn.json, eval_zhcn_hybrid.json.

What a production system adds

Limits