← All models

translation · text · WASM · ~850 MB

mBART-50 — many-to-many translation from one denoising-pretrained model

mBART-50 translates directly between any pair of 50 languages — no English pivot — with a single multilingual encoder–decoder. Its twist is its upbringing: mBART was pretrained by denoising (corrupting then reconstructing monolingual text in all 50 languages, the BART objective scaled up) before it was ever taught to translate. Pick a source and target, type, and watch it translate on-device. The output language is chosen by a single forced beginning-of-sequence token, shown below.

At a glance

ModelXenova/mbart-large-50-many-to-many-mmt (ONNX build of facebook/mbart-large-50-many-to-many-mmt)
Task / pipelinetranslation (sequence-to-sequence)
ArchitecturemBART: 12-layer BART-style multilingual encoder–decoder, ~610M params; denoising-pretrained on 50 languages, then fine-tuned many-to-many
Languages50 (codes like en_XX, fr_XX, zh_CN), translated directly — target chosen via a forced BOS token
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~850 MB (encoder + merged decoder), cached after first load
LicenseMIT
Web APIsWebAssembly, Web Workers, <datalist> — all Baseline widely available

This is a large model — ~850 MB downloads once, then it's cached. On a memory-constrained phone the first load can be slow or fail; the page tells you honestly if your device can't hold it.

Run it

Search the source and target language (type any of 50 names), enter text, and translate. Greedy decoding streams the output live and records real timing. Because mBART is many-to-many, you can go straight between two non-English languages.

Translation

See inside — language codes, forced BOS token & tokens

mBART is a sequence-to-sequence translator: it encodes the source, then decodes the target one token at a time. What selects the output language is a single trick — the decoder is forced to begin with the target language's special token (forced_bos_token_id). Change the target and only that first token changes; the same input then decodes into a different language. Below are the exact mBART language codes, the real numeric BOS token id mBART used, and the token counts each side.

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

Why it matters

One model, 50 languages, any direction, entirely on-device — no per-call fees, no data leaving the tab. mBART-50 covers the widely-used languages of Europe and Asia with solid quality, and because it shares one representation across all of them you can translate between two languages that were never explicitly paired in training.

Use cases

Basics

Translate a phrase, then swap the target across 50 languages to feel the many-to-many model.

Practical

Any-to-any pairs + a round-trip fidelity check to spot where a translation drifts.

Wild

Relay translation: chain a sentence through several languages and back to the start.

Multi-model

Translate any of 50 languages 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/mbart-large-50-many-to-many-mmt",
); // downloads + caches ~850 MB once

const out = await translator("The weather is nice today.", {
  src_lang: "en_XX",   // mBART-50 language code
  tgt_lang: "fr_XX",   // French
});
// → [{ translation_text: "Le temps est agréable aujourd'hui." }]

// Under the hood, tgt_lang selects a forced BOS token id that the decoder
// must emit first — that single token is what picks the output language.

mBART-50 codes are a two-letter language plus a region tag (en_XX, zh_CN, pt_XX) — the same scheme as the original fairseq model. This page streams tokens via a TextStreamer inside a Web Worker, so decoding never blocks the interface.

References