potentialpaper

Retrieval-Augmented Generation as In-Context Optimization: A Gradient Descent Perspective

Mingchen Li, Jiatan Huang, Liang Zhao, hong yu

ICLR 2026 submission

Edit this page

Or clone it with git

The page gets its repository with its first edit, so start in the web editor.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

Abstract. Currently, it remains unclear whether in-context learning (ICL) can serve as an al- ternative mechanism for retrieval-augmented generation (RAG), and its underlying operation is still poorly understood and largely intuitive. In this paper, we propose that trained Transformers can be viewed as performing retrieval-augmented gen- eration through gradient descent. We start by proving a weight construction and showing the equivalence of data transformations induced by linear self-attention- based Transformer and RAG training on a regression loss. Motivated by this construction, we empirically demonstrate that, when trained on simple regression tasks, self-attention-only Transformers exhibit strong similarity to RAG models trained via gradient descent. This allows us, at least within the scope of regression problems, to gain a mechanistic understanding of how in-context learning can be leveraged to optimize RAG. Moreover, we observe that the distribution of the data critically affects the generalizability of the learned models in the non-linear setting, so we propose strategies to enhance the robustness of in-context learning (ICL) against distributional variability encountered in practice. Among these, we explore normalization techniques as one representative approach, showing that they can effectively improve both stability during training and generalization across domains.

Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.

Claim this paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

add · history

No versions are recorded yet: its preprint, the venues it went to and what they decided, the camera-ready. Missing a version?

We don't know of a submission of this paper to a venue with open reviews. Missing a submission?

Loading the discussion…