Softplus Attention with Re-weighting Boosts Length Extrapolation in Large Language Models
Abstract
Lay Summary
Large language models often struggle when they are asked to read much longer text than they saw during training. A key reason is the attention mechanism, the part of the model that decides which earlier words or tokens are most relevant. In this work, we redesign attention so that it first produces stable scores and then sharpens them to focus more strongly on important information. Our method, called LSSAR, helps models trained on short text work better on much longer inputs without changing the position encoding or retraining from scratch. We show that this improves long-context language modeling and retrieval tasks. We also test the method on a physics-inspired problem, where a model observes orbital trajectories and predicts gravitational forces. The results suggest that better attention mechanisms can help models learn meaningful structure from data, such as the inverse-square pattern of gravity, rather than only improving benchmark scores. This may help future models reason more reliably over long documents and scientific data.