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



to validate the effectiveness of the attention head mask. By

                                                                       Table 1. Numbers of attention heads selected in the masks, and

convenience, we refer to the 8B-instruct version of Llama

                                                                       the metrics of translation tasks from English to other 6 languages.

3.1 as Llama3.18B-inst in this paper, and other models follow          “Original” uses no instructions nor masks, and “w/ instruction”

similar patterns. We use LM Transparency Tool (Tufanov                 adds explicit translation prompts to the original model. “Random

et al., 2024) to probe the logit outputs inside the models.            M” shuffles the task mask and has the equal number of heads.

                                                                       Bold and underline indicate the best and second-best scores.

Tasks and datasets We train the head mask on two types

of tasks: simple tasks and machine translation. Simple tasks                    Method             en-zh   en-fr   en-es   en-de   en-ru   en-ar

are taken from the work by Todd et al. (2024), including 35            Llama3.18B-inst

datasets of relatively simple tasks like generating antonyms           - # of heads in M           832     860     846     862     828     837

and extracting items. Machine translation uses the XNLI                  PPL (↓)

                                                                       - Original                  2.643   2.172   2.319   2.314   2.327   2.730

(Conneau et al., 2018) parallel corpus for 15 languages,               - w/ instruction            1.091   0.619   0.550   0.627   0.954   1.303

and we choose English, Chinese, French, Spanish, German,               - w/ random M               2.909   2.370   2.762   2.482   2.677   3.204

Russian and Arabic (en, zh, fr, es, de, ru, ar) for translation.       - w/ M                      1.017   0.552   0.504   0.580   1.055   1.322

                                                                       - w/ M of Llama3.18B        2.269   1.114   1.061   1.612   2.105   2.381

These 7 languages can be combined into 42 translation pairs              ROUGE-L (↑)

for a broad generalization of the head mask. Both types                - Original                  0.020   0.082   0.069   0.069   0.045   0.029

of tasks have the characteristic that models can hardly                - w/ instruction            0.539   0.541   0.599   0.576   0.491   0.414

                                                                       - w/ M                      0.589   0.711   0.748   0.677   0.401   0.427

generate the desired output solely based on the input                  - w/ M of Llama3.18B        0.019   0.204   0.241   0.099   0.046   0.045

unless they are explicitly instructed on the task to be                Llama3.18B

performed. For each dataset, we select 100 samples as                  - # of heads in M           819     809     811     816     795     821

the evaluation set, and the remaining samples are used for               PPL (↓)

                                                                       - Original                  2.308   1.672   1.853   1.780   1.824   2.434

training. Details of these datasets are listed in Appendix A.          - w/ instruction            1.901   1.240   1.350   1.258   1.573   1.945

                                                                       - w/ random M               2.703   2.329   2.337   2.133   2.377   3.251

                                                                       - w/ M                      1.158   0.585   0.577   0.660   1.142   1.867

3.4. Experiment Results

                                                                       - w/ M of Llama3.18B-inst   2.213   1.512   1.515   1.480   1.754   2.393

                                                                         ROUGE-L (↑)

Following the paradigm defined above, we train head masks              - Original                  0.017   0.072   0.067   0.066   0.045   0.030

for different tasks on various models. Our finding is: these           - w/ instruction            0.017   0.084   0.080   0.076   0.054   0.029

masks extensively work on all the tasks, and such attention            - w/ M                      0.424   0.658   0.657   0.606   0.179   0.067

                                                                       - w/ M of Llama3.18B-inst   0.016   0.071   0.074   0.076   0.037   0.030

head combinations trigger the functionalities on both pre-

trained and instruction fine-tuned models.

Evaluation results We report the perplexity (PPL) and                  partial attention heads selected by M only can trigger the

ROUGE-L (Lin, 2004) of Llama3.18B-inst and Llama3.18B                  model functionality, and significantly improve the accuracy

on 6 English translation tasks, as shown in Table 1. With the          of these tasks. The results on other tasks and experiments

mask M, by removing 15%-20% attention heads from the                   on Qwen2.57B-inst , Qwen2.57B are listed in Appendix C.1,

model, both models can reach better or comparable scores               and on simple tasks the pre-trained model Qwen2.57B also

than the full models with explicit translation instructions            exhibits well functionality.

(e.g. “Translate into Chinese:”). As an ablation, randomly             Besides, we found that the model’s few-shot in-context

selecting an equal number of attention heads results in a              learning functionality can also be enhanced by applying the

higher PPL than the original full model, indicating that the           head mask, as shown in Table 3. For the 6 representative

learned M effectively covers the attention heads necessary             simple tasks, we constructed 5-shot demonstration samples

for the task. Additionally, we attempt to swap the masks               (without instructions) for each task. The masks trained using

between pre-trained and instruction models for the same                these samples generally outperform the original model with

task, finding that their PPL also decreases compared to the            instructional 5-shot samples. Furthermore, we mix the 5-

original full model. Appendix C.1 presents the experiment              shot data from 32 out of 35 simple tasks to form a 5-shot

results on other translation pairs and models. Except for              multi-task hybrid dataset. After training the mask on this

the relatively poor performance on Qwen2.50.5B-inst , other            hybrid dataset, the model demonstrates improved few-shot

models consistently yield similar conclusions.                         in-context learning performance across various tasks, even

Simple tasks also show the similar phenomenon. We select               including those not seen in the training data. This suggests

6 representative tasks out of 35 in Table 2: sentiment (clas-          that the attention head mask can also promote the model’s

sification), antonym (semantic), capitalize_first_letter (pat-         abstract functionality of in-context learning.

tern), product-company (knowledge), conll2003_location                 Larger model shows better head functionality As a part

(recognition) and fruit_v_animal_3 (logic). In this genera-            of scaling validation, when using the head mask to trigger

tion scenario, the original full model can hardly generate             translation functionalities, we find that larger LLMs tend

the desired output without task instructions. Instead, using           to have better results. In Table 4, we show the genera-



                                                                   4

