Basics · Greedy (num_beams=1) vs Beam Search (num_beams=3) · SentencePiece · Apache-2.0

Inside MarianMT DE→EN: Greedy vs Beam Search & Subwords

German syntax frequently delays finite verbs to the end of subordinate clauses (weil … entdeckt hat) and splits separable verb prefixes across an entire clause. Compare Greedy decoding (num_beams=1) against Beam Search (num_beams=3) on the exact same Xenova/opus-mt-de-en (106.02 MB WASM q8, Apache-2.0) weights, and inspect how SentencePiece segments long German compounds.

1. Live Greedy vs Beam Search Comparison

Choose a German syntax challenge or type your own sentence to compare decoding strategies:

German pushes finite verbs to the end of subordinate clauses — watch how beam search searches global English word order.
Greedy (k=1) ms–
Beam (k=3) ms–
Beam latency ratio–
Word-level changes–
NaN check–

Greedy Decoding (num_beams = 1)

Picks the highest-probability next token at every step.

Initialise Opus-MT DE→EN above to compare greedy vs beam decoding.

Beam Search (num_beams = 3)

Tracks multiple partial hypotheses to optimize whole-sentence fluency.

Beam-search output will appear here.

Word-Level Reordering & Lexical Diff (Greedy → Beam)

Strikethrough = chosen only by greedy decoding · Highlighted = preferred by beam search.

Run a comparison above to inspect the word-level diff.

2. SentencePiece Compound-Splitting Visualizer

Every German word below is decomposed using MarianMT's live 58,101-piece SentencePiece tokenizer. Compounds like Rechtsschutzversicherungsgesellschaften split into high-frequency morpheme fragments without losing meaning.

Word start (▁) Compound continuation piece (+)

Subword statistics will appear once the comparison finishes.

Waiting for live tokenization…

3. Inspect Worker Decoding & Tokenizer Code

Show the code · worker.js — compareBeams() (Greedy vs Beam in one epoch-guarded pass)
Show the code · worker.js — tokenizeSentencePiece() (live SentencePiece piece extraction)
Show the code · opus-de-core.mjs — computeWordDiff() (deterministic word-level LCS diff)