Fine-grained Analysis of In-context Linear Estimation: Data, Architecture, and Beyond

Recent research has shown that Transformers with linear attention are capable of in-context learning (ICL) by implementing a linear estimator through gradient descent steps. However, the existing results on the optimization landscape apply under stylized settings where task and feature vectors are assumed to be IID and the attention weights are fully parameterized. In this work, we develop a stronger characterization of the optimization and generalization landscape of ICL through contributions on architectures, low-rank parameterization, and correlated designs: (1) We study the landscape of 1-layer linear attention and 1-layer H3, a state-space model. Under a suitable correlated design assumption, we prove that both implement 1-step preconditioned gradient descent. We show that thanks to its native convolution filters, H3 also has the advantage of implementing sample weighting and outperforming linear attention in suitable settings. (2) By studying correlated designs, we provide new risk bounds for retrieval augmented generation (RAG) and task-feature alignment which reveal how ICL sample complexity benefits from distributional alignment. (3) We derive the optimal risk for low-rank parameterized attention weights in terms of covariance spectrum. Through this, we also shed light on how LoRA can adapt to a new distribution by capturing the shift between task covariances. Experimental results corroborate our theoretical findings. Overall, this work explores the optimization and risk landscape of ICL in practically meaningful settings and contributes to a more thorough understanding of its mechanics.

Paper

Similar papers

Peer review

Reviewer EE6j7/10 · confidence 4/52024-07-04

Summary

The paper studies the in-context learning capabilities of linear attention (ATT) and linear state space layers (SSM) on a linear regression task. It shows that for both ATT and SSM there exists a parametrization such that they perform as well as one step of preconditioned gradient descent (PGD) with optimal preconditioning in expectation, and that they cannot perform better. The authors then propose a model for retrieval-augmented generation where in-context examples and the final query are correlated. For PGD, they provide an approximate expression for the optimal preconditioning weights and the related loss and relate it to the optimal weights in the noiseless, i.i.d. case, showing how the correlations between in-context examples and query translate into an increased effective sample size. Next, the authors give an upper bound on the optimal expected loss (for 1-step PGD <=> ATT <=> SSM) in a low-rank adapter setting. Experiments validate the theoretical results. A final experiment shows some initial results hinting that the SSM model studied (H3) performs slightly better than linear attention in an online setting and with a non-stationary task.

Strengths

In terms of results, the main original contribution is the analysis of the model with correlated training examples and query points. However, the analysis of the SSM model in the appendix seems non-trivial and should therefore also be considered as a significant element of originality. The section on related work is well-written and covers relevant work. The problem setup is very clean, making it very easy to read and understand the results. All results are clearly stated with the necessary assumptions and accompanied by clear explanations. The questions studied are highly relevant to contemporary machine learning research and applications of AI.

Weaknesses

* The main result (12) is not stated as a theorem, and the derivation in the appendix is not completely rigorous. In particular, it is not clear under which conditions the approximation in l.558 is justified. Unless the conditions for the approximations to be valid are stated more clearly, it is difficult to extrapolate from the experimental results to the full claim (A2). * The result on LoRA is not interpreted, and it is not immediately clear what the implications are from the statement of the result. I am not sure if the result implies claim (A3). * The additional experimental results (Fig. 3) seem somewhat preliminary and detached from the rest of the paper. Based on these results, it is not clear that the part of claim (A1) claiming an advantage of H3 is fully supported by the evidence.

Questions

* Under which assumptions are the approximation in (12) valid? What is the nature of the approximations made in the proof of the statement (high probability, asymptotic, ...)? * Can you elaborate on how claim (A3) follow from (14)? * Define $\alpha$-correlated * l.342: wildly studied -> widely studied (?)

Rating

7

Confidence

4

Soundness

2

Presentation

3

Contribution

3

Limitations

The authors address the limitations of their work and acknowledge that their analyses are "not precise and fully formal".

Reviewer HGXo6/10 · confidence 4/52024-07-06

Summary

The authors examine the capabilities of Transformers with linear attention in performing in-context learning (ICL) by implementing a linear estimator through gradient descent. The existing studies mostly consider IID task and feature vectors and fully parameterized attention weights. This work expands on these studies by analyzing: 1. The landscape of 1-layer linear attention and 1-layer H3 (a state-space model), proving both can implement 1-step preconditioned gradient descent. 2. New risk bounds for retrieval augmented generation (RAG), showing benefits from distributional alignment. 3. The optimal risk for low-rank parameterized attention weights, illustrating how LoRA adapts to new distributions.

Strengths

The authors provide a comprehensive theoretical analysis of the landscape for ICL, extending existing results to more practical settings. It offers new insights into the benefits of distributional alignment and the capabilities of low-rank parameterization in attention mechanisms. The theoretical findings are supported by experimental results, enhancing the credibility of the conclusions.

Weaknesses

1. The analysis is limited to single-layer linear attention and linear distribution data, which might not fully capture the complexities of multi-layer architectures. 2. The RAG and LoRA analyses are not precise and fully formal.

Questions

