translation · 1st compact CJK→EN neural translator · q8 · WASM · 113.11 MB · CC-BY-4.0
Opus-MT Chinese → English
University of Helsinki's OPUS-MT ZH→EN
(Helsinki-NLP/opus-mt-zh-en,
quantized to 113.11 MB INT8 ONNX in
Xenova/opus-mt-zh-en)
is a dedicated 6+6 MarianMT encoder-decoder that translates Simplified and Traditional Chinese directly into
fluent English in ~150 ms/sentence on universal CPU WebAssembly — 100% private,
zero cloud APIs, works offline after first cache.
1 · On-device model (113.11 MB q8 WASM · encoder 52.90 MB + decoder 60.21 MB)
2 · Live Chinese → English Neural Translator
Choose a Simplified or Traditional Chinese sample, type your own text, or upload a .txt /
.srt / .md file. Translation runs off the main thread in a dedicated Web Worker.
English translation
Waiting for runPrepare Opus-MT ZH→EN above to translate Simplified & Traditional Chinese locally in CPU WebAssembly.
3 · Sentence-by-Sentence Alignment & See Inside MarianTokenizer
MarianMT caps each sequence at 512 tokens. Segmenting multi-sentence Chinese paragraphs keeps
every clause inside the attention window and exposes per-sentence latency and SentencePiece subwords.
| # | Chinese segment | English translation | Tokens (in→out) | Latency |
|---|---|---|---|---|
| Run a translation above to inspect sentence-by-sentence alignment. | ||||
Real SentencePiece Subword Pieces (MarianTokenizer · 65,001 vocab)
Run a translation to inspect real MarianTokenizer SentencePiece subwords.
4 · At a Glance, Show the Code & Use-Case Ladder
| Upstream model | Helsinki-NLP/opus-mt-zh-en (Tatoeba-test.zho.eng: BLEU 36.1 · chr-F 0.548) |
|---|---|
| Browser ONNX repo | Xenova/opus-mt-zh-en (encoder_model_quantized.onnx 52.90 MB + decoder_model_merged_quantized.onnx 60.21 MB = 113.11 MB q8) |
| Pipeline task & runtime | translation · @huggingface/transformers@3.7.5 (shared pin in lib/webai.js) · CPU WASM |
| Architecture | MarianMTModel (6 encoder + 6 decoder layers, d_model=512, 8 heads, ffn=2048, swish, max_length=512, vocab_size=65001) |
| Special tokens | pad=<pad> (65000, also decoder_start_token_id), eos=</s> (0), unk=<unk> · pair baked into weights (no language-code prefix) |
| License | CC-BY-4.0 (University of Helsinki Language Technology Research Group) |
Show the code — Real Transformers.js MarianMT inference & streaming
Show the code — Chinese sentence segmentation for 512-token safety
Compare num_beams=1 vs num_beams=3 phrasing, latency, length ratio & SentencePiece tokens.
Preserve timestamps & SKUs verbatim while batch-translating Chinese subtitles or product CSVs off-thread.
Wild · Idiom (Chengyu) & Boundary Stress LabProbe isolated vs contextual Chinese idioms, Simplified vs Traditional script pairs, and split vs unsplit paragraphs.
Multi-Model · Chinese Photo OCR → EnglishChain PP-OCRv5 Mobile (21.5 MB) into Opus-MT ZH→EN (113.11 MB) to paint live English overlays onto Chinese signs.