In-context learning with attention allows transformers to make personalized predictions by attending to relevant training examples, flexibly adapting to heterogeneous data. This inspired us to revisit local regression. When predicting for a test observation, in-context learning upweights similar training examples, where "similarity" can be defined in a supervised manner; local regression weights typically rely only on covariates and may be suboptimal. This paper introduces a supervised learning framework inspired by in-context learning with simplified attention. As a leading example, we propose attention lasso, which fits a personalized lasso for each prediction point by weighting training examples using a supervised similarity metric. To control complexity, we use a shared lasso penalty and blend local models with a global model via a cross-validated parameter. This framework works with other learners, like gradient boosting, and extends to time series and spatial data. We give theory for a hard-attention variant that fits the lasso in the nodes of a single CART tree: in a sparse, continuous, piecewise affine model, it recovers the support and coefficient signs of each query's local linear model, and when the regression function is not affine it has lower prediction risk than every global affine fit, including the lasso.
翻译:暂无翻译