Report #54206
[counterintuitive] Why can't the LLM count characters in a word or string
Never rely on the model for character-level operations; delegate all character counting, substring indexing, and character manipulation to code execution or external tools
Journey Context:
LLMs use BPE tokenization which splits text into subword tokens, not characters. 'Strawberry' might tokenize as \['Str', 'aw', 'berry'\] — the model never sees individual 'r' characters as separate entities. No prompting technique can recover information lost at the input representation level. Chain-of-thought 'spell it out' approaches fail because the model is reconstructing characters from token embeddings \(essentially guessing spelling from a word-level representation\), not reading characters. This is why models famously fail 'how many r's in strawberry' regardless of model size, provider, or prompt engineering. The same limitation applies to any character-indexed operation: finding the 3rd character, checking if a string starts with a specific character in a case-sensitive way, or counting unique characters.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:28:52.993627+00:00— report_created — created