By Sagar Shankaran, Founder of CallSphere
A technical deep dive into how modern LLM tokenizers work, the tradeoffs between BPE and SentencePiece, and emerging approaches that improve multilingual and code performance.
Key takeaways
Tokenization is the first and arguably most consequential step in any LLM pipeline. It determines how text is split into the discrete units that the model processes. Poor tokenization wastes context window space, degrades multilingual performance, and creates unexpected failure modes. Yet it receives a fraction of the attention given to model architecture and training.
A tokenizer's vocabulary and merge rules directly affect cost (more tokens per text means more inference cost), latency (longer sequences take more time), and quality (splitting meaningful words into fragments hurts comprehension).
BPE, originally a compression algorithm, is the foundation of most modern LLM tokenizers. The training process is straightforward:
flowchart LR
INPUT(["User intent"])
PARSE["Parse plus<br/>classify"]
PLAN["Plan and tool<br/>selection"]
AGENT["Agent loop<br/>LLM plus tools"]
GUARD{"Guardrails<br/>and policy"}
EXEC["Execute and<br/>verify result"]
OBS[("Trace and metrics")]
OUT(["Outcome plus<br/>next action"])
INPUT --> PARSE --> PLAN --> AGENT --> GUARD
GUARD -->|Pass| EXEC --> OUT
GUARD -->|Fail| AGENT
AGENT --> OBS
style AGENT fill:#4f46e5,stroke:#4338ca,color:#fff
style GUARD fill:#f59e0b,stroke:#d97706,color:#1f2937
style OBS fill:#ede9fe,stroke:#7c3aed,color:#1e1b4b
style OUT fill:#059669,stroke:#047857,color:#fff
GPT-4's tokenizer (cl100k_base) uses BPE with a vocabulary of approximately 100,000 tokens. Claude's tokenizer uses a similar approach.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
SentencePiece, developed by Google, treats the input as a raw byte stream without pre-tokenization. This makes it truly language-agnostic — it does not assume spaces separate words, which is essential for languages like Chinese, Japanese, and Thai.
import sentencepiece as spm
# Training a SentencePiece model
spm.SentencePieceTrainer.train(
input="training_data.txt",
model_prefix="tokenizer",
vocab_size=32000,
model_type="bpe", # or "unigram"
character_coverage=0.9995
)
sp = spm.SentencePieceProcessor(model_file="tokenizer.model")
tokens = sp.encode("This is a test.", out_type=str)
SentencePiece also supports the unigram model, which starts with a large vocabulary and prunes tokens with the least impact on the training data's likelihood. This approach can produce more linguistically motivated subword units than greedy BPE merges.
OpenAI's tiktoken library implements BPE encoding in Rust with Python bindings, achieving 3-6x speedups over pure Python implementations. This matters for applications that tokenize large volumes of text for cost estimation or chunking.
Newer models address the multilingual penalty through several strategies:
Meta's BLT architecture, published in late 2024, proposes eliminating fixed tokenization entirely. Instead, it dynamically groups bytes into variable-length patches based on the complexity of the input. Simple, predictable text gets grouped into large patches (processed efficiently), while complex or information-dense text gets fine-grained byte-level attention.
This approach could resolve the multilingual fairness problem because it adapts to the data rather than relying on a fixed vocabulary trained on a potentially imbalanced corpus.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
Different tokenizers produce dramatically different token counts for the same text:
| Text | GPT-4 (cl100k) | Llama 3 | Gemma |
|---|---|---|---|
| English paragraph (100 words) | ~130 tokens | ~125 tokens | ~128 tokens |
| Chinese paragraph (100 chars) | ~110 tokens | ~150 tokens | ~105 tokens |
| Python code (50 lines) | ~350 tokens | ~380 tokens | ~340 tokens |
These differences directly affect inference costs and effective context window utilization.
When building retrieval-augmented generation systems, token-based chunking is more reliable than character-based chunking because it aligns with how the model processes text. Libraries like LangChain and LlamaIndex offer tokenizer-aware text splitters for this purpose.
Tokenization is infrastructure — invisible when it works well, painful when it does not. Understanding your tokenizer's behavior is essential for cost optimization, multilingual support, and reliable LLM application development.
Sources: SentencePiece GitHub | Tiktoken GitHub | BLT Paper - arXiv:2412.09871

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
CallSphere supports 57+ languages and multi-region telephony out of the box. Vapi numbers are heavily US/CA. See the global voice routing architecture.
GPT Image 2.0 hits ~99% character-level text accuracy across Latin, CJK, Hindi, and Bengali scripts. This crosses the threshold where marketing teams stop retouching generated images.
Discover how multilingual AI voice agents bridge language barriers in international freight, reducing miscommunication delays by 80%.
Build a post-call analytics pipeline with GPT-4o-mini — sentiment, intent, lead scoring, satisfaction, and escalation detection.
Miami Beach hotels serve guests from across Latin America, Europe, and the Caribbean. AI voice agents handle calls in 57+ languages with zero multilingual staffing.
London boutique hotels in Covent Garden, Notting Hill, Mayfair, and Shoreditch serve global tourism. AI voice agents handle 57+ languages with 24/7 direct booking capture.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.
Try Live DemoBook a DemoCalculate Your ROI