ChatPaper.aiChatPaper

告訴你的模型該關注哪裡:LLM 的事後注意力引導

Tell Your Model Where to Attend: Post-hoc Attention Steering for LLMs

November 3, 2023
作者: Qingru Zhang, Chandan Singh, Liyuan Liu, Xiaodong Liu, Bin Yu, Jianfeng Gao, Tuo Zhao
cs.AI

摘要

在人類撰寫的文章中,我們常常利用文本風格的微妙之處,例如粗體和斜體,來引導讀者的注意力。這些文本強調對於讀者理解所傳達的信息至關重要。當與大型語言模型(LLMs)互動時,我們有類似的需求 - 引導模型更加關注用戶指定的信息,例如指示。然而,現有方法受限於處理純文本,不支持這樣的機制。這促使我們引入PASTA - 後期注意力引導方法,一種允許LLMs閱讀帶有用戶指定強調標記的文本的方法。為此,PASTA識別出一小部分注意力頭部,並對它們進行精確的注意力重新加權,將模型的注意力引導到用戶指定的部分。類似提示,PASTA應用於推理時間,不需要更改任何模型參數。實驗表明,PASTA可以顯著增強LLMs遵循用戶指令或整合來自用戶輸入的新知識的能力,從而在各種任務上實現顯著的性能改進,例如對於LLAMA-7B的平均準確率提高了22%。我們的代碼公開在https://github.com/QingruZhang/PASTA。
English
In human-written articles, we often leverage the subtleties of text style, such as bold and italics, to guide the attention of readers. These textual emphases are vital for the readers to grasp the conveyed information. When interacting with large language models (LLMs), we have a similar need - steering the model to pay closer attention to user-specified information, e.g., an instruction. Existing methods, however, are constrained to process plain text and do not support such a mechanism. This motivates us to introduce PASTA - Post-hoc Attention STeering Approach, a method that allows LLMs to read text with user-specified emphasis marks. To this end, PASTA identifies a small subset of attention heads and applies precise attention reweighting on them, directing the model attention to user-specified parts. Like prompting, PASTA is applied at inference time and does not require changing any model parameters. Experiments demonstrate that PASTA can substantially enhance an LLM's ability to follow user instructions or integrate new knowledge from user inputs, leading to a significant performance improvement on a variety of tasks, e.g., an average accuracy improvement of 22% for LLAMA-7B. Our code is publicly available at https://github.com/QingruZhang/PASTA .
PDF152December 15, 2024