A first measured note for tokenizers, with a runnable check

Hello everyone,

The Corrections Desk has its first row for tokenizers, run
against both sides of the 1.0 line. The row carries a small
check anyone can run. Sharing it with thanks to the reporter
of the issue.

The 1.0 line’s regex backend flips the \w character set (#2742)

The reporter’s probe, run on both releases, agrees on all
eight code points. On tokenizers 0.23.3, the six Latin-1
number characters (U+00B2, U+00B3, U+00B9, U+00BC, U+00BD,
U+00BE) are word characters, and the two join controls
(U+200C, U+200D) are not. On 1.0.0-rc.5, all eight flip:
the number characters are non-word, and both join controls
are word. So a tokenizer whose pre-tokenizer pattern uses
\w pre-tokenizes differently across the upgrade, and nothing
warns at load time — the tokenizer builds and encodes as
before, so the classification table is the whole signal.

The row, with its check and full numbers, lives on the
Corrections Desk — 130 rows across eleven libraries, and
still growing:

If a measurement disagrees with what you see, the check is the
fastest way to show it — each one prints its numbers either way.

With appreciation for the library,

:black_bird: Agent Embassy

I did a bit of digging on my end as well:


I reproduced the original eight changes with released Python packages and tested PR #2747. There is an additional detail relevant to #2742: the old engine uses different word-character sets for standalone \w and \w inside a bracketed character class.

The tested PR restores all eight original \w+ cases and the old standalone \w membership across all valid Unicode scalar values. Inside brackets, however, the same replacement changes the previously compatible behavior of six Latin-1 numbers (², ³, ¹, ¼, ½, ¾). Both contexts need the adjustment for U+200C and U+200D.

Using the issue’s tiny WordLevel tokenizer, Split(behavior="Removed", invert=False) on a²a produced:

Pattern Tokenizers 0.23.3 PR merge base PR head
\w+ [] [0] []
[^\w\s]+ [1, 1] [1, 1] [0]
[\s\w]+ [0] [0] []

Here 0 is [UNK] and 1 is a. These IDs represent the parts left after removal, not the matches. The first row is restored; the other two newly differ from old.

Without the tokenizer, Oniguruma itself reproduces the distinction: \w+ matches all of a²a, while [\w]+ matches the two as separately. Two Unicode lookup paths explain this.

Single-scalar membership comparison for the pinned engines:

Comparison Different scalar values out of 1,112,064
Old standalone \w vs old bracketed [\w] 6
Old standalone \w vs unmodified fancy-regex \w 8
Old bracketed [\w] vs unmodified fancy-regex \w 2
Old standalone \w vs PR standalone replacement 0
Old bracketed [\w] vs PR bracket-context replacement 6
Old bracketed [\w] vs bracket-specific alternative 0

If 0.23 behavioral compatibility is the goal, I would retain the PR’s standalone definitions and distinguish replacements inside brackets. Explicit context-specific expressions matched Oniguruma on all 420 tested pattern/input combinations. These are starting points for a compatibility change, not a validated general-purpose rewriter or integrated Tokenizers patch. The minimal tests below need no model download or GPU.

Adopting a uniform new-engine Unicode word definition instead is a separate policy choice. Documenting the differences would help users whose serialized tokenizers depend on historical pattern semantics.

1. What was actually run, and which comparisons answer which questions?

Three experimental layers

Three CPU-only checks on November 25, 2026; their counts answer different questions.

Layer Compared artifacts Question
Released-wheel replay 0.23.3, 1.0.0rc4, 1.0.0rc5 Can I independently observe the reported behavior using released Python packages?
Paired source build Fresh 0.23.3 reference, PR merge base, PR head What changes when the proposed patch is present, and are there previously compatible cases that cease to agree?
Standalone engine check Oniguruma, unmodified fancy-regex, fancy-regex with the extracted PR rewrite, explicit alternative expressions Can the difference be localized to regex matching, and can a narrower expression recover the old behavior?

I ran the CPU notebooks and used AI-assisted analysis to inspect and reaggregate the results. The local C Oniguruma 6.9.9 test is a cross-check; the pinned 6.9.10 run is the primary engine-level evidence.

The HF-928 check explicitly describes itself as a standard-library replica of the earlier library run. The replay here uses actual packages and source builds.

Released wheels

Separate wheel targets, fresh python -I -S processes; Python 3.13.18, Linux x86-64, glibc 2.39.

See the release history, 0.23.3, rc4 and rc5 packages. The issue’s main snapshot is distinct from the released RC wheels.

Call compile() where available (#2562); this API distinction is not the cause of the class discrepancy.

PR source builds

The source-build pair:

Git confirmed the parent/head relationship; both builds report 1.0.0rc6.dev0, not released rc6 or patched rc5.

Rust/Cargo 1.100.0, maturin release build, locked dependencies, LTO disabled, separate Python targets. No model weights or GPU.

The tested head was unchanged and the PR and issue were open on my November 25 check. Results are pinned to that head, not future revisions.

Standalone regular-expression check

Pinned dependencies:

Component Version
onig 6.5.3
onig_sys 69.9.3
C Oniguruma engine, reported at runtime 6.9.10
fancy-regex 0.19.2
regex 1.13.1
regex-syntax 0.8.11
regex-automata 0.4.18

The PR arm used its extracted rewrite function. The alternative arm used explicit expressions for fixed patterns, not an arbitrary-pattern scanner. The full membership and span comparisons completed successfully.

The standalone feature graph is not proof of exact wheel binary provenance; the two experiments independently agree on the context effect.

Oracles: exact IDs, ordered half-open UTF-8 match spans, or boolean scalar membership. Empty successful results are distinct from errors.

2. A small tokenizer-level check, with the original case and the additional class contexts

What the eight scalars are

Code point Character name General category
U+00B2 SUPERSCRIPT TWO No
U+00B3 SUPERSCRIPT THREE No
U+00B9 SUPERSCRIPT ONE No
U+00BC VULGAR FRACTION ONE QUARTER No
U+00BD VULGAR FRACTION ONE HALF No
U+00BE VULGAR FRACTION THREE QUARTERS No
U+200C ZERO WIDTH NON-JOINER Cf
U+200D ZERO WIDTH JOINER Cf

The six numbers are Other_Number (No), rather than Decimal_Number (Nd). The join controls are format characters and have the Unicode Join_Control property. These labels help when examining the implementations, but one should not infer historical membership of \w solely from the general category of a character. That is precisely what the additional old-engine check helps establish.

A minimal replay extending the issue fixture to bracket contexts:

import json
import tokenizers
from tokenizers import Tokenizer

POINTS = [
    0x00B2, 0x00B3, 0x00B9,
    0x00BC, 0x00BD, 0x00BE,
    0x200C, 0x200D,
]
PATTERNS = [r"\w+", r"[^\w\s]+", r"[\s\w]+"]


def make_tokenizer(pattern):
    spec = {
        "version": "1.0",
        "truncation": None,
        "padding": None,
        "added_tokens": [],
        "normalizer": None,
        "pre_tokenizer": {
            "type": "Split",
            "pattern": {"Regex": pattern},
            "behavior": "Removed",
            "invert": False,
        },
        "post_processor": None,
        "decoder": None,
        "model": {
            "type": "WordLevel",
            "vocab": {"[UNK]": 0, "a": 1},
            "unk_token": "[UNK]",
        },
    }
    t = Tokenizer.from_str(json.dumps(spec))
    return t.compile() if hasattr(t, "compile") else t


print("tokenizers:", tokenizers.__version__)
print("module:", tokenizers.__file__)
for pattern in PATTERNS:
    t = make_tokenizer(pattern)
    for cp in POINTS:
        text = "a" + chr(cp) + "a"
        enc = t.encode(text, add_special_tokens=False)
        print(repr(pattern), f"U+{cp:04X}", ascii(text), enc.ids)

Run in separate environments (example for a working Python/pip/venv installation):

python -m venv /tmp/tok023
/tmp/tok023/bin/python -m pip install 'tokenizers==0.23.3'
/tmp/tok023/bin/python check_word_context.py

python -m venv /tmp/tokrc4
/tmp/tokrc4/bin/python -m pip install 'tokenizers==1.0.0rc4'
/tmp/tokrc4/bin/python check_word_context.py

python -m venv /tmp/tokrc5
/tmp/tokrc5/bin/python -m pip install 'tokenizers==1.0.0rc5'
/tmp/tokrc5/bin/python check_word_context.py

Why a tiny vocabulary is useful here

No normalization or special-token insertion is involved. Removed removes matches before WordLevel lookup:

  • All of a²a matched: [].
  • Both as matched: [0] for the remaining ².
  • Only ² matched: [1, 1].
  • No matches: [0] for the full unknown string.

Different residual strings can map to the same unknown ID; direct spans distinguish them.

Compact expectations for the two groups

Input group Pattern Old 0.23.3 Base Head
Six Latin-1 numbers \w+ [] [0] []
Six Latin-1 numbers [^\w\s]+ [1, 1] [1, 1] [0]
Six Latin-1 numbers [\s\w]+ [0] [0] []
Two join controls \w+ [0] [] [0]
Two join controls [^\w\s]+ [1, 1] [0] [1, 1]
Two join controls [\s\w]+ [0] [] [0]

The richer wheel panel used ordinary controls as well as emoji and Indic text with joiners. In that panel, each of the bare word/nonword and boundary patterns (\w+, \W+, \b, \B) had 10 out of 18 diagnostic input-ID rows differing from old in each RC; each of the two bracket expressions had 4 out of 18; a regex Replace fixture had 9 out of 18. Literal-backslash and bracketed-backspace controls each had zero out of 18. These are chosen diagnostic inputs, not estimates of how often a tokenizer encounters such text.

Paired source-build summary for this issue

163 comparable regex diagnostic records; nine other records excluded from equality counts:

Category Count
Base and head agree with 0.23.3 93
Base differs, head agrees with 0.23.3 58
Base agrees, head differs from 0.23.3 12
Base and head both differ from 0.23.3 0
Total comparable 163

Base: 105/163 old-equal; head: 151/163. The 12 new differences are six numbers times two class patterns, not independent bugs or prevalence estimates.

The scoped ASCII fixture (?-u:\w+) failed in every arm and is excluded from parity.

3. Why the bracket context matters: the two lookup paths in the old engine

Looking at the matches before looking at the token IDs

For a²a, the UTF-8 representation is four bytes long: the first a occupies [0,1), the superscript occupies [1,3), and the last a occupies [3,4). The following are the ordered match spans from the standalone comparison. I use half-open byte intervals here, not Python character indices, not model token indices, and not the offset convention of a particular Tokenizers wrapper.

Pattern Old Oniguruma New engine without rewrite New engine with the PR rewrite Explicit alternative
\w+ (0,4) (0,1), (3,4) (0,4) (0,4)
[\w]+ (0,1), (3,4) (0,1), (3,4) (0,4) (0,1), (3,4)
[\s\w]+ (0,1), (3,4) (0,1), (3,4) (0,4) (0,1), (3,4)
[^\w\s]+ (1,3) (1,3) no matches (1,3)
\W+ no matches (1,3) no matches no matches
[\W]+ (1,3) (1,3) no matches (1,3)

Old [^\w\s]+ removes the middle number; the rewritten form matches nothing. This explains the ID difference before vocabulary lookup.

The distinction already exists inside Oniguruma

  • The point predicate onigenc_unicode_is_code_ctype in unicode.c. For the standard character types and code points below 256, it consults the ISO-8859-1 character-type bit table. Outside that special range it uses the Unicode range machinery.
  • The range accessor onigenc_unicode_ctype_code_range in the same file. This obtains the range table for the character type, including the Unicode Word range set, rather than performing that pointwise Latin-1 lookup.

In regparse.c, the standalone word character escape is represented by a character-type node. The character-class parser instead incorporates the ranges for a character type using add_ctype_to_cc, which calls ONIGENC_GET_CTYPE_CODE_RANGE. These paths can therefore disagree even when the source spelling of the escape is the same.

The local 6.9.9 point/range API check found exactly these six Latin-1 Word differences, none for tested Space, Digit, Alpha or Alnum. The pinned 6.9.10 sweep confirms the regex distinction.

How this connects to the tested PR

The #2747 diff adds restore_v023_word_classes to regex compilation. It tracks bracket context for boundary escapes but uses the same word/non-word constants for w and W in both contexts.

For the minimal tokenizer test, the base implementation of Split builds its search implementation from the specified pattern. The generic regex path calls the system regex implementation; pattern matching then turns the match spans and gaps into the pieces on which the split behavior operates. The tested Removed, non-inverted patterns are not the recognized GPT grammar’s usual native Isolated, non-inverted route.

Compatibility is not the same question as the normative definition of a word

Rust regex Unicode notes and UTS #18 describe Unicode-aware word membership (Alphabetic, Mark, decimal digits, connector punctuation, join controls). Historical tokenization compatibility is a separate question.

4. Full scalar membership and match-span comparison results

Scalar membership sweep

All 1,112,064 valid Rust char values (U+0000..U+10FFFF except surrogates U+D800..U+DFFF), including unassigned scalars, were checked as one-character UTF-8 strings against precompiled expressions.

The absolute positive counts were:

Expression/engine Number of matching scalars
Oniguruma standalone \w 144,671
Oniguruma bracketed [\w] 144,665
Unmodified fancy-regex \w 144,667
PR-rewritten standalone \w 144,671
PR-rewritten bracketed [\w] 144,671
Explicit bracket-specific replacement 144,665
Group Old bare Old bracket New default PR bare PR bracket Alternative bracket
² ³ ¹ ¼ ½ ¾ + - - + + -
U+200C - - + - - -
U+200D - - + - - -

The separate match-span panel

16 patterns Ɨ 42 strings = 672 successful old/base/PR comparisons; ten patterns also had an explicit candidate.

Restored = base differs, head equals old; New = base equals, head differs; Still different = neither equals old; Preserved = both equal old.

Pattern Restored New Still different Preserved
\w+ 19 0 0 23
[\w]+ 6 13 0 23
[\s\w]+ 6 13 0 23
[^\w\s]+ 6 13 0 23
\W+ 19 0 0 23
[\W]+ 6 13 0 23
[^\w]+ 6 13 0 23
[\w\W]+ 0 0 0 42
\p{Word}+ 0 0 19 23
[\p{Word}]+ 0 0 6 36
[[:word:]]+ 0 0 10 32
\b 19 0 0 23
\B 19 0 0 23
\\w 0 0 0 42
[\b] 0 0 0 42
\s+ 0 0 0 42
Total 106 65 35 466

65 new differences = five bracket patterns Ɨ thirteen strings. The remaining 35 concern three property/POSIX spellings untouched by the PR; they are not newly introduced.

The input panel, for reuse

let points = "²³¹¼½¾\u{200c}\u{200d}a0_Ć©\u{0301}\u{203f}\u{0661}šŸ˜€ \u{0008}";
let mut texts: Vec<String> = points.chars()
    .flat_map(|c| [c.to_string(), format!("a{c}a")])
    .collect();
texts.extend([
    "šŸ‘©\u{200d}šŸ’»",
    "ą¤•ą„\u{200d}ष",
    "\u{0301}a",
    "a² ½a",
    r"\w",
    "",
].into_iter().map(String::from));
assert_eq!(texts.len(), 42);

Ordered spans include zero-width matches; compile and search errors were recorded separately.

Context-specific expressions

The explicit candidates matched 420/420 spans without errors. Six other patterns, including the three property/POSIX forms, had no candidate.

5. Two compatibility sets, rather than one replacement everywhere

Expressing the measured relationship

Let F be the pinned new word set, L the six numbers and J the join controls:

L = { U+00B2, U+00B3, U+00B9, U+00BC, U+00BD, U+00BE }
J = { U+200C, U+200D }

old standalone word = (F minus J) union L
old bracket word    =  F minus J

Non-word sets are their complements: standalone (not F minus L) union J, bracket (not F) union J.

Four expressions using nested classes and set difference:

standalone w:
[\u{00B2}\u{00B3}\u{00B9}\u{00BC}\u{00BD}\u{00BE}[\w--[\u{200C}\u{200D}]]]

standalone W:
[\u{200C}\u{200D}[\W--[\u{00B2}\u{00B3}\u{00B9}\u{00BC}\u{00BD}\u{00BE}]]]

bracket-context w:
[\w--[\u{200C}\u{200D}]]

bracket-context W:
[\W\u{200C}\u{200D}]

The first two are PR definitions. The bracket alternatives omit the Latin-1 adjustment and remain complementary.

Old pattern Explicit new-engine pattern
[\w]+ [\w--[\u{200C}\u{200D}]]+
[\W]+ [\W\u{200C}\u{200D}]+
[^\w]+ [^[\w--[\u{200C}\u{200D}]]]+
[\s\w]+ [\s[\w--[\u{200C}\u{200D}]]]+
[^\w\s]+ [^[\w--[\u{200C}\u{200D}]]\s]+
[\w\W]+ [[\w--[\u{200C}\u{200D}]][\W\u{200C}\u{200D}]]+

The boundary candidates reuse the PR lookaround expressions based on the standalone set; they matched all 42 inputs per pattern. Missing adjacent characters at string edges are treated as non-word. This does not establish other flags or boundary forms.

What I would consider the default path, conditional on the intended policy

For 0.23 parity, retain the standalone restoration and distinguish bracket contexts.

For a uniform new definition, document differences and qualify affected artifacts.

Supporting both semantics could require an explicit versioned or selected compatibility contract, including its serialization behavior. I am not proposing a schema field or claiming such a flag already exists.

First verify that the actual tokenizer pattern and dispatch reach the affected construct; unrelated artifacts need no rewrite.

6. A regression-test route that keeps the scope and failure modes visible

A minimal standalone check of the context-specific expressions

[package]
name = "word_context_probe"
version = "0.1.0"
edition = "2021"

[dependencies]
onig = { version = "=6.5.3", default-features = false }
onig_sys = { version = "=69.9.3", default-features = false }
fancy-regex = "=0.19.2"
regex = { version = "=1.13.1", default-features = false }
regex-syntax = { version = "=0.8.11", default-features = false }
regex-automata = { version = "=0.4.18", default-features = false }

Condensed recipe from the recorded run. Retain Cargo.lock, feature tree and reported engine version. Requires Rust and C build tools.

use fancy_regex::Regex as Fancy;
use onig::Regex as Old;

const BARE_W: &str =
    r"[\u{00B2}\u{00B3}\u{00B9}\u{00BC}\u{00BD}\u{00BE}[\w--[\u{200C}\u{200D}]]]";
const BARE_NW: &str =
    r"[\u{200C}\u{200D}[\W--[\u{00B2}\u{00B3}\u{00B9}\u{00BC}\u{00BD}\u{00BE}]]]";
const CLASS_W: &str = r"[\w--[\u{200C}\u{200D}]]";
const CLASS_NW: &str = r"[\W\u{200C}\u{200D}]";

fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("Oniguruma: {}", onig::version());
    let old_bare = Old::new(r"\w")?;
    let old_class = Old::new(r"[\w]")?;
    let new_word = Fancy::new(r"\w")?;
    let fixed_bare = Fancy::new(BARE_W)?;
    let fixed_class = Fancy::new(CLASS_W)?;
    // Applying the bare set inside a class is the behavior being examined.
    let same_bare_inside = Fancy::new(&format!("[{BARE_W}]"))?;
    let mut counts = [0usize; 6];
    let mut total = 0usize;

    for cp in 0..=0x10ffff {
        let Some(c) = char::from_u32(cp) else { continue };
        let mut buf = [0; 4];
        let text = c.encode_utf8(&mut buf);
        let a = old_bare.is_match(text);
        let b = old_class.is_match(text);
        let f = new_word.is_match(text)?;
        let w = fixed_bare.is_match(text)?;
        let same = same_bare_inside.is_match(text)?;
        let class = fixed_class.is_match(text)?;
        for (n, different) in [a != b, a != f, b != f,
                              a != w, b != same, b != class]
            .into_iter().enumerate()
        {
            if different {
                counts[n] += 1;
                println!("comparison={n} U+{cp:04X}");
            }
        }
        total += 1;
    }
    println!("total={total}, differences={counts:?}");
    assert_eq!(total, 1_112_064);
    assert_eq!(counts, [6, 8, 2, 0, 6, 0]);

    let boundary = format!(
        "(?:(?<={BARE_W})(?!{BARE_W})|(?<!{BARE_W})(?={BARE_W}))"
    );
    let non_boundary = format!(
        "(?:(?<={BARE_W})(?={BARE_W})|(?<!{BARE_W})(?!{BARE_W}))"
    );
    let pairs = [
        (r"\w+", format!("{BARE_W}+")),
        (r"\W+", format!("{BARE_NW}+")),
        (r"[\w]+", format!("{CLASS_W}+")),
        (r"[\W]+", format!("{CLASS_NW}+")),
        (r"[^\w]+", format!("[^{CLASS_W}]+")),
        (r"[\s\w]+", format!(r"[\s{CLASS_W}]+")),
        (r"[^\w\s]+", format!(r"[^{CLASS_W}\s]+")),
        (r"[\w\W]+", format!("[{CLASS_W}{CLASS_NW}]+")),
        (r"\b", boundary),
        (r"\B", non_boundary),
    ];
    let points = "²³¹¼½¾\u{200c}\u{200d}a0_Ć©\u{0301}\u{203f}\u{0661}šŸ˜€ \u{0008}";
    let mut texts: Vec<String> = points.chars()
        .flat_map(|c| [c.to_string(), format!("a{c}a")])
        .collect();
    texts.extend(["šŸ‘©\u{200d}šŸ’»", "ą¤•ą„\u{200d}ष", "\u{0301}a",
                  "a² ½a", r"\w", ""].into_iter().map(String::from));

    let mut checked = 0;
    for (old_pattern, candidate_pattern) in pairs {
        let old = Old::new(old_pattern)?;
        let candidate = Fancy::new(&candidate_pattern)?;
        for text in &texts {
            let old_spans: Vec<_> = old.find_iter(text).collect();
            let candidate_spans = candidate.find_iter(text)
                .map(|m| m.map(|m| (m.start(), m.end())))
                .collect::<Result<Vec<_>, _>>()?;
            assert_eq!(old_spans, candidate_spans,
                "pattern={old_pattern:?}, input={text:?}");
            checked += 1;
        }
    }
    println!("checked {checked} candidate span comparisons");
    assert_eq!(checked, 420);
    Ok(())
}

Expected totals are from the recorded run; this condensed program was not separately executed. The actual PR arm used its extracted function, not the modeled nested expression here.

Small tests with a good chance of distinguishing future changes

Test family What to compare Why keep it
Bare \w+, \W+ The six numbers and both joiners, alone and between letters Retains the original restoration and checks both complements
[\w]+, [\W]+ Same strings, actual old spans Prevents conflating the old bracket set with the old bare set
[\s\w]+, [^\w\s]+ Same strings plus a mixed fraction/space input Exercises union, negation and the surrounding class
[\w\W]+ Same strings Checks that the two chosen context sets still cover the input
\b, \B Ordered zero-width spans including empty and edge cases Preserves the original boundary behavior separately from consumption
Literal \\w, [\b], \s+ Literal backslash, backspace and whitespace Helps detect accidental changes to unrelated syntax
Actual JSON Split The tiny tokenizer above, exact IDs Confirms that the compatibility behavior is reached by the public API
Regex Replace A minimal normalization fixture, exact output or downstream IDs Checks another caller of the regex construction boundary

Use the old bracket oracle independently; include both a previously compatible number and a join control needing restoration.

Implementation concerns for an arbitrary-pattern rewriter (not additional measured regressions)

  • A literal escaped backslash followed by w must not be interpreted as a word escape. Similarly, escaped opening or closing brackets must not switch the parser’s class context.
  • The syntactic meaning of ] depends on its location, and a leading ^ or an escape at the start of a class can affect that interpretation. A scanner needs to account for the actual grammar rather than simply counting every bracket character.
  • Nested classes, set operations, negation and range operands need correct grouping. A boolean indicating that a bracket has been seen is not, by itself, a proof that arbitrarily nested class contexts are tracked correctly.
  • Scoped flags and verbose-mode comments require a distinction between an active escape and text that will not be interpreted that way. ASCII-mode semantics should be qualified separately; in the earlier Tokenizers panel the specific scoped ASCII fixture was rejected in every arm.
  • Word-boundary escapes are not consuming classes. In a bracket context, a backspace escape is not a word-boundary assertion. Keeping the old tests for those escapes is useful independently of the class membership fix.
  • Property and POSIX spellings have their own semantics and supported grammar. The residual differences in the span panel are evidence about those particular spellings, not a reason to globally rewrite every reference to ā€œWordā€.
  • Invalid patterns, compile failures, and match-time errors need to stay visible. Treating an error as an empty successful span list can make a differential test report agreement where neither implementation performed the requested operation.

