Elamur Research

Inferring Functionality of Attention Heads from their Parameters

Paper · 2025 · Amit Elhelo and Mor Geva

Summary

An attention head can contribute to several different tasks. Watching it respond to a prompt can reveal one of those contributions, but the result depends on what that prompt asks and which other components take part. Amit Elhelo and Mor Geva investigate whether the learned weights of an attention head can tell us more broadly what it is capable of doing. Their method, MAPS, expresses part of each head’s computation as a set of scores between the tokens a transformer can read and produce. A score describes how the head’s output transformation treats a source token when viewed in terms of a possible target token. The researchers can calculate these scores from the weights of the system under study.

MAPS uses these scores in two ways. To look for a known operation, it tests a collection of token pairs, such as countries and their capitals, and asks how frequently the appropriate target ranks among a head’s strongest outputs. It can also look for suppression, where the head’s contribution pushes the target down. To investigate a head without choosing a relation in advance, MAPS finds the inputs on which the head’s transformation has the strongest relative effect. It then examines what those inputs tend to promote. This second route can surface operations that a pre-defined list would miss, such as associations between time expressions and longer periods.

The authors test 20 pre-defined relations across 6 large language models. The rankings derived from the weights often agree with rankings derived from head outputs on prompts, although agreement varies with the relation and the surrounding text. Removing the outputs of high-scoring heads often impairs performance on the associated task more than removing an equal number of randomly selected heads. MAPS also recovers heads identified in earlier studies and finds others with similar token mappings. The maps show that many classified heads support several relations, and that heads sharing parts of their computation in Llama-3.1 frequently receive related classifications.

For the open-ended analysis, GPT-4o describes the strongest mappings of heads in GPT-2 xl and Pythia 6.9B. The pipeline assigns a pattern to 62% of the heads, with higher coverage in the middle and upper layers. In a separate evaluation by humans, GPT-4o and the annotators make the same call on whether a pattern is present in 80% of cases. These descriptions concern the mappings visible in the weights. Establishing when a head uses a mapping requires evidence about what it attends to and how the rest of the system responds.

Deep dive: Inferring Functionality of Attention Heads from their Parameters

MAPS uses attention head weights to identify token mappings, then tests whether those mappings predict head behavior and affect answers. · about 38 minutes to read

The problem and its context

What a prompt can reveal about a head

An attention head reads information from selected positions in a sequence and contributes an output at a position where that information may be useful. In a sentence with several names, for instance, a head might direct information about one name towards a position where the system will continue the sentence. Studying that event can tell a researcher which name the head favors in those circumstances. Elhelo and Geva ask a broader question. If the same head were given many different kinds of information, what transformations would its weights support?

The distinction matters because a head is shared across the inputs the system processes. A study can design examples that reliably elicit copying, follow the information through the components needed for those examples, and build a convincing account of how copying works there. A different task may send other information through the same component. Conversely, another head may contain a transformation that could copy a name when it receives the relevant information, yet barely participate in the examples chosen for the original study. The set of components involved in a particular computation is frequently called a circuit. Starting with a circuit gives a study a clear object of inquiry, while leaving open how far the properties of that circuit’s components extend.

The paper identifies practical difficulties with making the input-driven approach comprehensive. The more prompts it takes to bring out a head’s different behaviors, the more executions researchers need. Even a very large collection can miss contexts that activate a particular operation. The original training data could offer a wide range of contexts, but it may be unavailable, and running the system over it could be expensive. There is also an interpretation problem. A researcher looking at examples that activate a head has to work out which of their shared features explains the behavior. Several plausible patterns can appear in the same examples.

MAPS changes where that inquiry begins. It first inventories relationships suggested by the head’s weights, then checks selected relationships against behavior. That order is particularly relevant when the research question concerns a whole network. If the goal is to find every head that can promote a capital given a country, starting from heads already implicated in a capital-prediction task may privilege the ones that respond to the chosen prompts. A common numerical test can be applied across layers and heads before the researcher decides which components merit closer inspection.

Where the vocabulary view came from

The authors place MAPS in a line of interpretability research that examines attention in several ways. Some earlier studies inspect the positions to which heads attend. Others look at the outputs the heads produce, train probes or sparse autoencoders to help identify features, or intervene in the computation and observe what happens. These approaches answer related questions at different points in the process. A pattern over positions helps explain what information a head draws on. Inspecting its output helps explain what it writes. An intervention can test how much downstream behavior depends on what the head wrote. The paper discusses these approaches in connection with earlier studies of attention structure and head specialization. Analyzing Multi-Head Self-Attention · Analyzing the Structure of Attention in a Transformer Language Model

MAPS takes its central representation from earlier work that expresses internal computations in vocabulary coordinates. Each token has an embedding, a vector used to represent it at input. Each possible output token also has a direction against which an internal vector can be scored. A researcher can take a token embedding, transform it with a head’s weights, and compare the resulting vector with those output directions. The result gives vocabulary-level descriptions of effects that would otherwise be expressed in hidden coordinates. Related work used that idea to understand how feed-forward components promote concepts and to inspect transformations inside attention heads. Transformer Feed-Forward Layers Build Predictions by Promoting Concepts in the Vocabulary Space · Analyzing Transformers in Embedding Space

The paper’s account of earlier studies explains why a framework can be new even when its matrix calculation has precedents. Vocabulary projections had helped to check interpretations of particular heads, frequently after task behavior or a circuit analysis had suggested what to look for. Earlier work had also examined a single operation across many heads and systems. MAPS generalizes the unit of analysis in both directions. A bank of relations can be scored across the network, and a head can be examined for patterns that the bank did not anticipate. The shared representation makes it possible to connect these two kinds of inquiry without designing an entirely different scoring mechanism for each operation.

