The problem
I write to English-speaking clients, mostly about embedded systems,
telemetry and backend code, and my working language is Russian. For this
kind of text, the requirements for a translator are narrow but strict:
- domain terms must be translated correctly and consistently;
- obligations must survive: the Russian "должен" has to become "must", not "should";
- numbers with units, ranges, dates and code must come out exactly as they went in;
- client text must not leave my own machines.
The hardware was two ordinary laptops with no GPU: a Ryzen 7 PRO 3700U and a
Core i7-10510U, 16 GB each.
The result is xlate, now open source under Apache-2.0:
https://github.com/oleg-kukharenko/xlate. It is a personal tool, published as
is, without support. This article describes the decisions behind it, the
numbers I measured, and what did not work.
What it does
xlate is a Linux desktop tool with two windows.
- Translator (Super+Alt+T): text selected in any application is translated when the hotkey is pressed; the direction is detected automatically. My own Russian text is translated sentence by sentence as I type and translated back, so I can check the meaning before sending.
- Correspondence (Super+Alt+C): an incoming email is cleaned of quotes and signatures and translated. A local LLM writes a summary and a list of the sender's questions, including implicit conditions. I list my key points in Russian, and the local LLM writes a full reply, which is translated into English at once.
A Rust daemon (xlated) does the work and exposes a D-Bus API. The GNOME
Shell extension and the GJS/GTK 4 windows are thin clients with no logic.
Translation runs on the work laptop. The local LLM (Gemma 4 E4B in a
llama.cpp server) and a small knowledge base (multilingual-e5-small
embeddings, SQLite with sqlite-vec) run on the second laptop, behind a
firewall, connected by a direct cable. The split exists so that the LLM does
not take CPU away from translation.
Key decisions
1. Small translation models, not an LLM
The obvious choice today would be to translate with an LLM. I measured it on
the target laptops: Qwen2.5-3B as a translator was 14 times slower than the
dedicated model EN→RU and 5.5 times slower RU→EN. It also had a worse
failure mode: it sometimes executed the text instead of translating it, for
example answering a question it was given to translate. A half-second
translation while typing is not possible with a CPU LLM.
NLLB was the other candidate. On these laptops it was 3–4 times slower than
Opus-MT tc-big. It was less accurate EN→RU on my set (chrF++ 62.2 against
66.2) and slightly more accurate RU→EN (69.6 against 68.0); speed decided.
So the translation models are Opus-MT tc-big, one per direction, quantized
to int8 with CTranslate2 and run on the CPU. A changed sentence of up to 12
words is translated in 0.47 s EN→RU and 0.56 s RU→EN (median) in the
Translator window; 13–25 words take 0.86 s and 1.00 s.
Before writing the daemon in Rust, I ran a parity spike: the same models
through the ct2rs binding and through the Python reference. The output was
identical, and the Rust process used 555 MB against 870–948 MB in Python,
about 40% less. The daemon translates the first sentence in 0.50 s, with a
peak RSS of about 580 MB.
The models were fine-tuned on a custom corpus on free Kaggle GPUs, in
several rounds. The corpus mixes domain pairs, 25–40% general language
against forgetting, human parallel texts, business mail, everyday text, and
later term pairs produced by a teacher LLM. On the development set, domain
terms translated correctly went from 80.7% / 80.1% with the base models to
90.0% in both directions. The local LLM is still used where it helps:
summaries, drafts and an "Improve" editor that proposes a polished version
of a translation, which I accept or reject.
2. Mask before you translate
Masking is the main source of quality in the pipeline. Code, URLs, formulas,
dates, sums, ranges and numbers with units are replaced by placeholders
before translation and restored afterwards, verbatim or in the target
language's notation. On a set of 18 phrases with units, ranges and ± / −
signs, all 18 were distorted before the masking rules and none after.
The same idea handles names. A glossary and a per-contact dictionary keep
names, company names and agreed terms of a conversation as they are.
Without it, "Rotterdam DC" (a distribution centre) became "District of
Columbia".
3. Must, should, may
In technical correspondence the difference between "must" and "should" is a
difference in what you have promised. For RU→EN, a modality guard compares
the obligation in the Russian source with the English output and flags one
that was softened. A "≠ meaning" mark appears when the back-translation
differs from the source. Both only warn; neither changes the text.
4. Ask an outside model without sending the email
Sometimes I need a stronger model than the one on my laptop. Two external
models are wired in: DeepSeek (ds>) and Claude (cl>). From a closed
(client) conversation, the path has four steps:
- The local LLM rewrites my question as a general technical question, without the details of the email.
- An allow-list anonymizer goes over the result. It does not try to find sensitive data; it lets through only text it recognises as safe vocabulary, and everything else (names, addresses, numbers, codes) becomes a label such as
[NAME_1]. A separate check looks for secrets (keys, passwords, tokens) and data dumps. - A preview card shows the exact text that would be sent. I can edit it, cancel it or send it. There is no automatic path around the card.
- Labels in the answer are restored locally.
From a closed conversation to the preview card takes about 30 s, mostly the
local LLM. From an open conversation (public technical topics), the question
goes out with fragments from the local knowledge base, and the answer cites
them.
On the anonymizer test sets: 0 leaks on 62 development cases, 15 held-out
cases and 4,590 bypass-matrix checks. The red-team set has 2 known misses of
68 (a name made only of common words at the start of a sentence, and a name
form with a fleeting vowel); the per-contact dictionary covers both.
Around the anonymizer there are more layers:
- an encrypted vault (gocryptfs, no root) for emails, drafts and the translation journal; while it is not mounted, nothing is written, the journal is switched off rather than redirected;
- path-based zones (
open,closed,forbidden): whether text may go to an external model is decided by the zone of its source, not by the calling code, and a new contact isclosedby default; - a sandbox without network (bubblewrap) for code that reads closed data;
- canary entities: the fictional names, companies and numbers of the test emails are searched for in logs, caches and outgoing requests after test runs, and finding one is a failure;
- a spending ledger shared by both machines, with a monthly cap; without access to the ledger there are no paid calls.
Thirty DeepSeek questions cost about 0.01 USD.
5. When the metrics stop helping
The sealed test set for EN→RU is 189 phrases, mostly from articles collected
after the training corpus was frozen, with a limit of 12 evaluations in
total, so it stays a final check and not a tuning target. On it, chrF++ went
from 53.7 with the base model to 56.2, +2.5 with a 95% bootstrap interval of
[+1.4; +3.6]. The first fine-tuned round alone gave +2.1. RU→EN moved from
66.8 to 67.9, which is not significant.
But chrF++ did not separate the later training rounds from each other,
although their term accuracy was clearly different. A blind A/B on 10–13
pairs could not separate even the first fine-tuned round from the base
model.
What did work was a terminology key of 1,384 terms. I checked a random
sample of 50 entries by hand: 45 were correct and 5 were fixed (90%); after
the fixes, the EN→RU term scores moved by 0.2–0.3 percentage points and no
earlier conclusion changed. On term evaluation pairs built around key terms,
targeted fine-tuning moved EN→RU term accuracy from 45.9% to 82.1% and RU→EN
from 56.2% to 78.9%. Model decisions now rest on the key, not on chrF++.
What went wrong
The anonymizer was too careful. In the first live runs with fictional
emails it labelled too much: about 10 of 30 external answers began with "not
enough information". Adding technical vocabulary to the allow-list cut the
labels on the same runs from 51 to 26, with no new leaks on the development
and red-team sets.
A leak through a cache. A cache audit found that the daemon kept
translations in an on-disk SQLite cache, which meant client text outside the
vault. The cache is now in memory only, and a canary test guards the fix.
An audit of outgoing requests reconstructed what was sent, where and
when, without reading the content. It found one request that included a file
from a secrets directory, because the path filter checked only the file
name. The file held no secrets, but the filter now checks every path
component.
A systemd sandbox that did not sandbox. The first network-less sandbox
used systemd-run --user -p PrivateNetwork=yes. Tested on Ubuntu 24.04, it
did not remove network access. It was replaced with bubblewrap.
Things I tried and dropped:
- Two training rounds with teacher corrections gave no measurable gain (73.3%, 73.3%, 73.9% successful) and were stopped.
- A "check meaning" feature based on the local LLM was not released: it gave 7–18% false marks against a target of a few percent.
- A cache of external answers was postponed: at ≤ 1% false matches it recognised only 14.7% of paraphrased questions.
- Idioms of business mail stay wrong after training ("over the air" was translated as "go on air").
Results
Measured on the two laptops, CPU only, with the fine-tuned models. How each
number was measured is in docs/evaluation.md.
| What | Result |
|---|---|
| Changed sentence ≤ 12 words, median | 0.47 s EN→RU, 0.56 s RU→EN |
| Domain terms correct (key of 1,384 terms) | 90% both directions (base about 80%) |
| Targeted fine-tuning, term pairs | EN→RU 46% → 82%, RU→EN 56% → 79% |
| Sealed set EN→RU, chrF++ | 53.7 → 56.2, +2.5 [+1.4; +3.6] |
| Phrases with numbers and units distorted | 18 → 0 |
| Anonymizer | 0 leaks on 62 + 15 cases and 4,590 bypass checks; 2 known misses of 68 in the red team |
| Assistant evals on the assembled system | 0 critical failures, 0 leaks, real local model |
| Email summary / reply draft, local LLM on CPU | 25–64 s / 32–105 s |
| Gemma 4 E4B on the second laptop | about 6.3 tokens/s |
| Knowledge-base search | Recall@3 0.84, about 140 ms |
| External model cost | about 0.01 USD for 30 DeepSeek questions |
| Automated checks | 482 test functions (233 Rust, 249 Python), 101 headless window checks, local CI of about 40 steps |
Configuration is data: every setting, prompt and interface string lives in
YAML under config/, with JSON Schemas generated from the Rust types and the
same loader in Rust and Python, checked for parity in CI. A CI guard rejects
hard-coded addresses, paths, model names and keys in the code.
Limits
- Linux with GNOME Shell 46 only, English ↔ Russian only. The masking, the modality guard, the anonymizer lexicon and the prompts are written for this pair.
- A personal tool. It is built for one user on their own machines. There is no multi-user mode, no server deployment and no external security audit. It is published as is, without support: issues and feature requests are not handled. Fork it and change what you need.
- Not published: the fine-tuned weights, the training corpus, the terminology key, the sealed test sets and the held-out eval cases. The corpus includes texts that cannot be redistributed, and a test set loses its value once seen. The training and evaluation scripts are published.
- The local LLM on a CPU is slow for long replies (up to 105 s) and sometimes misses a key point.
- The anonymizer rules and the masking were tuned on fictional emails; there is no held-out set of real mail. An unusual form of sensitive text may still pass; the preview card is the last check, and it depends on the user reading it.
- The second machine sees client text in clear and must be trusted and firewalled. While the vault is mounted, the user's other processes can read it. Approved text is processed under the external provider's terms.
- Two machines are assumed. One machine with 16 GB can run both parts, but the LLM then competes with translation for the CPU.
Trying it
The quick start builds the daemon with the public base Opus-MT models and
translates from the command line. It needs no GNOME and no LLM, but it does
need Linux x86-64, Python 3.12, cmake, a C++ compiler, rustup, about 15 GB of
free disk and 4 GB of free RAM.
git clone https://github.com/oleg-kukharenko/xlate && cd xlate make demo scripts/xlate translate "The gateway must buffer telemetry for at least 60 minutes." On a clean Ubuntu 24.04 container with two build jobs, the whole demo took
about an hour, almost all of it compiling CTranslate2 and oneDNN.
With the base models, term accuracy is that of the base model (about 80% on
my key), not of the fine-tuned one. Masking, the modality guard and the
back-translation work the same.
Repository: https://github.com/oleg-kukharenko/xlate (Apache-2.0).
I take on paid embedded, backend and applied ML projects: Upwork, info@starflow.team.


