Skip to content

sentence-similarity · feature-extraction WASM int8 · 13.7 MB 768-d · 6 shared ALBERT layers Apache-2.0

paraphrase-albert-small-v2

Parameter-shared 6-layer ALBERT sentence encoder (sentence-transformers/paraphrase-albert-small-v2) that maps paraphrases and queries into 768-dimensional L2-normalized mean-pooled vectors in just 13.65 MB on-device with explicit int8 quantization.

768-d Paraphrase Similarity & 2D PCA Workspace

Download the 13.7 MB int8 ALBERT model above (or let cached weights auto-initialise) to compute live 768-d paraphrase similarities.

Backend / dtypeWASM · int8
Latency–
Output Tensor–
L2 Norm (mean)–
Top-1 Match–
Max Tokens / 100–
Non-finite–

Semantic Nearest-Match Inspector

Click any match to inspect its vector

Interactive 2D PCA Scatter (768-d → 2D)

Awaiting embeddings…

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)

Mean-pooled + L2-normalized

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

Anchor Q

SentencePiece Unigram Tokens

vocab_size: 30,000 · [CLS]=2 · [SEP]=3
paraphrase-albert-small-v2 architectural breakdown (verified from Xenova/paraphrase-albert-small-v2/config.json)
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

Verified model card metadata and browser delivery specification
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.

Use-case ladder

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