The authors also distinguish their approach from asking for a verbal account of a head’s strongest internal directions. A list of terms associated with a direction might reveal a topic. For a head that links countries to capitals, a researcher wants to see whether different countries lead to their respective capitals. Pairing an input with its candidate outputs supplies that information. Earlier work on linear relation decoding, as the paper describes it, had already found that linear functions can approximate relation operations. MAPS asks whether such a relation is legible in the weights of a particular attention head. Linearity of Relation Decoding in Transformer Language Models

What counts as an operation

In this study, an operation can be as simple as copying a token, as linguistic as promoting a comparative adjective, or as dependent on knowledge as associating a product with its company. The important common property is that the mapping can be demonstrated with examples that have a source and a target. A pair can represent identity, a change in form, a translation, or an association. It can also represent suppression. A head can write a vector that contributes evidence against a token, including the very token that another head favors.

Those definitions deliberately give the method a common scale. There is no need to decide beforehand whether a relation describes grammar, factual knowledge, or a more general string transformation in order to score it. Each relation can be represented as a collection of pairs and each head’s treatment of those pairs can be compared. The categories become useful later, when the authors ask where different kinds of operation appear and whether the same head passes tests from different categories.

The definition also fixes the scope of the interpretation. A vocabulary mapping asks how a head’s writing transformation treats a token representation. During ordinary execution, the head receives hidden states already affected by context and by layers that came before it. It may read from several positions and write a mixture of their information. A mapping derived from the weights offers a hypothesis about part of that computation. The paper tests this hypothesis by looking at head outputs with and without restrictions on attention, and by observing the consequences of removing head outputs altogether.

The method, step by step

Separate what a head reads from what it writes

The head has two roles in the formulation the authors adopt. Its query and key weights determine how much attention to place on the different positions available to it. Its value and output weights determine what it writes using the information from those positions. The authors combine the weights for each role into an interaction matrix. MAPS concentrates on the second matrix because it describes how information that reaches the head is transformed before it returns to the residual stream, the shared representation to which heads and other components contribute.

Imagine testing a country-to-capital mapping. The writing transformation can be applied to the embedding for Egypt and the resulting vector can be scored against the output direction for Cairo. The same calculation with Egypt and every possible output token provides a ranked list for that source. Each additional country supplies a new list. If the corresponding capitals repeatedly appear near the top, the head has a consistent property across examples of the relation. In an ordinary prompt, the head first has to obtain information about the country. The lookup described here isolates what the weights can do with that information.

How MAPS reads operations from attention head weights

The steps in order.

How MAPS reads operations from attention head weightsStep 1: Combine the head’s value and output weights1. Combine the head’s value and output weightsStep 2: Project the transformation into vocabulary space2. Project the transformation into vocabulary spaceStep 3: Read each source token’s ranked targets3. Read each source token’s ranked targetsStep 4: Score examples of predefined relations4. Score examples of predefined relationsStep 5: Rank source tokens by relative transformation strength5. Rank source tokens by relative transformation strengthStep 6: Collect their highest-scoring target tokens6. Collect their highest-scoring target tokensStep 7: Describe recurring patterns across the collected mappings7. Describe recurring patterns across the collected mappings

The branches share the vocabulary projection. Scoring a known operation starts with a set of relations and asks which heads support them. Describing salient operations starts with one head and asks which mappings are worth looking at. The latter uses a separate rule to choose source tokens before it reads their ranked targets.

From sequence representations to head output

The paper assumes a vocabulary V, the set of tokens recognized by the system, with size |V|. The hidden dimension d is the length of the vector used to represent each position. There are L layers and H attention heads per layer. For a sequence of n positions, X contains the hidden state for each position in a row, so X has shape n × d. The combined query and key matrix, written below as W(QK), has shape d × d. The simplified attention calculation is as follows.

A = softmax((X W(QK) Xᵀ) / √(d/H))

A is the matrix of attention weights, with a row for each receiving position and a column for each position it can read. The product X W(QK) Xᵀ produces the scores between positions. The superscript ᵀ transposes X, turning its rows into columns, so the product compares the state at a receiving position with the state at a possible source position. The square root of d/H gives the scale in the denominator, where d/H is the head dimension in this formulation. The softmax operation converts the scores for a receiving position into normalized attention weights over its available sources.

X̃ = A X

X̃ is the matrix of contextualized states for this head. Row by row, multiplication by A combines the states in X according to the attention weights from the corresponding receiving position. If the head’s attention is restricted to that position itself, its row in X̃ comes from the state at that position. The state may already reflect context accumulated in previous layers.

Y = X̃ W(VO)

Y contains the head’s output at every position, with shape n × d. W(VO) is the combined value and output transformation, with shape d × d. Its value part determines what representation to take from the information read by the head. Its output part projects that representation back into the space used by the residual stream. This form omits additive biases from the head’s transformations. The paper later accounts for the value bias in the measured outputs used for its correlation experiment.

This factorization explains why a parameter analysis can isolate an operation and still need validation on real inputs. It holds the writing transformation fixed and changes how the vectors entering it are chosen. Vocabulary embeddings are convenient stand-ins for individual source tokens. The vectors in X̃ are the actual combinations produced from an input sequence, and they may behave differently under the same transformation.

Put source and target tokens on the axes

