← All models

translation · text · WASM · ~470 MB

M2M100 — translate between 100 languages, directly

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.

At a glance

ModelXenova/m2m100_418M
Task / pipelinetranslation (sequence-to-sequence)
ArchitectureM2M100 — 418M-param multilingual encoder-decoder (Facebook AI)
Languages100, translated directly (no English pivot) via src_lang / tgt_lang
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~470 MB, cached after first load
LicenseMIT
Web APIsWebAssembly, Web Workers — all Baseline widely available

Run it

Choose the source and target language, type or paste text, and translate. Greedy decoding streams the output live and records real per-token timing.

Translation

See inside — language codes, tokens & 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.

src → tgt
–
Tokens in
–
Tokens out
–
Speed
–

Why it matters

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.

Use cases

Basics

Translate a phrase and swap the target language to feel the many-to-many model.

Practical

Localise UI strings and run a round-trip fidelity check to spot risky translations.

Wild

Play "telephone": chain translations across languages and watch meaning drift.

Multi-model

Translate any language into English, then have Kokoro read the result aloud.

How the API works

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.

References