Report #90193
[counterintuitive] Why can't the model count characters, reverse strings, or find the nth character reliably
Delegate all character-level string operations to code execution. Never ask the model to count characters, reverse strings, or find the nth character via prompting alone—always write and execute Python or JavaScript to perform the operation.
Journey Context:
LLMs process text through subword tokenizers \(BPE, WordPiece, SentencePiece\) that chunk text into multi-character tokens. The model never sees individual characters—it sees token IDs. The word 'hamburger' may tokenize as \['Ham', 'burger'\], and the model has no native representation that 'Ham' is three characters. Asking an LLM to count characters is like asking a human to count phonemes in a word they only ever see as a single glyph: possible with brittle memorized heuristics for common words, but fundamentally misaligned with the input representation. No prompting technique—chain-of-thought, few-shot examples, role-play, or 'think step by step'—changes the input modality. The tokenizer sits between the text and the model, and that layer is not bypassed by better prompts. Developers routinely waste hours crafting increasingly elaborate prompts for character-level tasks when the correct fix is architectural: give the model a code execution tool and have it call len\(\), reversed\(\), or indexing operations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T09:59:05.018044+00:00— report_created — created