Daily Tech Briefing
AI 科技速览

每天 5 分钟内学习 AI。获取最新的人工智能新闻,理解其重要性,并学习如何将其应用于您的工作。

AI 快讯
Dev.to AI · 2026/7/22 10:20:08

Why AI Can't Actually Hit Your Word Limit

AI 中文解读
AI又翻车了!你让它写250字,它偏偏给你340字,反复叮嘱也没用。原来,大语言模型根本不懂“计数”——它只会一个词一个词地往外蹦,每蹦一个就看看前面写了啥,再猜下一个,从头到尾都没有“字数到没到”这个检查环节。更麻烦的是,它内部用的不是“单词”而是“词块”,一个词可能被切成好几块,“250字”这个指令在它眼里就是个模糊的猜测。 这听起来像是AI的bug,其实是它天生的设计:没有计数器,没有循环,只有概率猜测。想让它精确达标,别指望一次生成搞定。聪明的做法是:先让它自然写完,再手动裁剪;或者要求“给我三段话”而不是“250字”;真要精确,就分两步走——先生成再校对字数。 这事对我们普通用户挺实用。以后写工作总结、发邮件、做摘要,别跟AI较劲硬性字数了。把它当个初稿助手,自己当最后的“字数审核员”,反而更高效。理解了AI的“数学盲点”,你就再也不会因为它超字数而恼火了。
<p>I Was drafting my blog post, told Claude "keep it to 250 words." Got back something like 340. Asked again. Same story.</p> <p>Figured there's a real reason behind this, and since I'm neck-deep in AI/ML fundamentals right now, decided to actually understand it instead of just being annoyed by it.</p> <h3> It generates one token at a time, no plan </h3> <p>LLMs don't write like we do think of the whole thing, then fill it in. They generate autoregressively: predict the next token, add it to the context, predict the next one, repeat. There's no "here's my 250-word essay, let me write it out" step happening anywhere. Every single token is picked based on what came before, nothing more.</p> <p>So when you ask for 250 words, the model isn't holding a target in memory and counting down. It's pattern-matching: "text like this, following an instruction like this, tends to stop around here." That's a guess shaped by training data, not a computation.</p> <h3> Words ≠ tokens </h3> <p>Also it's not even counting <em>words</em>. Internally, everything is tokens: sub-word chunks. "Debugging" might be one token or three depending on the tokenizer. "250 words" as an instruction gets converted into an expectation of <em>roughly</em> how many tokens that maps to, and that mapping is fuzzy. There's no clean 1:1 between what you asked for and what the architecture tracks.</p> <h3> No counter anywhere in the architecture </h3> <p>This is the part that surprised me most: there's no length-tracking variable sitting in the model's forward pass. No <code>if word_count == 250: stop</code>. The only thing steering generation is the probability distribution over the next token, sampled step by step, until it predicts an end-of-sequence token or hits a max-length cutoff set by the system.</p> <p>Compare that to something like a <code>for</code> loop with a counter deterministic, exact. LLM generation is closer to sampling from a learned distribution, over and over. Approximate by design, not by bug.</p> <h3> The workaround </h3> <p>Since I can't get an exact count out of a single generation, what actually works:</p> <ul> <li>Ask for a natural stopping point instead of a hard number</li> <li>Generate first, then trim or expand after, treating the count as a second pass, not the first</li> <li>For real precision, set limits in characters or use iterative regeneration with a check step, rather than trusting the first output</li> </ul> <h3> Why this clicked for me </h3> <p>This ties directly into what I've been learning attention, softmax over vocabulary, sampling strategies. Word-count control would need something structurally different: a running counter fed back into the decoding loop, or a constrained decoding step that force-stops at a token budget. Neither is how these mainstream models work by default.</p> <p>Small annoyance, decent rabbit hole. Worth knowing before you set a hard word limit and assume the model's counting along with you.</p> <p><em>Learning AI/ML from the ground up cloud engineer trying to understand the models she uses daily.</em></p>
分享
阅读原文