                                                   Large Language Models Can Perform Tasks Without Instruction via Selective Attention Head Masking

                                                                                                         31

                                    1.0                                                                  30

                                                                                                         29

                                                                                                         28               Table 7. Average attention scores of attention heads on the target

                                                                                                         27

Cosine similarity of FFN layer output





                                                                                                         26

                                                                                                         25

                                    0.8                                                                  24

                                                                                                         23

                                                                                                                          word. These tasks require selecting 1 word that differs from the

                                                                                                         22

                                                                                                         21

                                                                                                         20

                                                                                                                          others among 3 words (so the uniform score is 0.33). We calculate

                                    0.6                                                                  19

                                                                                                         18

                                                                                                         17

                                                                                                                          the attention score of each attention head on these words for the









                                                                                                          Layer No.

                                                                                                         16

                                                                                                         15

                                                                                                         14

                                                                                                                          last token of the input, normalize it, and then sum up the attention

                                    0.4                                                                  13

                                                                                                         12

                                                                                                         11

                                                                                                                          on all tokens of the target word as the values below.

                                                                                                         10

                                                                                                         9

                                                                                                         8

                                    0.2                                                                  7                                                 adjective v   object v    verb v     fruit v

                                                                                                         6

                                                                                                         5                Method

                                                                                                         4                                                    verb       concept    adjective   animal

                                                                                                         3

                                                                                                         2

                                    0.0                                                                  1                Original, all heads                0.352        0.306      0.314      0.347

                                                                                                         0

                                          0   32     64   96   128   160   192   224   256   288   320

                                                                Removed heads                                             w/ instruction, all heads          0.409        0.363      0.345      0.468

                                                                                                                          w/ instruction, heads in M         0.408        0.356      0.353      0.462

           Figure 5. Remove attention heads from the full model by weight                                                 w/ instruction, heads in 1 − M     0.413        0.386      0.316      0.494

           ascending order, and the cosine similarities of hidden states be-                                              w/ M, heads in M                   0.462        0.471      0.426      0.566

                                                                                                                          w/ M, heads in 1 − M               0.484        0.537      0.379      0.607

           tween w/ instruction and w/ M after each decoder layer. Darker

           lines indicate later layers (closer to the model output).





             the shallower layers have not yet processed much about                                                       with the previous findings that the selected attention heads

             functionality, and removing attention heads reduces their                                                    are not independently triggering the functionality, but are

             capacity to handle language and semantic processing.                                                         forming pathways to activate the model.



           Attention head mask is not selecting attention scores

           Although the attention head selection involves the model’s                                                     5. Attention Head Selection Potentially

           attention mechanism, we did not explore how this selection                                                        Improves Model Performance

           affects token attention scores in the previous discussion.

                                                                                                                          In Table 6, we notice that removing translation-unrelated

           Normally, in the attention layer, the model attends to the

                                                                                                                          attention heads can decrease the perplexity of the model

           preceding tokens with varying attention scores. However,

                                                                                                                          on the translation task. This suggests that the model may

           since our attention selection is independent of instructions,

                                                                                                                          inherently possess a better ability to perform specific tasks,

           the model’s attention will not focus on nonexistent instruc-

                                                                                                                          but this ability is suppressed by the noise of other attention

           tion tokens. Especially in some simple tasks, the model

                                                                                                                          heads outside the pathway to better handle a broader range

           input is just a single token, and there is little space for the

                                                                                                                          of tasks. To measure the influence of unselected heads

           attention mechanism to work around. From this perspective,

                                                                                                                          to the task, we introduce a scaling factor α ∈ [0, 1] on

           such functionality is unlikely caused by simply selecting

                                                                                                                          the outputs of attention heads outside M, and in this case

           attention heads that are more focused on the target.

                                                                                                                          the head mask can be written as M = I(σ(M) ≥ 0.5) +

           We verify this hypothesis by calculating the average atten-                                                    αI(σ(M) < 0.5). We conduct a grid search on 6 explicitly

           tion score distribution of heads on 4 extractive simple tasks                                                  instructed translation tasks of XNLI with Llama3.18B-inst .

           on Llama3.18B-inst as they have explicit target tokens in the                                                  As shown in Figure 6, it can be observed that using masks

           inputs. The input to these tasks is a set of words, and the                                                    to remove attention heads outside the pathway (α = 0)

           objective is to extract the target one that is different from the                                              consistently results in lower PPL than using all attention

           others. As shown in Table 7, for the original model without                                                    heads (α = 1). Meanwhile, this scaling method is not

           task instructions, the model does not pay significant atten-                                                   a simple linear interpolation between the full model and

           tion to the target word, and as expected, the instructed model                                                 the zero-masked model, but a convex combination of the

           has higher attention scores on the target word. However, if                                                    two: using a small α around 0.2 or 0.3 can achieve a lower

           we separately calculate the average attention scores of heads                                                  PPL. To further verify the performance improvement of the

           in and out of the task mask M, we find that the selected at-                                                   model in the generation scenario, we conduct evaluations

           tention heads do not necessarily have higher attention scores                                                  using the additional translation dataset IWSLT2017 (Cettolo

           (even lower in 3 out of 4 tasks) on the target word. This                                                      et al., 2017). Under the condition of providing the same

           indicates that the head selection is not based on the attention                                                translation instructions, we compare the score differences

           scores of the instructed model. Even in the masked model,                                                      between the original model and the model with the scaled

           attentions to the target word are further promoted, but the                                                    M applied. As shown in Table 8, using M consistently

           unused heads still have high attention scores on the target                                                    improves the model’s BLEU scores on these translation

           word, notwithstanding they are not involved in the model                                                       tasks, and applying a small scaler α can offer further slight

           inference. Such anomaly in attention scores suggests that                                                      enhancements. From this perspective, selecting attention

           the selection of attention heads functions more as influenc-                                                   heads can better showcase the model’s inherent but hindered

           ing the overall behavior of the model. This is consistent                                                      capabilities, potentially improving its performance.



                                                                                                                      8

