正确的答案,错误的方向:为什么Transformer在计数上失败以及如何修复
The Right Answer, the Wrong Direction: Why Transformers Fail at Counting and How to Fix It
AI总结:
研究发现Transformer在计数任务中失败是由于输出路径与所需令牌对齐问题,通过局部调整输出头和注意力机制可提升计数性能。
摘要:
大型语言模型在简单计数任务中常表现不佳,即使计数项在提示中也难以正确处理。本文通过分析Pythia、Qwen3和Mistral三种模型家族(0.4B至14B参数),发现Transformer未能将计数信息转换为正确的输出令牌是主要原因。线性探针显示中间层能恢复正确计数(R²>0.99),但计数方向与数字令牌输出头几乎正交(|cos|≤0.032)。通过局部调整输出头和注意力机制的LoRA,可显著提升计数性能。Logit-lens分析显示,计数信息在第35层被正确存储,但输出路径与所需令牌对齐问题仍需解决。这些结果表明计数失败是几何读取瓶颈,而非内部表示问题:模型知道计数,但输出路径与所需令牌对齐不当。
英文摘要:
Large language models often fail at simple counting tasks, even when items to count are in the prompt. We investigate whether this failure occurs because transformers do not represent counts internally, or because they cannot convert representations to the correct output tokens. Across three model families: Pythia, Qwen3, and Mistral, ranging from 0.4B to 14B parameters, we find evidence for the second explanation. Linear probes recover the correct count from intermediate layers with $R^2>0.99$, showing that the information is present. However, the internal directions that encode counts are nearly orthogonal to digit-token output-head rows ($|\cos| \leq 0.032$). In other words, the model stores the count in a form that the digit logits do not naturally read out. We localize this failure with two interventions. Updating only the digit rows of the output head (36,864 parameters) substantially improves constrained digit prediction (60.7--100.0% on four tasks), but it does not fix unconstrained generation (0%); we do not claim that digit-row repair fixes open-ended text. By contrast, small LoRA on attention Q/V (7.67M parameters) improves upstream routing and achieves 83.1%$\pm$7.2% in true greedy autoregressive generation (deployable fix). Logit-lens at layer 35 (entity counting; correct-digit rank): (i) median over 3 seeds drops from order-$10^4$ to 1; (ii) seed 42 shows $54{,}332 \to 838$ (median top-1 while one seed stays far below). Norm, logit-lens, and cross-task analyses generalize the bottleneck to counting, addition, and list length; nulls on MMLU and GSM8K and limited DROP transfer. These results identify counting failure as a geometric readout bottleneck, not an internal-representation failure: the model knows the count but the output pathway is misaligned with tokens needed to express it.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。