The input embedding matrix E has |V| rows of length d. Each row represents a source token. One earlier vocabulary projection used those same embeddings as the directions against which outputs were compared.

M̃ = E W(VO) Eᵀ

M̃ is the resulting token-by-token score matrix. Multiplying by E on the left applies W(VO) to each source embedding. Multiplying by Eᵀ on the right scores each transformed vector against each token embedding. The tilde on M̃ distinguishes this version from the projection that uses the system’s actual output directions.

M = E W(VO) U

M is the score matrix used for MAPS. U is the unembedding matrix, with shape d × |V|. Its columns determine how a hidden vector is scored against the possible output tokens. Where input embeddings and output directions have separate learned weights, U puts the output side of the calculation in the coordinates used to predict tokens. In M, a row is indexed by the source token, a column by the target token, and a cell gives the contribution of the transformed source in the target direction.

The country example uses a small region of this matrix. Read the rows associated with countries and look at the entries in the columns associated with their respective capitals. A plain copying operation draws attention to another shape. The source and target have the same token identity, so the entries of interest fall on the diagonal. A strongly ranked off-diagonal entry can describe a change in spelling, meaning, or language, depending on the tokens. A large score on its own tells the reader which pair to inspect. Repetition across corresponding pairs is what supplies evidence for the relation.

For most of the systems studied, the authors modify the source embeddings before projecting them. They apply the first feed-forward block, also called the first MLP, with the normalization that precedes it. The idea is to bring the source representation closer to what later heads may receive. The first attention layer precedes that block, so the first-layer heads are analyzed without this adjustment. Llama-3.1 70B also uses the embeddings without the adjustment because the authors obtained better results that way. This preprocessing uses learned components from the system. The procedure does not train a classifier to discover which heads implement a relation.

Turn examples into a relation score

A pre-defined relation starts with source and target strings that exemplify it. The paper draws on several kinds of material, including a frequency list for copying examples, factual pairs from a knowledge base, and datasets used in earlier relation-decoding work. The researchers augment some collections with examples proposed by ChatGPT and validate the generated examples manually. Some datasets also use checks from the NLTK package. The calendar-successor pairs are constructed in code. For several relations, the authors filter repeated sources so that alternative targets for the same source do not create multiple examples in the resulting collection. Wikidata · Locating and Editing Factual Associations in GPT

The study then applies tokenization, the conversion of strings into the units the system uses. The authors prepend a space when processing words to increase the chance that the tokenizer represents them as single tokens. The static relation test keeps a pair only when both sides meet that requirement. A relation dataset left with ≤30 pairs for a tokenizer is dropped for that tokenizer. A relation is therefore identified by the same general idea across systems, while the actual examples available to test it can differ. The final collections cover algorithmic, knowledge, linguistic, and translation relations.

ϕᵣ(M) = (1 / |Dᵣ|) ∑₍ₛ,ₜ₎ ∈ Dᵣ 𝟙[t ∈ topₖ(mₛ)]

The subscript r designates the relation under test. Dᵣ is its set of token pairs, and |Dᵣ| is the number of pairs. In a pair (s, t), s is the source token and t is the expected target. The vector mₛ is the row of M for the source s. The function topₖ returns the k tokens that score highest in that row. The indicator 𝟙 contributes one when the target is among those tokens and zero otherwise, and ∑ adds the contributions across the dataset. Dividing by the number of pairs gives ϕᵣ(M), the fraction of examples that pass.

A rank cutoff makes the question concrete. With a strict cutoff, the expected target has to compete with the whole vocabulary, including related tokens and variants of the same word. For GPT-2, Phi-2, and Pythia, the paper uses k = 1 for copying and name copying and k = 10 for the other relations. In Llama-3.1, the corresponding choices are k = 3 and k = 25. Its vocabulary contains more variants, which the authors take into account by widening the cutoff. The rules for copying remain stricter because the test is meant to find a strong tendency to preserve the input token.

For a suppression relation, the procedure uses −mₛ in place of mₛ. Negating the row reverses the order, making the strongest negative scores in the original row the first candidates for the same rank test. A head can consequently be tested for promoting a past-tense form and for suppressing that form, using the same examples. These scores describe contributions in the projected vocabulary, which is why the paper tests the signs against output behavior as well.

The continuous relation score supports ranking heads. For maps that label heads as implementing a relation, the paper also applies a cutoff of τ = 15%, where τ is the minimum share of successful pairs. This creates a distinction between the numerical evidence for a mapping and the label assigned to a head for a particular plot or count. The authors chose the cutoff after varying it and applying the test to randomly generated matrices. They can still use the scores of heads below the cutoff when ranking positive-scoring candidates in the causal experiment.

Select salient inputs before describing a head

A pre-defined inventory can only find the operations it asks about. For open-ended inspection, the simplest approach would be to sort all the entries in M and display the highest-scoring pairs. An exceptionally large input embedding can influence the scale of a row and dominate such a list. A list can also devote much of its space to several outputs from the same source. In that case, it offers little evidence about how the head behaves across different inputs. The authors instead decide which source tokens to inspect before selecting targets.

σₜ(W(VO)) = ‖eₜ W(VO)‖ / ‖eₜ‖

The token t is the candidate source in this formula. The row vector eₜ is its embedding, W(VO) is the writing transformation, and the double bars denote vector length. The numerator is the length after the transformation and the denominator is the original length. Their ratio, σₜ, is the saliency score. It measures the relative magnitude of the effect of the transformation on that source direction. It does not specify which output tokens will have high scores or whether they will share a recognizable relation.

