Download the 13.7 MB int8 ALBERT model above (or let cached weights auto-initialise) to compute live 768-d paraphrase similarities.
Interactive 2D PCA Scatter (768-d → 2D)
Diamond = Anchor Q · Shapes/colors = semantic groups · Select any point or match to inspect SentencePiece tokens and 768-d distribution below.
Pairwise Paraphrase Similarity Matrix (N × N Cosine)
See inside — ALBERT parameter sharing & 768-d embeddings
Standard BERT-base stores 12 distinct Transformer layers (~110M parameters).
ALBERT (A Lite BERT) slashes parameter count in two ways:
factorizing the 30,000-piece SentencePiece vocabulary embedding into a narrow
128-d table projected up to 768-d, and sharing a single
num_hidden_groups: 1 Transformer block across all 6 recurrent
layers. Passing explicit dtype: "int8" fetches the
11.38 MB onnx/model_int8.onnx graph instead of the
39.73 MB default model_quantized.onnx — cutting download weight
by 28.35 MB (3.49× smaller).
Selected 768-d Vector Distribution
SentencePiece Unigram Tokens
| Component | Verified Configuration | Practical Impact in Browser |
|---|
Show the code — worker.js explicit int8 model initialisation
Show the code — worker.js 768-d embedding & token extraction
At a glance
| Upstream model | sentence-transformers/paraphrase-albert-small-v2 (Sentence-Transformers v2 trained on 13 paraphrase & QA corpora) |
|---|---|
| Browser ONNX repo |
Xenova/paraphrase-albert-small-v2
→ onnx/model_int8.onnx
|
| Task & pipeline | sentence-similarity via pipeline("feature-extraction", "Xenova/paraphrase-albert-small-v2", { device: "wasm", dtype: "int8" }) + { pooling: "mean", normalize: true } |
| Architecture | AlbertModel · 6 parameter-shared layers (num_hidden_groups: 1), 12 heads, factorized 128 → 768 embedding, 3,072 GELU FFN, 30,000 SentencePiece Unigram vocab |
| Quantization & size | int8: 13.7 MB (exact 13,651,443 B = 13.65 MB decimal: 11.38 MB onnx/model_int8.onnx + 2.27 MB tokenizer.json + configs; avoids 39.73 MB default model_quantized.onnx) |
| Sequence & output | 768-d unit-norm float32 vector per text · trained max_seq_length: 100 (ALBERT positional ceiling 512) · special IDs: <pad>=0, <unk>=1, [CLS]=2, [SEP]=3, [MASK]=4 |
| Runtime & backend | Shared ../../lib/webai.js (Transformers.js 3.7.5) · CPU WASM inside a FIFO module Web Worker · Web APIs: WebAssembly, Web Workers, Cache Storage, SVG DOM (all Baseline) |
| License | apache-2.0 (Apache License 2.0, commercial-safe) |
Why parameter-shared ALBERT matters on the web
Full 768-d sentence encoders usually cost 90–140 MB even at 8-bit quantization.
paraphrase-albert-small-v2 delivers full 768-d paraphrase
vectors inside a 13.7 MB first-visit budget — small enough for mobile
browsers, offline PWAs, and instant client-side search without sending customer tickets or
private notes to a third-party embedding API.
- Zero-egress ticket deduplication — cluster duplicate support requests and FAQs directly in an agent's browser tab.
- Local semantic autocomplete — match phrasing variations ("master password" ↔ "recovery passphrase") offline with ~70 ms WASM latency.
- Fast Stage 1 retrieval — recall Top-K paraphrase candidates before passing a tight shortlist to a cross-encoder reranker.
Use-case ladder
Basics · Pooling & SentencePiece
Run mean vs CLS vs unnormalized pooling side-by-side and inspect live SentencePiece subword pieces and the 100-token SBERT window.
Practical · Duplicate Ticket Clusters
Upload CSV/JSON support queues, process off-main-thread with Pause/Resume/Cancel, tune clustering thresholds live, and export OWASP-safe CSV/JSON.
Wild · Paraphrase Robustness Arena
Stress-test word-order swaps, negation flips, keyboard typos, entity swaps, and lexical-overlap traps to expose real bi-encoder strengths and blindspots.
Multi-model · Retrieve → Rerank
Chain Stage 1 ALBERT (13.7 MB int8) → Stage 2 MS MARCO MiniLM-L-6-v2 cross-encoder (23.9 MB q8) in 37.6 MB total with a live rank-shift bump chart.
How the API works
import { pipeline } from "@huggingface/transformers";
// Explicit dtype: "int8" downloads 11.38 MB onnx/model_int8.onnx instead of 39.73 MB model_quantized.onnx
const extractor = await pipeline(
"feature-extraction",
"Xenova/paraphrase-albert-small-v2",
{ device: "wasm", dtype: "int8" },
);
// Matches 1_Pooling/config.json: pooling_mode_mean_tokens = true
const output = await extractor(
[
"How do I reset my forgotten recovery passphrase?",
"Steps to recover access when you lose your vault passphrase.",
],
{ pooling: "mean", normalize: true },
);
// output.dims === [2, 768] — dot product of unit rows equals exact cosine similarity