# Hand-crafted pretokenizer regexes are part of every frontier LLM and doing heavy lifting (Albert Gu, X thread)

- **ID:** 1444
- **Kind:** thread
- **URL:** https://x.com/_albertgu/status/2113687798826111283
- **Authors:** Albert Gu (@_albertgu) — Assistant Professor, CMU Machine Learning Department, co-founder / Chief Scientist, Cartesia, Mamba/Mamba-2 co-author (S4/HiPPO lineage)
- **Published:** 2026
- **Source:** x
- **Language:** en
- **Access:** free
- **Added:** 2026-10-23
- **Verified:** 2026-10-23
- **Page:** https://papers.projxon.ai/entries/1444

## Summary

A short illustrated explainer — framed as preparation for an unnamed, undated Cartesia "upcoming release" (pure teaser; nothing about it is verifiable from the thread) — arguing that the regex PRETOKENIZER is the one part of a modern LLM stack still hand-designed rather than learned, and that it does "pretty heavy lifting." Content is a lineage tour of the pretokenizer patterns shipped in well-known public BPE tokenizers, each shown as a screenshot and verified for this entry against the public tokenizer configs (NO errors found): (1) GPT-2's original pattern — contractions case-SENSITIVE and listed individually ('s|'t|'re|'ve|'m|'ll|'d), digits UNGROUPED (\p{N}+). (2) GPT-4 / cl100k_base — contractions become case-insensitive ((?i:…)) and digits are chunked in groups of 1–3 (\p{N}{1,3}) — a deliberate choice with arithmetic consequences (fixed-width digit chunking; a reply in-thread notes left-to-right chunking turns 12345 into 123|45). (3) GPT-4o / o200k_base — the letter branch forks by case (separate uppercase/titlecase-initial and lowercase-initial word patterns), roughly doubling the pattern's complexity; Gu's caption is candid ("honestly i have no idea, something about additional rules around upper/lower case") and the case-handling reading is correct. (4) DeepSeek — the pattern balloons into many script- and punctuation-specific branches, including a dedicated CJK range branch; the screenshot is EXCERPTED (presented without saying so — the full DeepSeek pattern is far longer). Claim hygiene: "part of every frontier LLM" overstates as written — regex pretokenizers are near-universal in the dominant BPE lineage (OpenAI, DeepSeek, Llama-3-style, Qwen, Mistral tiktoken-style), but SentencePiece/Unigram tokenizers and tokenizer-free/byte-level approaches don't use a hand-written regex pretokenizer; read as "every frontier BPE LLM." Post 1's meme regex is an implementation variant (possessive quantifiers, apostrophe-less contraction branch) of the GPT-4-family pattern rather than literally the cl100k pattern shown two posts later — cosmetic, not an error in any captioned claim. A notable unanswered reply asks what regression test catches a silent pretokenizer change that shifts model quality.

## Research notes

- Discovery: Hudson shared Gu's thread 2026-10-23. Relevance: (1) his pretraining/tokenizer choices (genuine) — the thread is the practitioner-facing exhibit for the tokenization thread his catalog already tracks from the research side: #49 (RePR — "the tokenizer is a new scaling axis") and #96 (CPLM — byte models get zero copy-head gain because the tokenizer bottleneck vanishes when V<D). Digit chunking, contraction splits, and whitespace rules are inherited SILENTLY whenever a tiktoken/HF tokenizer config is adopted, and they measurably shape arithmetic and code behaviour; if he trains a custom tokenizer, these regexes are the default being accepted or replaced. (2) Model Axes (weak) — cross-model eval comparisons bake in different pretokenizers (token counts, digit chunking, CJK handling differ across lineages). NO SSM/linear-attention content despite the poster — the thread makes no architecture or speed claims, so Hudson's recorded stack fact (Gated DeltaNet not faster than his Transformer baseline below ~16K) is not engaged in either direction. WATCHLIST: the teased unnamed Cartesia release — if it ships with tokenizer claims it is a NEW item, not an update to this thread. People: @_albertgu is a first-time share into the workflow (new people file at insert).
- License: none — thread only, no artifact; the quoted patterns originate from public tokenizer distributions (tiktoken is MIT) but the thread itself licenses nothing — do not assert a license at insert

## Similar entries

- [Token-efficient reasoning for frontier models (X thread by @paahrsa)](https://papers.projxon.ai/entries/739) (thread, #739)
- [Scaling KV Cache Compression to Frontier Models (X thread by @RampLabs)](https://papers.projxon.ai/entries/740) (thread, #740)
- [New hallucination benchmark accepted to NeurIPS 2026 Evaluations & Datasets track (X thread by @_emliu)](https://papers.projxon.ai/entries/743) (thread, #743)
- [AI video agency guide (X thread by @everestchris6)](https://papers.projxon.ai/entries/734) (thread, #734)
- [Adversarial RL for alignment + adversarial rubric matching (X thread by @nagpalchirag)](https://papers.projxon.ai/entries/741) (thread, #741)
- [Claude Opus 5.5 video tool: free crash course (X thread by @twoclipping)](https://papers.projxon.ai/entries/730) (thread, #730)
