use case · basics · token-classification · WASM q8 · 110.84 MB · MIT

Inside Uncased WordPiece BIO Decoding

See two defining mechanics of dslim/bert-base-NER-uncased live: how aggregation_strategy (none vs simple vs first) merges ## WordPieces into B-/I- entity spans, and why Original-Case, all-lowercase, and ALL-CAPS inputs produce identical token IDs and logits.

1 · Sentence & model loader

2 · Side-by-side aggregation_strategy comparison (none vs simple vs first)

Because Transformers.js 3.7.5 returns per-WordPiece predictions with ignore_labels: [], we compare three real decoding strategies on the exact same forward-pass tokens and softmax probabilities:

none · Raw WordPieces

No ## folding or BIO span merging — subwords appear individually.

Run probe to inspect.

simple · BIO Span Merge

Folds ## pieces into whole words and merges consecutive B-/I- runs.

Run probe to inspect.

first · First Subword Wins

Assigns each word the label & score of its leading WordPiece, then BIO-merges.

Run probe to inspect.

WordPiece boundary anatomy

Run the probe above to inspect WordPiece splits.

3 · Original-Case vs lowercase vs ALL-CAPS Case-Invariance Test

BertTokenizer runs with do_lower_case: true (verified on Xenova/bert-base-NER-uncased), so Original-Case, all-lowercase, and ALL-CAPS strings map to bit-identical input_ids and identical output logits.

Case-invariance verification across Original, lowercase, and ALL CAPS
Variant WordPieces Entities input_ids identical? Max |Δlogit| Span parity Latency
Run the probe to verify case invariance.

4 · CoNLL-2003 9-tag BIO schema (config.json id2label)

Exact 9 id2label entries from Xenova/bert-base-NER-uncased config.json
IDBIO TagMeaning
Show the code — bert-ner-core.mjs: analyzeCaseInvariance() (input_ids + logit delta check)
Show the code — bert-ner-core.mjs: bioMerge() (B-/I- WordPiece span merging)