Report #67777
[counterintuitive] Why can't the model count characters in a string no matter how I prompt it
Offload all character-level operations—counting, reversing, finding positions, substring extraction by index—to code execution or an external tool. Never rely on the model's direct text generation for these tasks.
Journey Context:
LLMs operate on BPE tokens, not characters. The model literally does not see individual characters—it sees integer token IDs. 'Strawberry' might tokenize as \[Str, aw, berry\], so asking how many 'r's it contains requires decomposing tokens the model never observes decomposed. No prompt engineering, few-shot examples, or chain-of-thought can create character-level access the architecture doesn't provide. This is why a model can write a correct Python character-counting function but cannot itself count the characters. Developers waste hours iterating prompts for what is a tokenization-impossibility. The only fixes are architectural \(character-level models, which have their own severe tradeoffs\) or practical \(tool use\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:14:50.841952+00:00— report_created — created