cd /news/natural-language-processing/a-first-measured-note-for-tokenizers… · home › topics › natural-language-processing › article
[ARTICLE · art-176043] src=discuss.huggingface.co ↗ pub= topic=natural-language-processing verified=true sentiment=· neutral

A first measured note for tokenizers, with a runnable check

A reproduction of Hugging Face tokenizers PR #2747 using released Python packages confirms the patch restores all eight original standalone `\w+` cases and old standalone `\w` membership across all valid Unicode scalar values, but inside bracketed character classes the same replacement changes the previously compatible behavior of six Latin-1 numeric characters (², ³, ¹, ¼, ½, ¾). Testing the issue's tiny WordLevel tokenizer with `Split(behavior="Removed", invert=False)` on `a²a` showed the `\w+` row restored to Tokenizers 0.23.3 output while `[^\w\s]+` and `[\s\w]+` newly diverge from the old engine. The author recommends retaining the PR's standalone definitions and distinguishing replacements inside brackets, reporting that explicit context-specific expressions matched Oniguruma on all 420 tested pattern/input combinations, and notes the minimal tests need no model download or GPU.

key takeaway

Retaining PR #2747's standalone `\w` definitions while using bracket-context-specific replacements matched Oniguruma on all 420 tested pattern/input combinations, whereas a uniform replacement diverges on six Latin-1 scalars (², ³, ¹, ¼, ½, ¾) inside brackets.

read2 min views2 publishedNov 25, 2026

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 a s 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? 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.
── more in #natural-language-processing 4 stories · sorted by recency
── more on @hugging face 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/a-first-measured-not…] indexed:0 read:2min 2026-11-25 · —