RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
Glossary / Transformer & LLM components / Tokenization
Transformer & LLM components

Tokenization

Tokenization is the process of converting text into the numeric tokens a model can process. Modern systems use subword tokenization (BPE, WordPiece, or SentencePiece) which strikes a balance between character-level (long sequences, generic) and word-level (short sequences, hits unknown words).

The tokenizer is part of the model — different models tokenize the same string differently. "OpenAI's GPT" might be 3 tokens for GPT-4 and 4 tokens for Llama. This affects both context budget and output speed: a more efficient tokenizer fits more content per token.

Special tokens (<bos>, <eos>, <|im_start|>, etc.) signal structure to the model — chat formatting, instruction boundaries, end-of-sequence. Misformatted special tokens are a common cause of garbled output in DIY inference setups.

Practical example

An operator fine-tuning Llama 3.1 with a custom chat template runs into garbled output after deployment — the model emits stray <|im_start|> fragments mid-sentence. The cause: the inference server (say, an older llama.cpp build) is loading a generic BPE tokenizer instead of the model's bundled SentencePiece tokenizer with its correct special-token mappings. The fix is verifying the tokenizer.json and tokenizer_config.json shipped with the model weights match what the runtime actually loads — a mismatch here silently corrupts chat formatting even when the model weights themselves are fine. This is also why swapping a fine-tune's base model without re-checking tokenizer compatibility is a common source of broken instruction-following after quantization.

Related terms

TokenEmbedding (Vector Embedding)

Reviewed by Eruo Fredoline. See our editorial policy.

Buyer guides
  • Best GPU for local AI →
  • Best laptop for local AI →
  • Best Mac for local AI →
When it doesn't work
  • CUDA out of memory →
  • Ollama running slowly →
  • ROCm not detected →