For each head, the pipeline selects the k = 30 source tokens with the highest saliency scores. For each of those sources it retrieves the n = 5 leading targets in M. Here k counts sources and n counts targets per source, separate from the use of k as a rank cutoff in the relation experiment. The resulting material presents several alternatives for each of a varied group of source tokens. GPT-4o receives the mappings and is asked to describe their shared pattern, with the option of saying that no clear pattern can be seen. This step uses a separate system to interpret the lists. Producing the numerical lists themselves requires no prompting of the system whose heads are being studied. GPT-4o System Card

The paper uses MAPS as the name of the framework and releases its code and the resulting head mappings. The numerical mappings and their verbal descriptions are distinct outputs. A reader can inspect a proposed description against the source–target lists that motivated it. The paper uses that distinction in the human evaluation, where readers judge the visible evidence and the precision of the description separately.

Experiments and results

The systems, vocabularies, and tasks

The main mapping study covers GPT-2 xl, Phi-2, Pythia 6.9B, and Pythia 12B, along with Llama-3.1 8B and Llama-3.1 70B. The architectures differ in depth, head count, and how attention parameters are shared. Pythia 6.9B has 32 layers and 32 heads per layer. Llama-3.1 70B has 80 layers and 64 heads per layer. The Llama-3.1 systems use grouped-query attention, so multiple heads share key and value projections. The other systems in this study use multi-head attention without that grouping. The Llama-3.1 vocabulary has ∼130k tokens, while the other systems’ vocabularies have ∼50k tokens. These differences matter both for what qualifies as a valid dataset example and for how the target is ranked. GQA · The Llama 3 Herd of Models

The 20 relations span several kinds of mapping. The algorithmic group includes copying, extracting a word’s first or last letter, and going from a year to its successor. The knowledge group includes national languages, capitals, and associations between an object and its broader class. The linguistic examples include comparatives, past tense, and homophones. The translation relations start from English and go to French or Spanish. The study treats the recorded target as the answer to be checked, so each score concerns a particular set of examples even when the relation name describes a broader ability.

The authors evaluate different claims with different measurements. For the static and dynamic scores, the unit of comparison is the head. For causal removal, the outcome is the accuracy of generated answers on relation tasks. For the description pipeline, the unit is a head’s displayed set of mappings and the pattern a reader can see in it. A high result on one measure supports a narrower conclusion than a high result on another. In particular, a head can write a vector that promotes the expected target without the complete system producing that target in its final answer.

Do the weights predict what a head writes?

The first validation compares a head’s static relation score with a score obtained from its output during execution. The authors use four prompt templates and compare results separately for each. In one template, the source is introduced as the topic of a document. Other templates position it in different contexts. A template provides surrounding text and avoids using the source token as an isolated sequence, which the authors say could make the result sensitive to the attention sink phenomenon. An attention sink is a position that can receive unusually large attention even when the information there is of limited relevance to the task. Efficient Streaming Language Models with Attention Sinks

The researchers record a head’s output vector at the last position of the prompt and project it through U. This is the position where a head writes its contribution to the continuation, whether the source is the final token or appears earlier in that template. The unconstrained condition allows the head to attend to the available prompt context. The restricted condition forces attention to the source representation, so the head’s output reflects its transformation of that representation more directly. Previous layers have still processed the prompt. The experiment restricts attention for the head being measured, rather than starting that head from an isolated embedding.

ϕ*ᵣ(h) = (1 / |Dᵣ|) ∑₍ₛ,ₜ₎ ∈ Dᵣ 𝟙[t ∈ topₖ(yₛ U)]

The star in ϕ*ᵣ identifies the score measured during execution. The argument h is the head, and yₛ is its recorded output vector for the prompt containing the source s, under the condition being measured. Multiplication by U gives a vector of scores in output vocabulary order. The topₖ operation uses the same rank cutoffs as the static test. The expected target t, the dataset Dᵣ, the counts in the sum, and the averaging operation have the same meanings as in the parameter-based score. For the dynamic output, the paper includes the contribution of the value bias before applying the output projection.

The comparison then asks whether heads strong on the static measure are also strong on the dynamic measure, within a particular relation and system. In Llama-3.1 8B, the paper describes correlations of 0.71-0.95 for the great majority of relations in the restricted setting. Name copying has a correlation of 0.95 under both attention conditions. Country to capital has 0.85 in each. For comparatives, the restricted correlation is 0.85 and the contextualized correlation is 0.86. For adjective to superlative, the corresponding values are 0.87 and 0.89. These cases show that contextualized execution can preserve the association between the static and dynamic measures.

Other relations are more sensitive to context. In the same Llama-3.1 8B results, the word-to-last-letter correlation is 0.67 in the restricted condition and 0.36 with ordinary attention. For word to compound it is 0.78 and 0.62, respectively. On the other hand, both conditions give comparatively modest correlations for some mappings, such as work to location at 0.44 and 0.45. A relation can be difficult to track with a static map even before the measured head is allowed to combine information across positions. The paper reports p-values ≤ 3.9e-128 for the Llama-3.1 8B correlations. Those p-values address whether the associations are statistically detectable. The coefficients indicate how closely the measures agree.

The supplementary results illustrate why it is useful to report both the correlation and the best score achieved by any head. In GPT-2 xl, the promotion results for word to homophone give correlations of 0.46 with attention restricted and 0.38 with contextualization. The maximum static relation score across its heads is 0.02. In Pythia 12B, country to capital gives correlations of 0.93 and 0.89, alongside a maximum static score of 0.97. Correlation describes agreement about how scores vary among heads. The maximum indicates whether even the strongest of those heads consistently promotes the expected tokens on that dataset. The paper also reports the correlation tests for suppression, which extend the comparison to negative contributions.

