Skip to content

feat(pipeline): Support Metaspace pretokenizer (T5, albert) - #2264

Merged
SBrandeis merged 9 commits into
feat/train_encode_splitfrom
feat/pipeline-metaspace
Jul 31, 2026
Merged

SBrandeis merged 9 commits into
feat/train_encode_splitfrom
feat/pipeline-metaspace

Conversation

@SBrandeis

@SBrandeis SBrandeis commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR

The released Metaspace pretokenizer is in fact a Normalizer (turn whitespaces into the ▁ delimiter) + a Split pretokenizer

This PR adds support for this pretokenizer

`memmem::Finder` carries a few hundred bytes of prefilter state on x86_64 (much
less on aarch64, which is why this only showed up in CI): a `Literal` stored
inline blew `NormalizerWrapper` and `DecoderWrapper` up to 352 bytes through
`Replace`, which `clippy::large_enum_variant` rejects.
The Python bindings search with a `&String` pattern — `NormalizedString.replace`
and `.split` take a plain `str` — so dropping these impls broke every job that
builds the bindings. Reinstating them through `Literal` keeps the public API and
still drops the regex engine from the literal path: they used to escape the
string and compile a regex on every call.

An empty pattern now covers the input by byte length rather than character
count, like every other impl (the old count sliced mid-character).
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@SBrandeis
SBrandeis marked this pull request as ready for review July 29, 2026 16:52
// Whitespace is thrown away, so cut the text where `WhitespaceSplit` would and write the
// words back one after the other, each with its own delimiter.
let mut words = Vec::new();
pipeline::PreTokenizer::pre_tokenize(&WhitespaceSplit, input, &mut words)?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels weird to call pretokenize here, but I understand the reuse

Base automatically changed from feat/literal-patterns to feat/train_encode_split July 31, 2026 14:15
@SBrandeis
SBrandeis merged commit 0bcf291 into feat/train_encode_split Jul 31, 2026
38 of 42 checks passed
@SBrandeis
SBrandeis deleted the feat/pipeline-metaspace branch July 31, 2026 14:41
ArthurZucker pushed a commit that referenced this pull request Sep 2, 2026
Squashed from 2 commits:
  - feat(atomsplit): offload literal patterns to atomsplit (#2263)
  - feat(pipeline): Support Metaspace pretokenizer (T5, albert) (#2264)

Area: core-splitter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants