直接读写Transformer组件研究
Through the Looking Glass: Directly Reading and Writing Transformers
这篇论文揭示了Transformer内部工作原理,展示了如何直接读写模型组件,对理解模型机制很有价值。
研究人员分析了18个Transformer模型,发现一个预测依赖于数万到数十万个组件,但实际起关键作用的组件仅占模型1-3%。在基准模型中,53个组件贡献了90%的预测能力,13个是预测不可或缺的,8个就足以产生预测。研究还实现了对模型组件的直接读写操作,包括安装新关联和创建条件触发编辑。
Through the Looking Glass: Directly Reading and Writing Transformers
How many of a transformer's components decide a token? Counted by the absolute value of each unit's and channel's contribution to the logit, one prediction rests on thousands to hundreds of thousands of them. But contributions are signed, and across eighteen models the mass pushing away from the predicted token is a median of seven times the mass carrying it. Divide by the net and the count is dozens: on the baseline, 53 components carry ninety percent of a prediction, 13 it cannot survive losing, and 8 suffice to produce it alone. Across twelve models trained elsewhere, 124M to 7B parameters, the sufficient set runs from two components to sixteen, and what a prediction draws on, followed all the way back, is one to three percent of the model, a share that does not grow with size. Three quarters of a layer's update is a fixed linear map of the state it received. Everything is read from the model's own parameters and activations, with nothing trained or fitted, and it names a component on both sides: what it writes, from the predictions it drives, reaching close to half of every model; what it reads, from its weights in the frame of its own layer, at 58.9 percent above chance over its eight strongest inputs. Sorting the remainder by upstream source yields grammatical categories the embedding cannot see. A name can be acted on. An association the model does not hold installs into one spare unit, key and value read from the weights, for a quarter of a percent of held-out loss, a fortieth of what a rank-one update costs. An installed attention head and a unit two layers above it make an edit fire only where a token occurred earlier in the context, and a unit the model trained for itself is driven from two layers upstream, 86 percent of the effect passing through it. An order-preserving activation puts a unit's inputs at the instrument's ceiling, at the price of a two-part install.