Measuring emoji coverage without mistaking a short count for support
Probe actual emoji and their ASCII escape spellings; print tokens and unknown rate rather than inferring semantic support from count
Verified: 2026-10-05. Emoji coverage is not established by a short token sequence. For the pinned files below, a one-token result can be [UNK], while a longer result can contain only known tokens assembled from ASCII letters, digits, and punctuation. The useful measurement is to encode the actual emoji, print the content tokens and offsets, and report the share of content positions occupied by [UNK]. Literal ASCII escape spellings must be tested separately; if an application decodes them before tokenization, the tokenizer receives an actual emoji rather than escape text. The exact token rows are intentionally not embedded; local execution supplies them.
This procedure applies to google-bert/bert-base-uncased@86b5e0934494bd15c9632b12f734a8a67f723594 and google-bert/bert-base-multilingual-cased@3f076fdb1ab68d5b2880cb87a0886f315b8146f8, using transformers==4.56.2 and AutoTokenizer with use_fast=True. It does not transfer token counts to another model, checkpoint, tokenizer revision, or dependency version.
Define the measurement
For these BERT wrappers, content tokens are IDs returned with add_special_tokens=False. A model-input token is an ID returned with add_special_tokens=True; that path adds the tokenizer’s [CLS] and [SEP], so its length is not the number of pieces representing the submitted text. The probe reports the unknown rate as the share of content positions occupied by [UNK]. This denominator is token positions, not source characters, Unicode code points, UTF-8 bytes, or model-input positions. Padding and truncation remain disabled so batching and length limits cannot alter the observations.
Fast-tokenizer offsets show which Python character span each content token covers. They help distinguish several ASCII pieces from pieces attributed to an actual code-point sequence. The assertions also require the model-input IDs to be exactly the content IDs enclosed by the pinned tokenizer’s CLS and SEP IDs, with special_tokens_mask marking only those positions. Thus the framing convention is checked rather than hidden in a total length.
Run the pinned probe
Use an environment containing the exact Transformers release. The script contains every probe, retrieves the files at the full commits, prints tokens, offsets, model-input tokens, and unknown rates, and deliberately asserts no lexical outcome. An assertion about the expected number of pieces would replace the diagnostic with another hard-coded assumption.
from importlib.metadata import version as package_version
from transformers import AutoTokenizer
TRANSFORMERS_PIN = "4.56.2"
installed_transformers = package_version("transformers")
assert installed_transformers == TRANSFORMERS_PIN, (
f"Install transformers=={TRANSFORMERS_PIN}; "
f"found {installed_transformers}."
)
print(
f"transformers={installed_transformers}; "
f"tokenizers={package_version('tokenizers')}"
)
actual_emoji = "😀"
zwj_emoji = "👩🏽💻"
def escape_spellings(text):
wide_escape = text.encode("unicode_escape").decode("ascii")
utf16_digits = iter(text.encode("utf_16_be").hex())
utf16_escape = "".join(
"\\u" + high + low
for high, low in zip(utf16_digits, utf16_digits)
)
return wide_escape, utf16_escape
wide_escape, utf16_escape = escape_spellings(actual_emoji)
PROBES = (
("actual emoji", actual_emoji),
("actual multi-codepoint ZWJ sequence", zwj_emoji),
("literal ASCII wide escape spelling", wide_escape),
("literal ASCII surrogate-pair spelling", utf16_escape),
)
assert not actual_emoji.isascii()
assert not zwj_emoji.isascii()
assert wide_escape.isascii()
assert utf16_escape.isascii()
assert actual_emoji not in (wide_escape, utf16_escape)
PINNED = (
(
"google-bert/bert-base-uncased",
"86b5e0934494bd15c9632b12f734a8a67f723594",
),
(
"google-bert/bert-base-multilingual-cased",
"3f076fdb1ab68d5b2880cb87a0886f315b8146f8",
),
)
for MODEL_ID, FULL_COMMIT in PINNED:
tokenizer = AutoTokenizer.from_pretrained(
MODEL_ID,
revision=FULL_COMMIT,
use_fast=True,
)
assert tokenizer.is_fast, f"Expected a fast tokenizer for {MODEL_ID}"
print(f"\n{MODEL_ID}@{FULL_COMMIT}")
for label, text in PROBES:
content = tokenizer(
text,
add_special_tokens=False,
padding=False,
truncation=False,
return_offsets_mapping=True,
)
model_input = tokenizer(
text,
add_special_tokens=True,
padding=False,
truncation=False,
return_special_tokens_mask=True,
)
content_ids = content["input_ids"]
model_ids = model_input["input_ids"]
content_tokens = tokenizer.convert_ids_to_tokens(content_ids)
model_tokens = tokenizer.convert_ids_to_tokens(model_ids)
assert content_ids, f"Unexpected empty content encoding for {label!r}"
non_unknown_specials = (
set(tokenizer.all_special_ids) - {tokenizer.unk_token_id}
)
assert not set(content_ids).intersection(non_unknown_specials)
assert model_ids == (
[tokenizer.cls_token_id]
+ content_ids
+ [tokenizer.sep_token_id]
)
assert model_input["special_tokens_mask"] == (
[1] + [0] * len(content_ids) + [1]
)
unknown_count = content_ids.count(tokenizer.unk_token_id)
unknown_rate = unknown_count / len(content_ids)
if unknown_count:
observation = "[UNK] present; not successful decomposition"
elif len(content_ids) > 1:
observation = "multiple known tokens; inspect the source span"
else:
observation = "one known token; lexical presence only"
codepoints = " ".join(hex(ord(char)) for char in text)
print(f" {label}")
print(f" source={text!r}; code_points={codepoints}")
print(f" content ({len(content_ids)}): {content_tokens!r}")
print(f" offsets: {content['offset_mapping']!r}")
print(
f" unknown: {unknown_count}/{len(content_ids)}; "
f"rate={unknown_rate}"
)
print(f" observation: {observation}")
print(f" model input ({len(model_ids)}): {model_tokens!r}")
print(f" special mask: {model_input['special_tokens_mask']!r}")
Interpret the rows
Read the rows separately for each model. Begin with the actual-emoji probe. If its only content token is [UNK], the sequence is short but lexically unknown, and every content position contributes to the unknown rate. If its only token is not [UNK], the tokenizer emitted an in-vocabulary token and no content position is unknown, but that still says nothing about the model checkpoint’s understanding of the emoji. If several non-[UNK] tokens appear, inspect their offsets before labeling the lexical result as atomic or fragmented.
The multi-code-point probe places a skin-tone modifier and a zero-width joiner between a woman emoji and a laptop emoji. A single [UNK] may cover the whole span, in which case the correct observation is unknown fallback, not successful decomposition. Alternatively, the tokenizer may emit several known pieces with no [UNK]; that is known-token fragmentation of the submitted sequence, not proof that the model treats it as one unit. A user-perceived emoji, a Unicode code point, and a tokenizer token are different units.
The literal-text probes are generated from the actual emoji: one uses Python’s wide escape, and the other spells its UTF encoding as a surrogate pair. The script passes those ASCII strings unchanged. If they produce only known tokens, the unknown rate applies to backslashes, letters, and digits: no emoji code point reached that tokenizer call. If upstream JSON, shell, template, or application logic decodes either spelling first, rerun the test after that boundary with repr or code-point logging. Otherwise, a clean escape-string result can hide an earlier conversion into the actual emoji.
The rate also needs careful reading. A single [UNK] covering many code points contributes only its own content position, while a long sequence of known pieces can make a small number of unknown positions look minor in a position-based rate. That is not a character-coverage ratio. Use the printed code-point sequence and offsets alongside the rate, or define a separate span-weighted metric for a different question. Never merge unknown fallback and fragmentation into one “unsupported” bucket: unknown means the content path selected [UNK]; fragmentation of an actual submitted sequence means multiple non-unknown content tokens were emitted.
Limitations
These are lexical observations, not semantic support measurements. The tokenizer files establish normalization, WordPiece vocabulary, and tokenization structure; they do not establish what a model’s embeddings or downstream behavior mean. A semantic claim would require a separate, controlled evaluation against a named model checkpoint and is outside these references. The four probes also cannot certify corpus-wide emoji coverage: they are regression cases, not an emoji inventory.
Fast-tokenizer backend details and preprocessing remain part of the local test environment. The script prints both the Transformers and tokenizers versions, but the evidence boundary fixes Transformers, not an independently reproduced backend build. Unicode handling before Python or before AutoTokenizer can also change the source string. Treat any count as valid only for the displayed input representation, exact model revision, dependency environment, and tokenization settings.
Re-check changes
Re-check whenever either pinned tokenizer file or a tokenizer dependency changes. The evidence boundary is the pinned uncased tokenizer.json, the pinned multilingual tokenizer.json, and the Transformers 4.56.2 tokenizer API. For this site, each pinned JSON file is the version authority for its vocabulary and normalization settings.
Keep the probe strings and add_special_tokens choices unchanged. Resolve a replacement model revision to a full commit, install the intended Transformers version, record the installed tokenizers version, and run both models again. Compare token strings, IDs if needed, offsets, special-token masks, content lengths, and unknown rates. Review changes to the JSON’s vocabulary, normalizer, pre-tokenizer, and post-processor rather than accepting a new headline count. If only the dependency changed, hold both tokenizer commits fixed; if only a tokenizer file changed, hold the environment fixed. That isolation identifies whether an observation came from pinned data or execution machinery. Re-run the assertions before publishing a revised interpretation, and retain both the old and new provenance in the change record.
Sources
- google-bert/bert-base-uncased tokenizer.json at 86b5e093
Pinned WordPiece vocabulary and normalization settings for the English uncased model.
- google-bert/bert-base-multilingual-cased tokenizer.json at 3f076fdb
Pinned WordPiece vocabulary and normalization settings for the multilingual cased model.
- Hugging Face Transformers v4.56.2 tokenizer API
Versioned reference for encoding options, output fields, and fast-tokenizer alignment methods.
Token counts in this article were produced by the tokenizers pinned on the sources page and are checked by the site's test suite. If a count ever stops matching the pinned vocabulary, the build fails.