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

                                                                                                  0

C.3. More Removal Experiments

                                                                                                500





C.3.1. O NE - BY-O NE H EAD R EMOVAL                                                        1000



                                                                                            1500









                                                                                   Token rank

In the one-by-one head removal experiment depicted in Fig-                                  2000

ure 2, we unveil the model’s translation functionality by                                   2500

removing a certain amount of attention heads. We provide                                    3000                                                                                                              That

                                                                                                                                                                                                              It

more detailed results to enhance the conclusions that: (1) the                              3500

                                                                                                                                                                                                              L

                                                                                                                                                                                                              I

                                                                                                                                                                                                              However

model behavior change is not caused by removing certain                                     4000

                                                                                                            0         32         64      96         128         160     192         224    256         288     320

independent, influential attention heads; (2) the model can                                                                                           Removed heads



maintain its original behavior as long as the functional path-                                    0

way remains intact, even if the model loses more attention                                      500

heads.                                                                                      1000





Remove by influential order Figure 2 involves many                                          1500









                                                                                   Token rank

target token’s rank surges when removing certain attention                                  2000





heads, and we claim that removing heads in the order of                                     2500



                                                                                                                                                                                                              That

target token’s rank increments caused by each head will not                                 3000

                                                                                                                                                                                                              It

                                                                                                                                                                                                              L

                                                                                                                                                                                                              I

accelerate the switch in model behavior. To verify this point,                              3500

                                                                                                                                                                                                              However



we select the first 320 heads from the ascending order of the                               4000

                                                                                                            0         32         64      96         128         160     192         224    256         288     320

                                                                                                                                                      Removed heads

task head weight, and for these 320 heads, we re-order them

by the target token’s rank increment caused by each head                Figure 8. Prompt Llama3.18B-inst with “I see a llama sleeping in

in descending order. Then we remove these heads one by                  my backyard.”, and remove the first 320 attention heads from the

one and compare their token rank changes with the original              full model by head weight of en-zh translation task in different

order. The token rank changes are illustrated in Figure 8. In           orders. We use a gray vertical line to indicate where the target

this influential order, the model could indeed perform higher           token becomes the top-1 token. Top: In original ascending order

                                                                        of head weights. Bottom: In descending order of target token’s

target token rank in the early stage, but its domination is

                                                                        rank increments.

postponed to around 290 heads. Therefore, removing more

influential heads does not necessarily lead to a faster switch

                                                                                      0                                                                                                                              That

in the model behavior.                                                                                                                                                                                               It

                                                                                                                                                                                                                     L

                                                                                   500                                                                                                                               I

                                                                                                                                                                                                                     However

Remove on the negative initialized mask We provide                             1000



the token ranks and the model outputs of the negative ini-                     1500

                                                                      Token rank









tialized mask in Figure 9. The behavior switch of the model                    2000

happens at removing the 355th head, which is nearly 200

                                                                               2500

heads later than the results in Figure 2. Although it loses

                                                                               3000

more attention heads, the model can still maintain certain

                                                                               3500

instruction following behavior before the switch.

                                                                               4000

                                                                                                      0         64   128   192    256   320   384         448   512   576     640   704   768    832    896   960       1024

                                                                                                                                                     Removed heads

C.3.2. Q UERY-H EAD R EMOVAL

                                                                         # of removed                     Generated outputs

Equation (2) actually applies M on the value heads of the                                      0

                                                                                               1

                                                                                                          That’s quite a surprise! Llamas are not typically found in backyards, so it’s

                                                                                                          That’s quite a surprise! Llamas are not typically found in backyards, so it’s

MHA layer, and it ignores the attention scores calculated by                                  ...

                                                                                            235

                                                                                                          ...

                                                                                                          That’s a pretty interesting sight! I’ve seen a llama sleeping in my backyard before, but I

                                                                                            236           I see a llama sleeping in my backyard.

query and key heads. To explore whether such masks can                                        ...         ...

                                                                                            297           I see a llama sleeping in my backyard.

be applied to the attention scores, we move the mask value                                  298

                                                                                            312

                                                                                                          You’re not seeing a llama sleeping in your backyard, you’re seeing a llama sleeping in your backyard

                                                                                                          That’s a pretty surreal scene! A llama sleeping in your backyard! Maybe it’s just a visitor

inside the softmax function in Equation (1) to make it work                                 341

                                                                                            342

                                                                                                          You’re looking at a llama that’s sleeping in your backyard.

                                                                                                          I see a llama sleeping in my backyard.

                                                                                              ...         ...

on the query (also key) head outputs. In this configuration,                                354           I see a llama sleeping in my backyard.

                                                                                            355           我看到一只羊在我的后院睡觉。(I see a sheep sleeping in my backyard.)

masking out a head means that the head pays uniformly                                         ...

                                                                                            693

                                                                                                          ...

                                                                                                          我看到一只羊在我的后院睡觉。(I see a sheep sleeping in my backyard.)

                                                                                                          我看到一只在我家中睡眠。(I see a sleeping in my house.)

equal attention to all the input tokens. Nevertheless, the                                  694

                                                                                            695           我在我的后院看到睡牛。(I see sleeping ox in my backyard.)

                                                                                            742           我看到一只睡在我的后院的后院。见到一只睡在我的 (I see a backyard sleeping in my backyard. See a sleeping in my)

training of this query-head mask fails to steadily trigger the                              743

                                                                                            786

                                                                                                          I see a llama sleeping in my backyard.

                                                                                                          I see a llama sleeping in my backyard.user.sideassistant.help

model functionality on most of the tasks. As described in                                   798

                                                                                              ...

                                                                                                          user’s helpmate’s helpmate’s helper’s helper’s helper’s helper’s helper’s helper’s

                                                                                                          ...



Section 4, the attention head mask is not only a simple se-

lection of higher or lower attention scores, and even unused            Figure 9. In the negative initialization scenario, we prompt

heads are still working to focus on important tokens. This              Llama3.18B-inst with “I see a llama sleeping in my backyard.”,

can explain why the query-head mask fails to work. Table                and remove attention heads from the full model by head weight of

39 shows a case study of failed translations.                           en-zh translation task in ascending order. Use the same notations

                                                                        as in Figure 2.



                                                                 23

