Skip to content

basics · pooling ablation & tokenizer lab 1_Pooling: mean_tokens = true SentencePiece 30,000 Unigram

Pooling Lab (Mean vs CLS vs Unnormalized) & SentencePiece

Every run executes three real on-device passes over the same sentences — official pooling: "mean", normalize: true, untrained pooling: "cls", and raw unnormalized normalize: false — so you can measure why 1_Pooling/config.json mandates mean pooling and inspect ALBERT's exact ▁ SentencePiece subword splits.

Three-Mode Pooling & Sequence-Limit Lab

Download or auto-initialise paraphrase-albert-small-v2 to run the live 3-pass pooling comparison.

Mean Margin (+ vs −)–
CLS Margin (+ vs −)–
Kendall τ (Mean vs CLS)–
Kendall τ (Mean vs Raw Dot)–
Unnorm L2 Norm Range–
3-Pass Total Time–

Mean (Official) vs CLS Cosine Similarity

768-d normalized vectors

SentencePiece Subword Breakdown

▁ word-start · yellow = continuation · strikethrough = truncated

ALBERT uses a 30,000-piece SentencePiece Unigram model ([CLS]=2, [SEP]=3, <unk>=1, <pad>=0). Rare technical terms split into multiple continuations and inflate sequence length toward the 100-token SBERT cutoff.

Exact 3-pass pooling telemetry: Mean (L2-norm) vs CLS (L2-norm) vs Unnormalized Mean Dot Product
ID Topic Mean Cos (#Rank) CLS Cos (#Rank) Raw Dot (#Rank) Raw L2 Norm Tokens Sentence

Why 1_Pooling/config.json forbids CLS pooling

During Sentence-Transformers contrastive training, the loss is computed exclusively on the attention-masked mean of all final-layer token embeddings (pooling_mode_mean_tokens: true) and L2-normalized before cosine scoring. The [CLS] token (ID 2) receives no direct pooling supervision for sentence similarity, and skipping L2 normalization allows longer or higher-norm sentences to dominate raw dot products regardless of semantic fit.

Show the code — SentencePiece Unigram token & limit inspection
Show the code — Mean vs CLS vs Unnormalized rank & margin comparison