Global site search

Search guides, labs, glossary, and research

Type two or more characters to search.

Start with a channel, artifact, or defense term

Examples include zero-width, metadata, tokenizer, or prompt injection.

    BYTES · PRETOKENS · SUBWORDS · CONTEXT

    Tokenization and Normalization Differentials

    Follow text through validation, normalization, pre-tokenization, subword segmentation, token IDs, truncation, chunking, and detokenization.

    Quick answer

    What does this Machine Tradecraft expansion explain?

    Tokenization is a versioned pipeline, not a universal word splitter: bytes and Unicode forms are normalized or preserved, a pre-tokenizer sets merge boundaries, a vocabulary maps subwords or bytes to IDs, and truncation or chat templates alter the final model input.

    Model coupling
    A model is mathematically coupled to its exact tokenizer vocabulary, normalizer, special tokens, and template.
    Security differential
    String filters and model token sequences can disagree, especially around Unicode, whitespace, identifiers, and special-token text.
    Evidence rule
    Record raw text, preprocessing configuration, token IDs, truncation, and tokenizer version together.
    Reviewed implementation boundary

    Know what is measured, approximated, and still external.

    The submitted report remains byte-identical. This separate review, checked 2026-08-26, narrows implementation claims and gives visitors a decision path before they generalize from a local result.

    IMPLEMENTATION MODE Deterministic educational token-boundary simulation
    VISIBLE SOURCE PROFILE 2 standards/specifications · 2 research · 0 government · 2 implementation
    SOURCE BODY Preserved; corrections live in this review layer
    Directly computed

    Output produced deterministically by the local runtime.

    • Exact input bytes, code-point units, simple whitespace/punctuation pretokens, chunk limits, and overlap
    • Deterministic synthetic pieces and IDs generated from a bundled educational rule set
    • Exact local chunking output for the synthetic sequence
    Bounded approximation

    Useful model or subset that must not be mistaken for full conformance.

    • The BPE-, WordPiece-, and Unigram-like labels explain concepts but do not reproduce full training or inference algorithms
    • Synthetic token IDs have no relationship to a vendor vocabulary
    • Normalization and byte-fallback examples are illustrative unless the exact serialized tokenizer is supplied
    Requires external verification

    Conclusion that needs an exact implementation, trust system, model, parser, or human review.

    • Exact boundaries require the model's tokenizer files, normalizer, pre-tokenizer regex, vocabulary, merge or score tables, special-token map, chat template, and immutable version
    • Security or moderation conclusions require evaluation against the actual model and surrounding application pipeline
    • Tokenizer drift must be tested across deployment artifacts, not inferred from names
    Decision support

    Choose the next evidence step instead of treating one result as a verdict.

    QuestionWhat the local page can answerWhat it does not establishNext evidence step
    How do generic segmentation choices change boundaries?Use the educational comparison and chunk matrix.Any named production tokenizer's exact output.Run the immutable production tokenizer on the same preserved input.
    Will the input fit a model context?Only for the synthetic sequence and selected limit.Actual vendor token count or chat-template overhead.Measure with exact tokenizer and template artifacts.
    Does a boundary change imply a security bypass?No — it identifies a differential to test.Model uptake, classifier failure, or exploitability.Evaluate the full moderation and inference pipeline.
    Focused deterministic fixture

    Multilingual, combining, emoji, code, and identifier boundary set

    Shows how bytes, graphemes, pretokens, synthetic subwords, truncation, and overlap can disagree.

    Expected boundary: All synthetic outputs remain deterministic and clearly labelled as non-vendor data.

    Open prepared laboratory
    Version and authority checkpoints
    • SentencePiecePrimary research paper used for conceptual architecture
    • BPE for subword unitsPrimary research paper used for BPE background
    • tiktokenVersioned implementation repository; no code or vocabulary is loaded by the public runtime
    Compare independent views

    One artifact, several machine-readable representations

    No single view is automatically authoritative. Preserve the source, identify each parser or receiver, and compare their outputs before authorizing a consequential decision.

    01Raw bytes

    The exact UTF-8 input before text processing.

    02Unicode form

    Code-point and optional normalization copies.

    03Pretokens

    Whitespace, punctuation, casing, and regex boundaries.

    04Subwords

    Educational BPE, WordPiece, and Unigram-style pieces.

    05Token sequence

    Synthetic IDs and fallback markers from the bundled vocabularies.

    06Context assembly

    Special tokens, truncation, chunks, and overlap.

    Bounded method

    Analysis workflow

    The workflow preserves evidence before transformation and keeps structural inspection separate from execution, remote verification, or model behavior.

    1. Preserve the original bytes and validate UTF-8.
    2. Record every normalization and pre-tokenization rule.
    3. Load the tokenizer vocabulary and special-token map by immutable version.
    4. Tokenize before applying model context limits.
    5. Log the exact token sequence and chunk boundaries supplied downstream.
    Defense in depth

    Controls carried into implementation

    These controls are contextual. They reduce a defined risk; they do not guarantee safety, truth, attribution, or resistance to every adaptive attack.

    01

    Never assume one tokenizer represents another model or version.

    02

    Moderate the exact canonical representation and model-bound input, not only display text.

    03

    Escape or isolate user text from special-token and chat-template construction.

    04

    Chunk at model token boundaries while preserving source offsets.

    05

    Include tokenizer files and configuration in software and model provenance.

    Shared vocabulary

    Key terms

    Definitions are linked into the site-wide glossary and back to the full report.

    Pre-tokenization

    Rule-based segmentation before a statistical subword algorithm.

    Subword

    A token unit smaller than a word and often larger than a character.

    Byte-pair encoding

    A vocabulary-building method that repeatedly merges frequent adjacent units.

    WordPiece

    A subword method commonly using likelihood-oriented vocabulary selection and continuation markers.

    Unigram tokenization

    A probabilistic segmentation model that selects among vocabulary pieces by score.

    Byte fallback

    Encoding unknown text as tokens representing its UTF-8 bytes.

    Special token

    A reserved token representing structure or control rather than ordinary user text.

    Truncation

    Discarding input tokens beyond a bounded context limit.

    Detokenization

    Reconstructing text from token IDs, potentially after lossy preprocessing.

    Continue with primary material

    External standards and research

    These links are provided for visitors who want the governing specification, paper, framework, or implementation documentation. Links open in a new tab; the site does not fetch them during runtime analysis.

    Primary research Research paper

    SentencePiece paper

    Language-independent subword tokenization and detokenization.

    Original research or formal conference publication.
    aclanthology.org
    Primary standard Normative standard

    Unicode Text Segmentation

    Grapheme, word, and sentence boundaries.

    Normative or first-party specification material.
    www.unicode.org
    Primary standard Normative standard

    Unicode Normalization Forms

    Canonical and compatibility normalization.

    Normative or first-party specification material.
    www.unicode.org
    Implementation reference Implementation documentation

    Hugging Face tokenizer summary

    Practical algorithm comparisons and implementation concepts.

    Tool, vendor, or implementation documentation; behavior is version-specific.
    huggingface.co
    Implementation reference Source repository

    OpenAI tiktoken repository

    Versioned byte-pair tokenizer implementation.

    Tool, vendor, or implementation documentation; behavior is version-specific.
    github.com
    Continue the investigation

    Read the evidence, then test the bounded model

    The full submitted report is preserved byte-for-byte in the governed research library and in durable repository documentation. The laboratory turns selected concepts into deterministic local output without external calls or hidden persistence.

    Detailed report

    Tokenization, Normalization, and Boundary Differentials in AI Pipelines

    A detailed account of byte, Unicode, normalization, pre-tokenization, BPE, WordPiece, Unigram, SentencePiece, fallback, special-token, truncation, chunking, and model/tokenizer mismatch behavior.

    Read governed report
    Focused laboratory

    Educational Tokenization Differential

    Compare deterministic miniature character, byte, BPE, WordPiece, and Unigram-style profiles, then inspect local round trips and bounded chunks. The bundled vocabularies do not reproduce a vendor tokenizer.

    Open bounded laboratory