# Oral 31798

- Kind: Oral
- Talk page and recording: https://iclr.cc/virtual/2025/oral/31798

> Transcript of the talk's recording (session_asr), made by speech recognition or taken from the host's captions. It may contain errors. The words are the speakers'; listen to the recording on the talk's page before quoting it.

Hello everyone, uh we are honoured to have uh our presentation at Iclear Art Iclear. I'm Zhen Hongzhou and I will be a st PhD student in Computing and Data Science at NTU this fall. Uh this paper was conducted during my internship at Tongyi lab and uh you'll be lead supervision. Uh in this paper we comprehensively incrop is proud a role of attention hides in
Large language model safety. Next I will introduce our work to you.
Uh first let I start with an interesting and important question. Why do large local models generate harmful content? The answer is easy to understand. These models are trained upon my style inter internet style data size. And as a result, they are able to learn harmful knowledge during pre-training. Although the proportion of these data is small, but uh models still learn wild because the total amount of
amount of the data are large. After the model is pretrained, the this harmful knowledge are store in the model's parameters. Take an uh take understand
Because standard large volume model has an example. Such knowledge can be encoded across different layers of the model. When the user query the model with a malicious question, or a job request, the model will prepare to answer by activity and passing along through layer uh layer by layer computation.
Uh a common view in the community is that uh MLPs are more responsible for understanding the semantics of the input. In particular, individual neuronal in MLP layers play a key role in encoding such meanings. This is the motto seem to understand the query why there is unsafe by MLPs more.
This will have been supported, support by several r recent started. There are many some recent well known works through it, such as sparse auto-encoder. Uh when it comes to the role of attention in safety, there is still relative limited investigation, that's reasonable because attention typically is sought to address the bias of sequence more than semantical understanding.
However, it attention really irrelevant to safety. Uh in this work we aim to uh comprehensively study how multi-head attention contributes to um safety uh and most specifically how it interact with safety. Okay, uh it is also while
Knowing that uh different attention hides in multi-hide attention, specialized in different functions across general task, uh for example there are some inducing hides, uh retrieval hides and others, uh based on this we propose a simple but powerful intuition. Uh they're
Uh different attention height may also have different role when it comes to safety. Uh in particular there uh some height may act as uh safety height. They may play uh unique role in safety. Uh at the beginning we guessed that there might be some height uh that specialise in recognising the work the harmful word in malicious query while jailbreak inf interface in
BioT outbreak uh impact with the classification of these hides. With the this item in mind we began to explore this question. However, before we can analyse the role of potential hides in safety, we face a practical challenge. How should we able to add individual attention hide?
Uh previous work high attempts to directly mask out zero out the output of a attention high because uh but it often not work well. Uh in our in our work we propose uh more frigginged application applications strategy. Ist still is in spite of modi modifying the final attention output, we independently scale our mask the query key and the value matrix.
for each hand. Uh in our paper, we perform this application by applying a mo small scale scaling factors epsilon to the query key and the value matrix of a specific uh attention high. Uh interestingly, we find the that
When we scale Q our K matrix uh since these matrices are used inside the softmax operation the effect of this of the scaling becomes equivalent. Uh this operation calls the original attention weights to degrade into a row-wise average, removing the the high ability to wide sequence just we as we guessed.
We refer to this type of addition as I-indifferentate uh uh attention. Or uh on the other hand, we s also scale we s uh it it's simply results in scaling the output of the attention height which we call scaling contribution. This minor sort of height uh similar effect to directly uh scaling the attention output.
And now that we have an effective abolition method, the next question is how can we use it to identify safety related higher. In current large round models, even at attention high level, uh, uh, seven
The Lama has a more than one thousand different height. So there must be an efficient way to do this. A straightforward approach is to alphabetic each height uh generate b response on a malicious question dataset. Uh and then check whether the output become harmful.
However, this cost of this method is still expensive. Since it requires full full power passed and response evaluation for each height, even if we evaluate one thousand harmful data, the final evaluation volume is one million. Uh ins side uh we propose a more efficient and elegant uh method. And since the
Not drunk model is trained to reject harmful question with similar response. We assume that any deviation from this typical safety distribution of rejection response could be a signal of unsafe behavior. To formalize this idea, we then define safety parameters as the first k parameters when the KL divergence of the model's response to harmful question is the largest after being updated.
In this formulation, uh X_sub_H is uh is a harmful question. Uh set sub o_ designates uh the original model parameters. Uh set sub C_ repre represents candidate parameters. And black slash indicates the admission of specific uh parameters. Set sub C_
Uh simply put, if the large language models response to more harmful questions after a certain parameter is removed, uh it means that it has a impact on safety.
Based on these, we not only applied the same idea to attention height, specifically we ask for a given harmful queries X_H with attention height one, update it, called the model's response distribution to safety the most. Uh to quantify this, we introduce the safety height importance score to evaluate the change of the model safety after updating attention in some way.
which is used to identify those important high. Uh for for harmful query Q_sub_H, if a high uh if a high H_sub_I_ in the layer L_ of the of update operation makes its output probability distribution change more, uh then we think it is uh it is important for safety in this problem.
Uh after identified and ablating the most important safety height for a given harmful query, we observe the uh clear and significant drop in model safety. In particular, the you and differentiate attention ablation method proved to be more effective in relieving such safety and sensitive height.
This finding proves strong empirical evidence for our hypothesis. Tension hides don't contribute equally to safety some play to safety some plays uh much more critical roles. Considering that finding the most important hide for each sub subphysic specific query may not generalize well, we further expand the strips to the data site level.
Given a harmful query, the SiteQSubH, we collect the model output before the and after applying each attention head. Uh we then merge this output across the data sites into matrix matrix theta and matrix application application. Uh next we apply a singular value decomposition to obtain a live singular matrix U sub theta and the U sub application.
Finely we computed the principal angles between U sub theta and U sub I ablation. A simplified visualization is shown on the right. Just like the just like in the query level setting, a large angular differ difference indicates that this is a quite strongly influenced model behaviour on the harmful data side.
Uh while shifts hide us indeed find whether a single attention hide is important for safety. It doesn't not it doesn't capture interaction uh among multiple hides. User in reality several hides may work together to support safety behaviours. To address this, we propose the safety hide hide attribution algorithm uh hierarchic method to search
uh for a group of higher that c that contributes to safety. Uh experimental results support our institution obligating multiple safety ha related higher together called a stronger degradation in safety compared to obligating them individually. Combine the privacy experimental
If pyramid host results are under-mised or we try to give some analyse about the safety height. We believe that the main role of the safety height is to extract safety relative related information from the sequence. On the other hand hand uh from the ad actual impact of differentiate uh t uh attention uh evaluating the ability of uh specific uh height to pay attention to the sequence will greatly
reduce safety. On the other hand, the previous studies including our including our use of scaling contribution to modified output of a certain height are usually not as good as and differentiate attention. Another interesting conclusion is that pruning is important for safety.
Uh we ana analyzed uh safety height distribution of lambda two and Vikuna, both of which are trained for lambda two base. The results are shown in the figures, and we found that their consistence is very good, which confirmed our hypothesis to a certain extent.
Uh and we compared the performance of some printing method on several there was on several results uh task as shown by dotted line. Uh the results show that safety height found be by our method has an impact on performance um but it within a assignable range.
sum up. Our work dem demonstrate that different attention heights play different roles in large amount of safety. By introduce chips and our uh attribution algorithm, we prob new insight on in defining and extending safety relevant con components inside the large amount of models. Uh Thank you for your attention and you can scan the QR code for our paper.
Uh so when you identify these uh kind of safety heads, yeah, can it be used for uh defending against fine-tuning attacks or like even like further fine-tuning the the models for for downstream tasks to be able to actually uh preserve the s the safety capabilities of the model? Uh to be honest, uh we have now try try to uh fine-tuning the model safety by our findings. Uh I
uh and the V_ are is powering the uh f filters some filter work to uh use our attention hides to do this. Great. Any other questions? Uh if not, let's thank the speaker.
