translation · text · WASM · ~470 MB
Most translation models go through English. M2M100 is many-to-many: it translates
straight from any of 100 languages to any other, set with a source and target
lang code. Pick two languages, type, and watch the translation stream in — all on-device.
| Model | Xenova/m2m100_418M |
|---|---|
| Task / pipeline | translation (sequence-to-sequence) |
| Architecture | M2M100 — 418M-param multilingual encoder-decoder (Facebook AI) |
| Languages | 100, translated directly (no English pivot) via src_lang / tgt_lang |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~470 MB, cached after first load |
| License | MIT |
| Web APIs | WebAssembly, Web Workers — all Baseline widely available |
Choose the source and target language, type or paste text, and translate. Greedy decoding streams the output live and records real per-token timing.
A translator is a sequence-to-sequence model: it encodes the source, then decodes the target one
token at a time. What actually drives it is the pair of language codes — change tgt_lang
and the same input produces a different language. Here are the exact codes used, the token counts on
each side, and how fast it decoded.
On-device translation means you can localise, understand, or bridge languages without sending a single word to a server — private, offline-capable, and free of per-call fees. One 470 MB model covers 100 languages in every direction.
Translate a phrase and swap the target language to feel the many-to-many model.
Localise UI strings and run a round-trip fidelity check to spot risky translations.
Play "telephone": chain translations across languages and watch meaning drift.
Translate any language into English, then have Kokoro read the result aloud.
Translation is one pipeline call; the language pair is set per call:
import { pipeline } from "@huggingface/transformers";
const translator = await pipeline(
"translation",
"Xenova/m2m100_418M",
); // downloads + caches ~470 MB once
const out = await translator("Hello, how are you?", {
src_lang: "en", // source language code
tgt_lang: "fr", // target language code
});
// → [{ translation_text: "Bonjour, comment allez-vous ?" }]
Change tgt_lang to any of the 100 codes and the same input translates to that language —
no separate model per pair. This page streams tokens via a TextStreamer inside a Web
Worker so the UI stays responsive.