Basics · ALiBi Long-Context Proof & Token Scaling Lab

Inside ALiBi 512-d: Truncation Blind Spot & Token Scaling

Four ~1,200-token handbooks share an identical ~1,100-token governance opening, with the decisive clause placed after token 512. Run both Full ALiBi and a 512-token truncated pass on the exact same 32.77 MB encoder, then measure real browser WASM latency across 128 → 256 → 512 → 1024 → 2048 tokens.

1. Long-context truncation blind-spot experiment

Full ALiBi ranking (up to 4,096 WASM tok)

Run comparison to rank all 4 handbooks with ALiBi.

    Truncated 512-token ranking

    Run comparison to see what disappears past 512 tokens.

      Exact tokenizer cutoff inside the target document

      Run the comparison to inspect the exact token cutoff boundary.

      2. Live token scaling lab (128 → 256 → 512 → 1024 → 2048 tokens)

      ALiBi requires zero learned positional embeddings, so the same 32.77 MB weights evaluate any sequence length. In live Chrome CPU WASM q8, sequences up to 4,096 tokens run cleanly (~69 ms @ 128 tok → ~6,059 ms @ 4,096 tok), whereas 6,144 and 8,192 tokens exceed the single-thread WASM heap (ORT error 75016480), so our worker enforces a safe 4,096-token browser ceiling.

      Measured latency curve

      Per-length diagnostics

      Live measured WASM latency and norm across token counts
      Target Exact tok Latency Tok/s L2 norm NaN
      Click "Run live 128 → 2048 token sweep" above to benchmark on this device.

      Show the code

      Show the code: WordPiece token counting, truncation preview & 4,096-tok WASM guard
      Show the code: mean-pooled feature-extraction forward pass & NaN check