Does removing the selected heads change the answer?

The next experiment turns relation examples into tasks. For country to capital, a country is inserted into a sentence stem that calls for the capital. For operations such as copying or changing an adjective to its comparative, the prompt can demonstrate the mapping before presenting the new input. The authors design task prompts for 13 relations. A relation is omitted for a particular system if the required dataset is unavailable or if intact accuracy is <0.1. The test target comes from the same relation data used to derive the examples for the static map.

For each relation, the researchers rank the heads by their parameter-based score and progressively zero their outputs in rank order. The intervention applies at the final prompt position, where these contributions can affect the prediction. The answer is generated by greedy decoding, which takes the highest-scoring next choice at each step. The removal series is bounded by the number of heads with positive scores and by a preset cap. The cap is 150 for GPT-2 xl, both Pythia systems, and Llama-3.1 8B. It is 250 for Llama-3.1 70B. If target accuracy reaches 0 earlier, the paper reports the run up to that point.

The random baseline removes an equal number of heads outside the corresponding ranked set. The authors repeat the random selection 5 times and report mean accuracy. A separate control asks how the same targeted intervention affects other relation tasks. The experiment uses up to five such tasks, selected with <15% head overlap and baseline accuracy differing by ≤20% from the target task. The random comparison helps assess the cost of removing that many outputs. The controls ask whether the effect is disproportionately concentrated on the operation used to choose the heads.

Pythia 12B country-to-capital test accuracy after removing 75 heads

Removing the heads ranked by MAPS leaves substantially less target-task accuracy than random removal.

Pythia 12B country-to-capital test accuracy after removing 75 headsRandom heads, mean accuracy: 0.95Random heads, mean accuracy0.95MAPS-ranked heads (this paper): 0.00MAPS-ranked heads (this paper)0.00
The numbers
System or settingaccuracy
Random heads, mean accuracy0.95
MAPS-ranked heads (this paper)0.00

Lower accuracy in this chart indicates a stronger effect of the intervention. On the country-to-capital relation test, intact Pythia 12B reaches 0.97 accuracy. With the same relation-based intervention, accuracy averaged across the selected control tasks is 0.90, compared with 0.89 intact. This is a case where the heads chosen from the weights have a large collective effect on the task they were selected for, while performance on the controls remains close to its initial level.

Across the Pythia 12B tasks reported in the main comparison, the authors give relative accuracy drops of ≥32% after targeted removal and declines of ≤13% under random removal. The control tasks sometimes also suffer, with the paper reporting a relative drop of at most 33%. The effect is therefore uneven across both relations and controls. For adjective to comparative, the target accuracies are 0.91 intact, 0.20 after targeted removal, and 0.82 under random removal. Its selected control tasks average 0.92 intact and 0.63 after the targeted intervention. The controls preserve much more of their original performance than the target task in this case, although the intervention affects them as well.

The Llama-3.1 results show why the causal finding is best read relation by relation. In Llama-3.1 70B, the country-to-capital target accuracy moves from 0.84 intact to 0.29 after ranked removal, with 0.85 under random removal. For noun to pronoun it is 0.98 intact and 0.98 after ranked removal. In Llama-3.1 8B, the English-to-Spanish target records 0.94 intact and 0.97 after ranked removal. The authors report that the Llama-3.1 accuracy drops are frequently smaller, while emphasizing that in 9 out of 11 relations the drops exceed those from the random and control baselines. The experiments link many static mappings to consequences for prediction, and their weaker cases show that this link varies across tasks.

Can a single-token map carry over to longer names and words?

The static map can only score examples that fit its vocabulary axes. The authors test whether a static score obtained on such examples predicts the behavior of heads on new examples whose source occupies multiple tokens. They prepare new datasets for 11 relations and run the correlation experiment on GPT-2 xl, Pythia 6.9B, and Pythia 12B, using the document-topic template. They keep the static score from single-token examples and compare it with dynamic scores from the new prompts. The comparison asks whether relative strengths among heads carry across different tokenizations of a source concept.

The paper reports that for 53 out of the 64 combinations of system, relation, and attention condition, the multi-token correlation is either higher or within ≤0.05 of the single-token correlation. For instance, Pythia 6.9B has a contextualized correlation of 0.89 on both the single-token and multi-token country-to-capital examples in this experiment. For contextualized name copying in Pythia 12B, the corresponding values are 0.38 and 0.33. That case illustrates an important aspect of the aggregate result. A similar coefficient on the two datasets can reflect stable performance at a modest level of agreement.

There is also a qualification to the paper’s account of the remaining cases. Its main discussion says those correlations remain ≥0.63, with drops of ≤ 0.13. Some entries in its detailed comparison are lower than that stated floor and differ by more than the stated similarity allowance. For example, the contextualized word-to-synonym correlations for Pythia 12B are 0.61 on single-token sources and 0.58 on multi-token sources, both close and below the floor. In GPT-2 xl, the restricted year-to-following results are 0.95 and 0.82, while the contextualized results are 0.74 and 0.63. The reported aggregate supports transfer in many comparisons. The individual rows give a more precise account of how strong the relationship is for a chosen operation.

How often is a head’s salient pattern readable?