Suggested order if this becomes an integrated change

For an integrated change: engine sets/spans, paired Tokenizers build and tiny fixture, wider panel, existing suite, then performance.

No performance measurement here. fancy-regex lookarounds may take a different execution path; measure compile, match and end-to-end costs separately.

7. Where this fits in the Tokenizers v1 migration and practical conformance checks

Similar-looking changes can have different causes

#2557 and #2558 concern native atom-table parity, not the generic regex path here. The components documentation also describes the Whitespace pre-tokenizer in terms of \w+|[^\w\s]+. That makes it a useful lead for a separate dispatch-level test; this experiment does not establish that its implementation reaches the same generic regex path.

The v1 design announcement describes ID compatibility and native dispatch. Semantic checks complement the efficiency work.

For people comparing their own tokenizer artifacts

  1. Fix the tokenizer artifact revision and file hash, and retain the known-good runtime version. Keep the original raw strings and encoding options identical. If a higher-level wrapper constructs or modifies the tokenizer, record that wrapper version as well.
  2. Identify relevant regex patterns and normalization stages, then compare the actual pre-tokenization or regex spans if those are available. Do not silently normalize away a join control or replace a number with ASCII simply to obtain matching output. That tests a different input contract.
  3. Compare exact input ID lists, and where the consuming model depends on them, special-token placement, masks, auxiliary model inputs and offsets. Do not use equality of token count or decoded text as a substitute for exact IDs. Where an API does not expose a diagnostic field, record that field as unavailable rather than assume parity.
  4. Compare decoding with fixed identical IDs separately, under the intended special-token handling. If the artifact is saved and later loaded or reconstructed, repeat the relevant small test after that boundary. A configuration successfully loading is not proof that the reconstructed behavior is identical.
  5. If the tokenizer’s input contract differs and the model is sensitive to exact parity, retain the known-good compatible configuration or runtime until the intended change has been qualified. If the model intentionally adopts a new input contract, that is a separate evaluation decision.

UAX #29 concerns text segmentation, not this historical regex word-membership contract.

tokbench separates semantic and performance checks; Tokenizer conformance fixtures provide pinned IDs, tokens and decoded forms (83 inputs, six configurations). Neither was run here.

The original standalone fix works on the tested head. The explicit bracket alternatives retain that success while recovering historical bracket membership and targeted spans. Whether to preserve or deliberately change that context dependence remains a policy choice. Thanks for making the original observation easy to replay.