Saved in:
Bibliographic Details
Main Authors: Zhang, Xuechen, Chang, Xiangyu, Li, Mingchen, Roy-Chowdhury, Amit, Chen, Jiasi, Oymak, Samet
Format: Preprint
Published: 2024
Subjects:
Online Access:https://arxiv.org/abs/2411.12892
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916488651210752
author Zhang, Xuechen
Chang, Xiangyu
Li, Mingchen
Roy-Chowdhury, Amit
Chen, Jiasi
Oymak, Samet
author_facet Zhang, Xuechen
Chang, Xiangyu
Li, Mingchen
Roy-Chowdhury, Amit
Chen, Jiasi
Oymak, Samet
contents The attention mechanism within the transformer architecture enables the model to weigh and combine tokens based on their relevance to the query. While self-attention has enjoyed major success, it notably treats all queries $q$ in the same way by applying the mapping $V^\top\text{softmax}(Kq)$, where $V,K$ are the value and key embeddings respectively. In this work, we argue that this uniform treatment hinders the ability to control contextual sparsity and relevance. As a solution, we introduce the $\textit{Selective Self-Attention}$ (SSA) layer that augments the softmax nonlinearity with a principled temperature scaling strategy. By controlling temperature, SSA adapts the contextual sparsity of the attention map to the query embedding and its position in the context window. Through theory and experiments, we demonstrate that this alleviates attention dilution, aids the optimization process, and enhances the model's ability to control softmax spikiness of individual queries. We also incorporate temperature scaling for value embeddings and show that it boosts the model's ability to suppress irrelevant/noisy tokens. Notably, SSA is a lightweight method which introduces less than 0.5% new parameters through a weight-sharing strategy and can be fine-tuned on existing LLMs. Extensive empirical evaluations demonstrate that SSA-equipped models achieve a noticeable and consistent accuracy improvement on language modeling benchmarks.
format Preprint
id arxiv_https___arxiv_org_abs_2411_12892
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Selective Attention: Enhancing Transformer through Principled Context Control
Zhang, Xuechen
Chang, Xiangyu
Li, Mingchen
Roy-Chowdhury, Amit
Chen, Jiasi
Oymak, Samet
Machine Learning
Computation and Language
The attention mechanism within the transformer architecture enables the model to weigh and combine tokens based on their relevance to the query. While self-attention has enjoyed major success, it notably treats all queries $q$ in the same way by applying the mapping $V^\top\text{softmax}(Kq)$, where $V,K$ are the value and key embeddings respectively. In this work, we argue that this uniform treatment hinders the ability to control contextual sparsity and relevance. As a solution, we introduce the $\textit{Selective Self-Attention}$ (SSA) layer that augments the softmax nonlinearity with a principled temperature scaling strategy. By controlling temperature, SSA adapts the contextual sparsity of the attention map to the query embedding and its position in the context window. Through theory and experiments, we demonstrate that this alleviates attention dilution, aids the optimization process, and enhances the model's ability to control softmax spikiness of individual queries. We also incorporate temperature scaling for value embeddings and show that it boosts the model's ability to suppress irrelevant/noisy tokens. Notably, SSA is a lightweight method which introduces less than 0.5% new parameters through a weight-sharing strategy and can be fine-tuned on existing LLMs. Extensive empirical evaluations demonstrate that SSA-equipped models achieve a noticeable and consistent accuracy improvement on language modeling benchmarks.
title Selective Attention: Enhancing Transformer through Principled Context Control
topic Machine Learning
Computation and Language
url https://arxiv.org/abs/2411.12892