Skip to content
AmerAlreyahiPublic

Repository files navigation

OptimaMT

DOI models: CC BY 4.0 code: MIT pairs: 51 ONNX Runtime: 1.31.1 FLORES-200: identical output

OptimaMT is a set of free translation models that run locally, on your own computer or in the browser: 51 translation directions built from the University of Helsinki's OPUS-MT models and optimized for ONNX Runtime. Same translations, about half the memory in fast mode, and a drop-in replacement: swap the model name and you're done.

ONNX Runtime's fast mode at half the memory: 2.3–2.5× faster than the default, same translations.

Memory against speed

Fast mode used to cost double memory; OptimaMT keeps it fast and light. Medians of 5 reference pairs.

How it works

Same translations: on FLORES-200 devtest all 51 pairs give identical output, so identical BLEU.

BLEU, original vs OptimaMT

Full technical report (PDF): OptimaMT-Technical-Report.pdf · more charts, the browser results and every number: REPORT.md · interactive results and a live demo: OptimaMT/results

Used in production

  • OpenCircle, a desktop screen translator for Windows and Linux, ships these models since v0.1.4.

Quick start

import { pipeline } from "@huggingface/transformers";

const translator = await pipeline("translation", "OptimaMT/de-en", {
  dtype: "q8",
  session_options: { extra: { session: { disable_quant_qdq: "1" } } }, // fast mode
});
const [out] = await translator("Der Leuchtturm steht an der Küste.");
console.log(out.translation_text); // The lighthouse is on the coast.
pip install onnxruntime sentencepiece numpy huggingface_hub
python scripts/translate.py OptimaMT/de-en "Der Leuchtturm steht an der Küste."

Verify it yourself

pip install -r requirements.txt
python scripts/convert.py en-ar   # rebuilds the decoder from Xenova's file: byte-identical to ours
python scripts/verify.py en-ar    # same token ids as the original, both session settings

Models

All 51 repos: the OptimaMT collection, named OptimaMT/<source>-<target>.

From To
en ar · de · es · fr · hi · id · it · nl · pt · ru · uk · vi · zh
es ar · de · en · fr · it · ru
fr ar · de · en · es · ru
ar de · en · es · fr
ru en · es · fr · uk
de en · es · fr
it en · es · fr
nl en · fr
uk en · ru
zh · ja · pl · hi · id · vi · th · ko · pt en

en-ar, en-zh, fr-ar and es-ar take a target token first (>>ara<<, >>cmn_Hans<<); use transformers.js 3.x for these.

Licence

Models: OPUS-MT (University of Helsinki), ONNX exports by Xenova, modified; CC BY 4.0 (NOTICE). Code: MIT (LICENSE).