Tokenizer
A preprocessing component that splits text into smaller units (tokens) and maps them to integer IDs for model input, and reverses the process for output.
A tokenizer converts raw human language into numerical tokens that a transformer model can process. This includes two main operations: (1) segmentation-breaking text into subwords, characters, or bytes, and (2) encoding-mapping each segment to an integer ID from a fixed vocabulary. Subword tokenizers (e.g., Byte-Pair Encoding, WordPiece, SentencePiece-used by GPT, BERT, Llama) balance vocabulary size and token length by splitting rare words into smaller pieces (e.g., 'tokenizer' -> ['token', 'izer']). Vocabulary size typically ranges from 32k to 128k. Tokenization dramatically impacts model behavior: a given word may be represented as one token in one language or multiple in another, affecting memory usage and generation speed. For example, many LLMs use byte-level tokenization (like GPT-4's tiktoken) to handle any Unicode character. Pitfalls: leading spaces, punctuation, and digits can produce unexpected token counts. Always use the exact tokenizer matching your model-mismatches degrade performance. Token-to-word ratio varies by language (English ~1.3, Chinese ~2.5). Tokenizer choice affects context window utilization; a longer tokenization per word reduces effective context. For AI builders, profiling token counts on your dataset is essential before fine-tuning or RAG to avoid truncation. Tokenizers also influence inference cost since compute scales with token count both in attention (quadratic) and KV cache (linear).
One token equals roughly one word-in reality, it varies by language and tokenizer, often 0.7 to 1.5 tokens per word.
Related terms
Concepts you'll usually encounter alongside this one.
The rate at which a language model generates or processes tokens, commonly used to measure inference throughput.
The context window defines the maximum number of input tokens a transformer model can process at once, determining the length of conversation history or document it can reason over.
A neural network architecture using self-attention mechanisms to process sequential data in parallel, forming the foundation of modern LLMs.
Used in benchmarks
Workloads on MyAI Bench that involve Tokenizer.
Mentioned in tutorials
Hands-on guides that put this concept to work.
Stand up a fully functional local LLM stack on Ubuntu 22.04, NVIDIA drivers, CUDA, Ollama, and your first model, in under 30 minutes.
Run local LLMs on Windows 11 the right way, WSL2, the WSL CUDA toolkit, and Ollama with full GPU acceleration. Native installer covered too.
Apple Silicon is shockingly good at LLM inference. Get Ollama running with unified memory acceleration on any M-series Mac in 15 minutes.
DeepSeek's reasoning model rivals GPT-4 on math and code. Run the distilled 7B/14B/32B variants on consumer hardware in 30 minutes.
See how this term affects your memory budget.
Real numbers, real chips, every workload.
Picks for builders, by use case.
Stay Ahead of the AI Curve
Get weekly AI hardware news, benchmark updates, and deals in your inbox. Founding-subscriber list, be one of the first.