1. How does the distributional alignment in RAG quantitatively affect the sample complexity of ICL? Are there specific metrics or case studies that illustrate these benefits in practical applications? 2. What are the limitations of LoRA in your cases? I believe LoRA significantly underperforms compared to fully parameterized models. If there are no limitations compared with the fully parameterized models because of the linear distribution data, can you talk about the relationship between the data distribution and LoRA. 3. The paper focuses on single-layer (linear) models. How do the findings extend to multi-layer (linear) architectures? 4. The paper discusses LoRA adaptation for distribution shifts. Are there practical examples or case studies where LoRA has been successfully applied to handle real-world distribution shifts? 5. The study primarily considers linear regression tasks. How would the insights gained from this study apply to more complex tasks, such as natural language processing or computer vision tasks that involve non-linear relationships?

Rating

6

Confidence

4

Soundness

3

Presentation

3

Contribution

3

Limitations

As mentioned in Weakness: 1. The analysis is limited to single-layer linear attention and linear distribution data, which might not fully capture the complexities of multi-layer architectures. 2. The RAG and LoRA analyses are not precise and fully formal.

Reviewer LuUw5/10 · confidence 3/52024-07-15

Summary

This paper studies how transformers can use ICL to solve linear regression problems. It is shown that state space models, transformers are both capable of performing linear regression as well as gradient descent (which implements the least squares solution). There are results about LORA and RAG.

Strengths

The presentation is clear.

Weaknesses

The analysis of vanilla regression is not novel, I think, and has been done for instance in Theorem 1 of Ahn et al (transformers learn to do preconditioned gradient descent) where it is even shown that a pretrained transformer (with GD) learns to do this in a similar setting (which is stronger than showing that it can learn it). Maybe for SSMs this result is new but I am not sure how strong of a contribution this is considering that it only establishes the existence of such a solution.

Questions

What is the significance of the RAG result? It makes sense that giving the learner access to $\beta$ through $X$ directly improves the error. A comparison to some reasonable baseline might be a nice story if it came about that transformers are able to leverage this kind of side information particularly well. What i mean is to compare this with a loss like $\Vert y-X\beta\Vert^2 -\Vert X\beta\Vert^2 + \Vert \beta\Vert^2$ which is aware of this kind of side information. What is the significance of the LoRA result? A decomposition of the optimal error in terms of the singular values of a covariance is shown and then it is observed that if the covariance changes in a specific way (I think the singular vectors have to remain fixed), then LoRA can help. What role does Lemma 1 play? This is not about LoRA, but rather for an entirely low rank model. Why does linear attention perform better for shorter contexts than it was trained on (Figure 3a)? How does Figure 3b show that H3 is better at generalizing to a longer context length if the plot is discontinued at the context it was trained on? I noticed that the performance on varying $\beta$ in Figure 3d better than the iid noiseless case. Can you elaborate on that? Is this for a fixed (that is, rather than varying) $\beta$?

Rating

5

Confidence

3

Soundness

3

Presentation

3

Contribution

1

Limitations

Yes

Reviewer LuUw2024-08-09

I had a misunderstanding about the RAG section. Please disregard what I said. I thought $x$ was sampled as $\mathcal(\alpha \beta, (1-\alpha)I)$. Because of the clarifications on the experiments, and the contributions relating to SSMs (equivalences to PGD), I change my score from 3 to 5. However, I still feel the following about the Transformer results: 1. The LoRA discussion holds only when the new and old $\Sigma$ are jointly diagonalizable and this makes the message a little weak, but it is possible that this is truly the only benefit from LoRA on a single layer. 2. Using the present model to study RAG still seems somewhat simplistic to me. These are difficult to fix, since this is a critique of the model itself. The results themselves seem reasonable to me.

Authorsrebuttal2024-08-12

We thank the reviewer for reassessing our work and for raising their rating. We would like to provide further clarifications on their comments: 1. For low-rank parameterization, our main technical result is Lemma 1. This result does not rely on the assumption of diagonalization and establishes a natural generalization of fully-parameterized results (Theorem 1) to the low-rank setting. In LoRA analysis, we assume diagonalization mostly to be able to provide closed form interpretable bounds on its impact in terms of eigenspace. We anticipate one can establish similar upper bounds on the impact of LoRA in terms of the angle between the eigenspaces of old and new covariance matrices. Finally, it worths noting that the analysis of general covariance is challenging even for vanilla ICL (fully parameterized) as both Ahn et al. and Mahankali et al. make assumptions about the covariance of $\beta$ and/or $x$ while we allow for arbitrary $x$, $\beta$ covariances in our main results. 2. Our RAG model is inspired from real RAG systems [[Karpukhin et al.](https://arxiv.org/pdf/2004.04906), [Lewis et al.](https://arxiv.org/pdf/2005.11401)], which utilize cosine similarity of the document (feature) embeddings. However, we agree with the reviewer that exploring more complex RAG models, either with general covariance models or allowing for nonlinear feature/document representations learned via a separate retriever model, would be valuable. This is certainly an exciting direction for future work and we appreciate their suggestion.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC