Skip to content
clariant @ arch : ~/clariant/work/document-translation
cd ~/work

~/work/document-translation on ⎇ main [✓]❯cat case-study.md

experimenting

Private Document Translation

Research and design for a self-hosted system that translates confidential English and Mandarin documents into Indonesian, keeping the original layout. Evaluation harnesses for translation models and OCR, with confidence intervals, and local LLMs measured on our own hardware.

role
AI Engineer Intern
period
Sep 2026 – present
company
Dewaweb
status
experimenting
Python LLM evaluation OCR Qwen COMET BabelDOC

Context

The documents in scope (permits, certificates, official letters) are confidential, so cloud translation APIs are out. They arrive in English or Mandarin, often as scans with stamps, tables, and text inside images. They have to come out in Indonesian, laid out like the original. Everything has to run on hardware we control.

I’m doing the technical groundwork with my supervisor, and a teammate also commits to the repo. Each open question gets a time-boxed spike with a written verdict: a license audit, a high-level design, and a UI prototype on mock data. Only public or synthetic documents are used during development.

What I built

  • Translation-model evaluation. A reproducible harness that scores candidate models with COMET-22 on the FLORES+ benchmark (1,012 sentences per direction), with 95% bootstrap confidence intervals, pinned data and model hashes, and a power-profile gate so timing runs are comparable. On CPU, Mozilla’s Firefox Translations models beat OPUS-MT in both directions (English→Indonesian 90.6 vs 88.3, Chinese→Indonesian 86.7 vs 84.2) and run 13–15 times faster. Through a hosted API, the larger Qwen3.5-35B-A3B scores higher still (92.3 and 89.2) and translates Chinese directly instead of pivoting through English, though even its 4-bit build is too big for the 16 GB office GPU.
  • Local LLMs on our own hardware. The office PC serves Qwen 3.6 and 3.8 and Bonsai behind an API, so the same harness can score models we would actually host and measure how they behave under concurrent requests.
  • OCR evaluation. Local OCR engines (PaddleOCR, RapidOCR) compared against vision-language models (Qwen3-VL 8B, Qwen3.5-35B-A3B) on character error rate and on whether each line’s box lands on the text. Local engines read 97–100% of printed body text but fail silently under stamps (21–56% error). The vision-language models read those lines almost perfectly but misplace boxes. The resulting design uses both: local OCR for positions, a vision-language model for the lines it can’t read.
  • End-to-end PDF translation. BabelDOC is the base. Out of the box it shrank translated text to an unreadable 1.4 pt and dropped rotated text, and it crashed with a plain custom translator (an open upstream issue). About 1,500 lines of overrides brought it to a 4 pt minimum with no overlaps, and text that still can’t fit stays in the original behind a numbered marker, with its translation on a legend page.
  • Rendering check. On a synthetic page, body text can be replaced in place without disturbing an overlapping stamp or table rule, and labels baked into a chart image can be overlaid at the positions OCR finds.

What I’d point to

A verdict in each report says “partly” when the evidence is partial: six test pages don’t settle an OCR choice, and an API run doesn’t show what a 16 GB GPU can host. The open questions are listed next to the results instead of being rounded into a recommendation.

Stack

Python · uv · COMET-22 · FLORES+ · Mozilla Bergamot · OPUS-MT · Qwen · PaddleOCR · RapidOCR · BabelDOC · PyMuPDF · Docker