The automatic pipeline processes 2,224 heads in Pythia 6.9B and GPT-2 xl. Across the two systems it reports a pattern for 62% of the heads. For the middle and upper layers the reported range is 60%-96%, while the early and final layers have a range of 20%-60%. This measure records when GPT-4o offers a pattern for the displayed mappings. It gives the coverage of the description process, which the human study then checks on a sample.

A qualitative review of 107 heads with identified patterns finds that 38% show semantic operations, 36% algorithmic ones, and 26% linguistic ones. Cases include association between historical entities and years, completion of fragments such as resil towards resilience, and changes in capitalization such as water to Water. Some mappings express a graded association. A head can promote several related time expressions while favoring a longer period, with month pointing towards year and year towards decade. The source–target lists let a reader see how consistently such a description fits and where alternative readings may apply.

Five graduate students fluent in English evaluate random samples of 138 (13.5%) heads from Pythia 6.9B and 134 (11.2%) from GPT-2 xl. They judge whether the examples show a pattern, how precisely the description captures it when both reader and system see one, and what kind of pattern it is. Under the annotation instructions, a pattern should be apparent across 20 or more mappings. It can be a repeated source-to-target operation or a strong commonality among the targets. Similarity among sources alone is insufficient.

In 80% of cases, humans and GPT-4o reach the same conclusion about whether a pattern is present. In 87% of the failures, GPT-4o describes a pattern the annotators cannot see in the mappings. Among heads with observable patterns, it supplies a pattern in 95% of cases. Where both the annotators and GPT-4o see a pattern and the description is rated for precision, <2% of the descriptions are labeled poor. A description can still receive an intermediate rating for being too broad, too narrow, or only partly correct. Pattern detection and faithful description are distinct stages, and the study measures both.

What the ablations show

Random matrices test the role of the learned weights

A vocabulary projection combines input embeddings, the head transformation, and output directions. The authors consider whether the embeddings could already make related words look close enough for a random head to pass the relation test. For each layer, they generate H random matrices with the shape of the writing matrix. The normal distribution used for sampling takes its mean and standard deviation from the learned matrices of that layer. They then apply the same relation-scoring procedure and threshold to the synthetic matrices.

The test produces no classified random matrices for Phi-2, the two Pythia systems, or the two Llama-3.1 systems. In GPT-2 xl, it classifies 5 random matrices, compared with 250 relation heads among the trained system’s 1200 heads. This supports the use of the 15% threshold to identify associations that depend on the learned head weights under the paper’s random baseline. The comparison holds the surrounding vocabulary representation in place, which makes the difference informative about the contribution of the transformation in the middle. It does not attribute every individual association exclusively to that transformation, since the learned embedding and unembedding directions still enter the score.

The two random controls in the paper act at different points and answer different questions. Replacing the matrices in the static analysis checks how easily the scoring rule finds a relation without the trained transformation. Removing randomly selected head outputs in the causal experiment checks how easily a task loses accuracy when a group of real heads is silenced. Taken together, the comparisons connect a trained parameter pattern to a measurable role in execution. The first comparison supplies a baseline for finding a mapping, and the second supplies a baseline for assigning it behavioral importance.

Restrictions on attention expose the contribution of context

The forced-attention comparison narrows the computation between the source and the output of the observed head. A strong relationship between the parameter score and the measured score in this condition shows that the writing transformation transfers to the source representation produced by the system. Releasing the restriction adds the head’s choice about what to read. A lower correlation under ordinary attention is consistent with the head sometimes taking information from other positions, with interaction among the information it reads, or with the behavior differing across prompt conditions. The comparison measures the combined effect of allowing that context at the head.

A closer look at an individual head makes the difference concrete. In GPT-2 small, head 8.11 has a static name-copying score of 0.88. Its dynamic score is 0.23 on the template that introduces the name as a document topic. When examples of copying precede the test name in another prompt, its dynamic score is 0.92. The same weights can thus give a much clearer copying signal in a prompt that elicits copying. Among the additional name-copying heads examined in GPT-2 small, the static and dynamic scores correlate at 0. Considering only the name position yields a value of 94 and a p-value of 2.5e−7. This supports the ability seen in the weights under a condition that supplies the right information to the head.

The removal experiments take the comparison from head outputs to whole-system answers. Repeatedly silencing high-ranked heads can expose an effect shared among many components, including ones whose individual scores fall below the threshold used for assigning labels. The country-to-capital example in Pythia 12B provides strong evidence for the importance of the selected group on that prompt task. The smaller or absent effects for some relations in Llama-3.1 show that the same selection procedure can yield different dependencies. Since the intervention zeros the entire output of each selected head, the result concerns the group’s contribution at the intervened position, encompassing the other things those heads may write there.

Comparing the maps with previously identified heads

The authors apply MAPS to earlier circuit findings in GPT-2 small and GPT-2 medium. For the indirect-object identification work in GPT-2 small, they recover the principal heads previously associated with moving names and those associated with suppressing that behavior. The expanded analysis also identifies 21 additional name-copying heads in that system, 6 of which the earlier work had already described as backups. The appendix reports a previously identified backup mover and a backup negative mover that MAPS misses. Across the similar operations it examines, the paper summarizes its comparison as finding 25 additional heads in GPT-2 small and 46 in GPT-2 medium.

The results for GPT-2 medium cover both copying and capital associations. Earlier researchers had identified mover heads in tasks involving names and colors, with substantial overlap between the sets. MAPS gives the included mover heads the name-copying classification and finds that many of them also score on other relations, including year succession and country-to-language associations. The appendix reports 31 other name-copying heads in GPT-2 medium. For the country-to-capital circuit, it recovers the earlier capital heads and finds 15 others with the same static relation classification.

