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





Table 2. Numbers of attention heads selected in the masks, and the                                   Table 4. Left: After applying the head masks, the generated results

accuracy of 6 representative simple tasks. Using the same notation                                   of the English input "I have never seen such a beautiful sunset."

as in the Table 1.                                                                                   across different sizes of models. We use green to highlight the

                                                                                                     correct translations, yellow for partially correct translations, and

                             senti-    anto-    capitalize      product-   conll2003   fruit v

         Method                                                                                      red for incorrect translations. Right: Top output tokens and their

                             ment      nym      first letter    company     location   animal

Llama3.18B-inst                                                                                      logits on Qwen2.50.5B-inst . Upper (a) is with the M of task en-de,

- # of heads in M             745       834         774           754         787        827         and lower (b) is with the explicit translation instruction.

  Accuracy (↑)

- Original                    0.01      0.12        0.15          0.06        0.00       0.00

- w/ instruction              0.59      0.30        0.97          0.73        0.41       0.51        Model & Task         Prediction

- w/ M                        0.86      0.76        1.00          0.83        0.92       0.98        Qwen2.50.5B-inst

- w/ M of Llama3.18B          0.64      0.75        0.98          0.78        0.75       0.87        - en-zh              我从未见过如此美丽的日落。

                                                                                                     - en-fr              Je n’ai jamais vu tellement une belle lueur de ciel.

Llama3.18B                                                                                           - en-es              I’m sorry, but I can’t provide the exact description of a sunset ...

- # of heads in M             679       726         678           674         670        786         - en-de              I’ve never seen such a beautiful sunset.

  Accuracy (↑)

- Original                    0.00      0.13        0.00          0.07        0.07       0.00

                                                                                                     Qwen2.51.5B-inst

                                                                                                     - en-zh              我从未见过如此美丽的日落。

                                                                                                                                                                                                    (a) w/ M

- w/ instruction              0.91      0.66        1.00          0.75        0.79       0.99        - en-fr              Je n’ai jamais vu un coucher de soleil aussi beau.

- w/ M                        0.80      0.66        0.99          0.76        0.79       0.97        - en-es              He nunca había visto un solsticio tan hermoso.

- w/ M of Llama3.18B-inst     0.00      0.11        0.06          0.35        0.37       0.43        - en-de              I can’t say I’ve ever witnessed one like that before.

                                                                                                     Qwen2.53B-inst

                                                                                                     - en-zh              我从没见过如此美丽的日落。

                                                                                                     - en-fr              J’ai jamais vu un tel coucher de soleil si beau.

Table 3. Accuracy of 6 representative simple tasks in the 5-shot                                     - en-es              Nunca había visto una puesta de sol tan hermosa.

                                                                                                     - en-de              Ich habe nie so ein wunderschönes Sonnenuntergang gesehen.

scenario on Llama3.18B-inst . Italic indicates that the correspond-                                                                                                                                (b) w/ inst

ing task is not included in the hybrid dataset (unseen during the

training).                                                                                           Table 5. Jaccard similarities of head masks on 12 tasks between

                                                                                                     Llama3.18B-inst and Llama3.18B . “Random” calculates the math

                            senti-    anto-    capitalize      product-    conll2003   fruit v       expectation of Jaccard similarity on two randomly shuffled masks.

        Method

                            ment      nym      first letter    company      location   animal

Original, 5-shot            0.96      0.56        0.95           0.77        0.61       0.98            Task             en-zh             en-fr            en-es            en-de               en-ru   en-ar

w/ instruction, 5-shot      0.97      0.67        1.00           0.84        0.72       1.00

w/ M, 5-shot                0.99      0.73        0.99           0.88        0.95       1.00         Similarity           0.766            0.766            0.797            0.802               0.740   0.762

w/ M of hybrid, 5-shot      0.98      0.69        1.00           0.88        0.82       1.00          Random              0.675            0.687            0.679            0.693               0.656   0.680



                                                                                                                                                         capitalize        product-        conll2003     fruit v

                                                                                                        Task            sentiment       antonym

                                                                                                                                                         first letter      company          location     animal

tion examples of four translation pairs on Qwen2.5 series.                                           Similarity           0.591            0.707            0.612            0.634               0.615   0.707

Smaller models suffer from difficulties in triggering target                                          Random              0.531            0.610            0.545            0.533               0.547   0.649

functionality (e.g. Qwen2.50.5B-inst on en-es directly takes

the input as instruction), aligning to the target language                                           This makes us believe that the pre-trained models have al-

(e.g. Qwen2.50.5B-inst on en-de), and accurately translating                                         ready learned some task-related knowledge in the attention

the sentence. From the perspective of attention heads, as                                            heads during the next-token prediction pre-training. As

larger models usually have more attention heads, there are                                           swapping the head masks can also trigger certain function-

more combinations of heads available to correspond to more                                           alities in some cases, we further investigate the similarity

functionalities. On the other hand, Qwen2.50.5B-inst and                                             of the selected attention heads between the pre-trained and

Qwen2.51.5B-inst have the same amount of attention heads,                                            instruction models. For two masks of Llama3.18B-inst and

but the latter has larger hidden size and more parameters                                            Llama3.18B on the same task, we calculate the Jaccard sim-

in FFN layers, which may work better to process the func-                                            ilarity of the selected attention heads. Table 5 shows that

tionality from incomplete MHA output. A more illustrative                                            the mask similarity is generally higher than the random

example is shown in Table 4a and 4b, where we probe                                                  expectation, but still lower than identical 1.0, as masks of

the last layer’s output logits on the last token of the input.                                       the instruction model tend to use more heads. We suppose

When using the head mask of the translation task en-de,                                              that the instruction model inherits most of the attention

Qwen2.50.5B-inst takes “I” as the top-1 token, but German                                            head functionalities from the pre-trained model, and also

words “Es” (It), the expected “Ich” (I) and Russian “Я” (I)                                          introduces new functionalities that are not present in the

are also in top tokens. In contrast, with the explicit instruc-                                      pre-trained model during the instruction fine-tuning.

tion, the model can correctly predict the token “Ich” as the

top-1 token. This suggests that the small models may have

difficulty in distinguishing and triggering the functions of                                         4. Attention Head Selection Forms Functional

different attention heads.                                                                              Pathways

Pre-trained models also possess functionalities Even                                                 In this section, we further investigate how the combination

though pretrained models (base models without instruction                                            of selected attention heads triggers the task functionality

fine-tuning) generally perform worse than instruction fine-                                          in the LLM. We first define the functional pathway as a

tuned models on both types of tasks, we observe that they                                            group of interdependent attention heads that work together

still exhibit certain functionalities, especially in simple tasks.                                   to enable specific functionalities. In the following experi-



                                                                                                 5

