use case · basics · inside MarianMT ZH→EN · q8 WASM · 113.11 MB · CC-BY-4.0

Inside MarianMT ZH→EN: Greedy vs Beam Search & SentencePiece

Run the exact same Chinese sentence through Greedy decoding (num_beams=1) and Beam Search (num_beams=2..4) back-to-back on-device. Measure the real latency cost per beam, highlight phrasing changes word-by-word, and inspect the exact MarianTokenizer SentencePiece CJK subwords and length ratios.

1 · Opus-MT ZH→EN worker (113.11 MB q8 WASM · auto-inits from cache)

2 · Live Greedy vs Beam Search Comparison

Select a Chinese test sentence

Prepare Opus-MT ZH→EN above to compare Greedy (num_beams=1) vs Beam Search live on CPU WASM.

Greedy Decoding (num_beams=1)

—

Latency: — · Output tokens: —

Beam Search (num_beams=3)

—

Latency: — · Output tokens: —

Measured Decoding Latency & Throughput (CPU WASM)

Source tokens—
Chars / token—
Token ratio (out/in)—
Char ratio (EN/ZH)—
Word overlap—
Beam slowdown—

3 · SentencePiece CJK Subword Breakdown & Show the Code

Helsinki-NLP/opus-mt-zh-en uses a joint 65,001-entry SentencePiece vocabulary (spm32k source + target, <pad>=65000, </s>=0). Watch how Chinese multi-character compounds pack into single subword IDs while rare words split into single characters.

Run a comparison above to inspect real SentencePiece subwords and IDs.

Show the code — Real in-worker Greedy vs Beam Search comparison
Show the code — Chinese sentence boundary & clause chunking

Weights: Helsinki-NLP/opus-mt-zh-en → Xenova/opus-mt-zh-en (113.11 MB q8 ONNX), licensed under CC-BY-4.0.