Recovery provides a check against findings reached through a different line of inquiry. The additional heads broaden the list of components capable of the mapping. Whether they contribute to the original circuit is a separate empirical question and depends on the tasks and prompts. Some of the earlier mover heads also illustrate that a useful task-level label can describe only part of a head’s repertoire. A component that moves names in one circuit can have weights that also support mappings across other kinds of input.

Distribution across layers, head groups, and systems

To produce the category maps, the authors label a head when it passes the cutoff on at least one relation in a category, including a suppression variant. The layers with most of these classifications tend to be in the middle and upper part of the network. The open-ended descriptions show a broadly similar concentration. The agreement between a pre-defined relation bank and a search for salient patterns suggests that the layer pattern extends beyond the contents of the relation bank. Both procedures still rely on a vocabulary projection, so they share a sensitivity to how directly a layer’s output can be represented as token scores.

Overlapping labels are common. Among the classified heads, the share belonging to multiple categories is 38% in GPT-2 xl, 29% in Phi-2, and 20% in both Pythia systems. The reported share is 11% in each Llama-3.1 system. The authors describe a general tendency toward fewer multi-category heads in larger systems and point to Llama-3.1 8B as an exception to that pattern. The denominator is the set of heads classified by MAPS, so these percentages describe the detected operations and the degree to which those labels overlap. They do not measure the total number of distinct operations every head performs.

The Llama-3.1 maps give the authors a reason to consider architectural sharing as well as size. Heads in the same attention group often receive similar relation labels, sometimes involving a relation and its suppression variant. In grouped-query attention, shared key and value parameters give the heads some common structure. Individual heads can still use different queries and output projections. The observed patterns connect group structure with the kinds of mappings detected. A comparison in which grouping alone changes would be needed to isolate how much of the pattern it explains.

Suppression is substantial enough to matter to the resulting inventory. Across the systems, 20%-36% of classified heads pass on at least one suppressive variant. This measure concerns the negative end of the score rankings. It makes visible heads that may be missed when an analysis looks only for strong promotion. In GPT-2 small, recovering both the positive and negative name movers gives a specific example of why the signed interpretation matters. The automated open-ended analysis concentrates on positive mappings, so the full extent of readable suppression patterns remains a separate question.

The authors also compare distributions of scores for selected relations across systems. They observe that some relations reach similar high scores in systems that differ in architecture and training data. This supports recurrence at the level being measured, namely which token associations a head’s writing transformation can express. The broader distributions contain heads with varying strengths for the same relation. A classification cutoff makes the plot easier to read, but the distributions suggest that an association may be present to different degrees in many components. For research on locating or editing an association, that distinction matters because a head that receives the strongest label may be one among several contributors.

What changes when the analysis starts with salient inputs

Ranking all source–target cells together and first ranking the source embeddings by relative transformation strength yield quite different lists. For GPT-2 xl, the paper reports a Jaccard similarity of 0.01 on average between the lists, where Jaccard similarity measures the overlap of two sets relative to their union. This establishes that the selection rule changes the evidence presented for interpretation. The paper gives a reason to prefer inputs that span multiple source tokens. Its human study tests the resulting pipeline, without a corresponding human comparison of descriptions made from the highest raw entries. The overlap statistic on its own does not measure which descriptions would be better.

The appendix uses the same token-wise saliency values to investigate how concentrated each head’s operation is. Input skewness describes whether a head has unusually large relative effects on a small set of inputs. For outputs, the authors take the strongest target for every vocabulary source and count how much of the vocabulary occurs among those targets. For this output-space analysis they normalize the columns of the unembedding matrix, reducing the influence of output vector length on the comparison.

t = argmax(mₛ)

Here s is a source token, mₛ is its row of mapping scores, and argmax returns the target token t at the largest entry. The authors apply the operation to every source and retain the distinct targets. The share of the vocabulary represented in that distinct set gives their output space size. A head can have a small output space even when a large number of sources give a strong response, if many sources converge on the same few targets.

The paper compares these statistics with illustrative cases. A transformation sending the whole vocabulary toward 1 target, such as an end-of-sequence token, has very narrow output coverage. A capitalization transformation can operate across many words and fragments with different corresponding targets. The reference subset of capitalized tokens with leading spaces accounts for 25% of the GPT-2 xl vocabulary and 16% of the Pythia 6.9B vocabulary. These examples distinguish the breadth of the inputs on which a head acts from the breadth of the outputs it favors.

In both systems used for this analysis, input skewness rises and then falls sharply in the early layers before stabilizing. Output space size tends to decrease across layers, with a slight rise near the end. The authors interpret the trends as evidence that shallower heads tend to have large effects on narrower sets of inputs, while deeper heads can act on broader input sets and direct them towards a more limited vocabulary region. The statistics support a difference in concentration. They do not assign a specific operation to a head without the underlying mappings.

Limitations

Limits identified by the authors

The head’s writing transformation is the part directly examined by MAPS. The query and key transformation determines which positions supply the information it writes, and the authors identify that computation as a target for further study. A head with a strong capital mapping in its weights might rarely attend to the relevant country in a particular context. The dynamic scores show that this can matter, while the interventions measure the consequences of the head output that actually occurs. Neither provides a full account of the routing decisions that make the mapping active. The authors discuss adapting the vocabulary approach to query and key weights, as well as using linear mappings or activation patching to improve access to representations that are hard to read directly. Patchscopes

