Basics · Global vs Local Attention & 128/600/1200+ Tok Lab · 452.56 MB WASM q8

Alternating Global-Local Attention & Long-Context Needle-Cloze Lab

ModernBERT-Large sets global_attn_every_n_layers: 3 and local_attention: 128 across 28 layers: 10 global layers (RoPE θ=160,000) carry early directives across thousands of tokens while 18 local sliding-window layers keep quadratic cost low. Compare ~128 vs ~600 vs 1,200+ tokens directly against a 512-token truncation cliff.

1. On-device model

Initialise ModernBERT-Large above to run the 128 / 600 / 1,200+ token needle-cloze lab.

2. 28-layer global vs 128-token local sliding-window schedule

Layers 1, 4, 7, 10, 13, 16, 19, 22, 25, and 28 use full global self-attention (RoPE θ=160,000). The remaining 18 layers attend only within ±64 tokens (window 128, RoPE θ=10,000) — saving over 55% of attention operations at 1,200+ tokens without losing long-range recall.

3. Long-Context Needle-Cloze Lab (128 vs 600 vs 1,200+ tokens)

A decisive fact sits near the opening of an expanding log while [MASK] sits at the very end. Each rung runs twice: Full ModernBERT-Large RoPE (up to 8,192 tok) vs a max_length: 512 BERT truncation clip.

Full ModernBERT-Large RoPE vs 512-token truncation predictions across 128, 600, and 1,200+ tokens
Rung tokens Attn ops saved Full RoPE top guess Full target prob 512-tok clip guess 512-tok target prob Latency (full / clip) NaN
Initialise the model and run the 128 / 600 / 1,200+ token needle lab above.

4. Multi-Mask Cloze & Top-K Depth Calibration

Supports both [MASK] and <|mask|> syntax. Adjust top-k to watch probability mass accumulate across the 50,368-token BPE vocabulary.

Mask slots–
Top-1 share–
Top-k mass–
Entropy / Eff. choices–
Latency–

Inspect the needle builder & retention chart

Show the code · modernbert-large-core.mjs — buildLongContextNeedleProbe()
Show the code · modernbert-large.js — drawLengthRetentionChart()