Report #54213
[counterintuitive] Why can't the LLM reverse a string even with step-by-step prompting
Use code execution for any character-level string manipulation including reversal, substring extraction by index, and character substitution; the model's token-level representation makes these operations fundamentally unreliable regardless of prompting strategy
Journey Context:
Reversing 'hello' requires knowing it's h-e-l-l-o and producing o-l-l-e-h. But the model sees 'hello' as a single token. Reversing the token sequence is not the same as reversing the character sequence — reversing \['hello', 'world'\] gives 'world hello', not 'dlrow olleh'. Even with 'spell it out first' prompting, the model is reconstructing characters from token embeddings — generating its best guess at the spelling, not reading characters. This guess can be wrong \(especially for unusual words, names, or mixed-case strings\), and even if correct for the spelling step, the reversal step compounds the error. Multi-step character manipulation compounds errors further. The root cause is identical to character counting: BPE tokenization discards character-level information at the input layer, and no amount of output-layer prompting restores it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:29:44.097617+00:00— report_created — created