A second limit is the vocabulary itself. If an operation depends on several words forming an idiom, an input’s position, or a feature without a convenient token representative, the matrix can fail to express it clearly. The multi-token experiment shows that scores learned from the available single-token examples can track a head’s behavior on some longer sources. It leaves the static representation unchanged. In particular, success for a longer source such as a country name does not show that the matrix itself encodes arbitrary sequence-to-sequence operations.

The authors associate early-layer coverage with this representational limit. An early head can supply intermediate features for later processing, and those features may have no straightforward reading in terms of candidate output tokens. Reduced coverage in the final layers of the open-ended analysis is also an observation about what the pipeline could describe from salient mappings. Layerwise counts give an account of where the method finds visible operations. They cannot establish how much each layer contributes overall.

The simplified interaction-matrix formulation leaves out additive bias terms from the value and output transformations. The dynamic experiment includes the value bias when measuring a head’s output, so its agreement with MAPS is evidence that the omission often permits a useful estimate. Agreement varies by relation and context, and the paper leaves incorporation of the bias terms into the static analysis as future work. The open-ended pipeline also leaves scope for better coverage of negative mappings. The pre-defined suppression results show that such mappings already matter within the operations the authors chose to test.

Limits visible in the evaluation design

The relation percentages describe particular datasets and choices of rank cutoff. Changing the tokenizer can change which examples survive and how many close alternatives compete for a target. The wider cutoffs for Llama-3.1 address part of that issue. Because both the retained examples and the cutoffs can differ, comparisons across systems are most informative as patterns of recurring mappings and their relative strengths under the study’s rules. They give a weaker basis for claiming that one system has more of a general ability, such as translation, because it has more heads labeled for a particular token-pair dataset.

The rank test uses the target recorded in a pair. A relation like translation can involve several appropriate choices for a source, and the paper’s multilingual coverage comprises the translations it tests from English to French and Spanish. The linguistic inventory includes particular word forms and established pairings, such as past-tense variants selected during data construction. The experiment therefore gives substantial detail about the supported examples, with limited evidence about broad language coverage, ambiguity resolution, or which mapping an input sentence requires.

The causal tasks provide evidence of dependence under a defined intervention. The selected heads can number many, the removal zeroes everything each selected head writes at the final position, and the greedy answers are elicited by specific templates. A large accuracy loss supports a collective causal role for those outputs on that test. Identifying which individual heads are essential, which specific part of an output carries the effect, or how the head groups interact would require more targeted interventions. The available control tasks also vary by system and relation. The supplementary comparisons include cases with few qualifying controls, so the evidence of task specificity is stronger where the intervention can be tested across several well-matched alternatives.

Finally, the people who assessed the open-ended descriptions saw the mappings and judged what could be inferred from them. They did not establish the frequency of that operation in ordinary text or its role in a downstream task. The pipeline sometimes produces a plausible explanation for an unconvincing group of examples. Its automatic coverage measure also depends on a string check that treats responses containing clear as failures to detect a pattern, which the authors describe as giving an upper bound on the share of undetected patterns. The human results provide a more direct assessment of readable evidence, within the systems, samples, and criteria the annotators used.

What came after

The later citing studies address several settings where recognizing the behavior of a head can inform a further question. Their stated topics establish how the research questions relate to MAPS. The details of which MAPS calculations, head labels, or experimental procedures they adopted are unspecified.

Improving Chain-of-Thought for Logical Reasoning via Attention-Aware Intervention studies an attention-aware intervention in the context of chain-of-thought for logical reasoning. The point of contact is the move from examining attention components to changing their behavior during a task. Elhelo and Geva use intervention to see whether heads ranked from their weights matter to prediction. The later study’s stated goal concerns improving a reasoning process through intervention. That places task performance at the center of the follow-up question, with an intervention serving a different purpose from the diagnostic removals in MAPS.

Soft Head Selection for Injecting ICL-Derived Task Embeddings studies soft selection of heads for injecting task embeddings derived from in-context learning, where examples in an input supply information about the task. Its stated focus connects to the relation maps’ treatment of heads as graded candidates. MAPS gives each head a numerical score and uses a cutoff when a discrete inventory is needed. A study organized around soft selection asks how a downstream operation can use different heads to different degrees. Here the stated operation is embedding injection, which puts the emphasis on choosing where to introduce a task representation.

Unveiling Inherent Visual Grounding in Multimodal LLMs for Text-Rich Images investigates visual grounding in a vision and language setting. Its subject is the connection between a system’s processing and visual evidence in images containing text. It shares MAPS’s interest in uncovering functionality already present inside a system, while the stated domain extends to representations drawn from images. In that setting, a natural counterpart to the source-side question is how information from visual input reaches a component whose output can influence language. The vocabulary projection in MAPS supplies one account of how to read a writing transformation when its inputs can be represented by tokens. The later study’s topic locates the related interpretability question in a setting where the source of the information can be visual.

Cite

Cite as Amit Elhelo and Mor Geva. 2025. Inferring Functionality of Attention Heads from their Parameters. Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers).

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2025.acl-long.866

@inproceedings{elhelo2025inferring,
  title = {{Inferring Functionality of Attention Heads from their Parameters}},
  author = {Amit Elhelo and Mor Geva},
  booktitle = {Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
  year = {2025},
  doi = {10.18653/v1/2025.acl-long.866},
  url = {https://doi.org/10.18653/v1/2025.acl-long.866}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/elhelo-2025-inferring-functionality-attention-heads-their/