Basics · Cross-Lingual Bitext & Context Window · 295.7 MB WASM q8 · Apache-2.0

Cross-Lingual Bitext Alignment & 128 vs 512 Context

Test the two foundational behaviours of Xenova/paraphrase-multilingual-mpnet-base-v2: 1) matching translated sentences across 10 languages & 6 scripts with Recall@1, and 2) comparing SBERT's trained max_seq_length: 128 cap against XLM-R's 512-token window.

1. On-device model

Initialise paraphrase-multilingual-mpnet-base-v2 above to run the bitext & context labs.

2. Cross-Lingual Parallel Bitext Alignment (Recall@1)

Embeds every source sentence alongside its parallel translations in different languages. Because multilingual knowledge distillation aligns meaning across scripts, true translation pairs on the diagonal should outscore every off-diagonal distractor.

Recall@1 match–
Mean true pair cos–
Mean best distractor–
Mean margin–
Latency–
NaN count–
Per-pair cross-lingual bitext alignment scores and Recall@1 matches
Pair / Lang Source sentence Parallel translation True pair cos Best distractor Hit
Run bitext alignment above to inspect pair scores.

3. Trained max_seq_length: 128 vs XLM-R 512 Budget

sentence_bert_config.json specifies max_seq_length: 128, while config.json gives XLM-RoBERTa max_position_embeddings: 514 (model_max_length: 512). Run the exact same long document and query at both limits to observe whether a late-occurring clause past token 128 gets truncated or retrieved.

Full XLM-R tokens–
Cosine @ 128 tok–
Cosine @ 512 tok–
Delta (512 − 128)–
Latency–
Context observation: Run the 128 vs 512 comparison above.

4. Inspect bitext alignment & tokenization source

Show the code · mpnet-multi-core.mjs — computeBitextAlignment()
Show the code · worker.js — embed()