Basics · [CLS] vs Mean Pooling, Drug Brand↔Generic & WordPiece Roots

Pooling & WordPiece Ablation: Why [CLS] Wins for Biomedical Entities

Unlike SentenceTransformers that average token states, cambridgeltl/SapBERT-from-PubMedBERT-fulltext self-aligns the [CLS] token (pooling: "cls") over PubMedBERT's 30,522-token uncased WordPiece vocabulary. Run live 4-condition ablations across medical synonyms, brand vs generic drug pairs, and Latin/Greek morphological root splits.

1. Load Model & Select Biomedical Ablation Pack

2. Live [CLS] vs Mean Ablation & WordPiece Telemetry

Official: [CLS] Pooling @ 512 Tokens

Run ablation to score with official [CLS] token pooling.

    Ablation: Mean Pooling @ 512 Tokens

    Run ablation to compare un-aligned token-mean pooling.

      4-Condition Separation Margin Chart

      PubMedBERT WordPiece Splits (Latin/Greek Roots) & Score Drift

      Per-term PubMedBERT WordPiece tokenization, [CLS] vs Mean cosine scores, and 512 vs 25 window comparison
      ID Role PubMedBERT WordPiece Pieces [CLS] @512 Mean @512 Δ (CLS−Mean) [CLS] @25
      Run ablation above to inspect WordPiece splits and all four pooling/window conditions.

      Show the Code

      Show the code: PubMedBERT WordPiece subword & special-token inspector (worker.js)
      Show the code: Kendall tau, Spearman rho & separation margin math (sapbert-core.mjs)