Report #63603
[counterintuitive] LLM ignores instruction to output exactly N words or sentences
Use structured output constraints \(logit\_bias, max\_tokens, grammar constraints\) or post-processing scripts to enforce exact length. Do not rely on semantic instructions for precise counts.
Journey Context:
Instructions like 'write exactly 50 words' are routinely missed. LLMs predict the next token based on probability. The concept of a 'word' or 'sentence' is a human abstraction mapped onto tokens. The model does not possess an internal counter that ticks down and perfectly halts generation at exactly N words. It generates until an End-Of-Sequence \(EOS\) token is predicted. Asking it to count words is asking it to simulate a state machine it does not have.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T13:14:41.367573+00:00— report_created — created