Basics · Greedy (num_beams=1) vs Beam Search (num_beams=2–4) · Clitics & SentencePiece · Apache-2.0

Inside OPUS-MT ES→EN: Beam Search, Clitic Pronouns & Subword Fertility

Spanish drops subject pronouns, glues object pronouns onto verbs (dímelo = tell it to me), and puts adjectives after nouns. Compare Greedy decoding (num_beams=1) against Beam Search (num_beams=2, 3 or the config default 4) on the exact same Xenova/opus-mt-es-en (113.11 MB WASM q8, Apache-2.0) weights, then inspect how SentencePiece segments enclitic verbs, accents, and conjugations.

1. Live Greedy vs Beam Search Comparison

Choose a Spanish grammar challenge or type your own sentence to compare decoding strategies:

Spanish glues object pronouns onto imperatives and gerunds — watch how the decoder unpacks them.
Greedy (k=1) ms–
Beam (k=4) 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 ES→EN above to compare greedy vs beam decoding.

Beam Search (num_beams = 4)

Tracks multiple partial hypotheses to optimise whole-sentence fluency.

Beam-search output will appear here.

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

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

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

Per-Word Subword Fertility of the Test Sentence

Subword statistics will appear once the comparison finishes.

Waiting for live tokenization…

2. Clitic, Accent & Conjugation Subword Explorer

Each probe word is tokenized by the live 65,001-piece SentencePiece model and translated in isolation. Enclitic stacks (enviándoselo), conditional and subjunctive endings (pidiéramos), and letters like ñ / ü reveal how the shared vocabulary trades whole words for reusable pieces. The morphology column is a linguistic gloss; the pieces and English are live.

Live SentencePiece segmentation and isolated English translation of Spanish clitic, accent and conjugation probe words
Spanish word Type Morphology (gloss) Live SP pieces Live English
Initialise the model above — probes run automatically once ready.

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-es-core.mjs computeWordDiff() (deterministic word-level LCS diff)