Attention layers provably solve single-location regression

## Abstract

Abstract. Attention-based models, such as Transformer, excel across various tasks but lack a comprehensive theoretical understanding, especially regarding token-wise sparsity and internal linear representations. To address this gap, we introduce the single-location regression task, where only one token in a sequence determines the output, and its position is a latent random variable, retrievable via a linear projection of the input. To solve this task, we propose a dedicated predictor, which turns out to be a simplified version of a non-linear self-attention layer. We study its theoretical properties, by showing its asymptotic Bayes optimality and analyzing its training dynamics. In particular, despite the non-convex nature of the problem, the predictor effectively learns the underlying structure. This work highlights the capacity of attention mechanisms to handle sparse token information and internal linear structures.

## 1. Introduction

Attention-based models (Bahdanau et al., ), such as Transformer (Vaswani et al., ), have achieved unprecedented performance in various learning tasks, including natural language processing (NLP), e.g., text generation (Bubeck et al., ), translation (Luong et al., ), sentiment analysis (Song et al., ; Sun et al., ; Xu et al., ), and audio/speech analysis (Bahdanau et al., ). These developments have led to many architectural and algorithmic variants of attention-based models (see the review by Lin et al., ). At a high level, the success of attention has been linked to its ability to manage long-range dependencies in input sequences (Bahdanau et al., ; Vaswani et al., ), since attention consists in computing pairwise dependence between input tokens according to their projection in learned directions, independently of their location in the sequence.

On the theoretical front, however, a deeper understanding of attention-based neural networks is still in its infancy. This limited progress is due both to the complexity of the architectures and to the disturbing diversity of relevant tasks. A common approach to tackle these challenges is to introduce a simplified task that models certain features of real-world tasks, followed by demonstrating a simplified version of the attention mechanism capable of solving the task. Prominent examples of this pattern include studying in-context learning with linearized attention (Ahn et al., ; von Oswald et al., ; Zhang et al., ), topic understanding with a single-layer attention and alternate minimization scheme (Li et al., ), learning spatial structure with positional attention (Jelassi et al., ), and next-token prediction with certain bigram structures (Bietti et al., ; Tian et al., ).

While these works shed light on some abilities of Transformer, they do not encompass all the characteristics of tasks where Transformer performs well, in particular in NLP. Two features of particular interest, which to our knowledge have not been addressed in previous theoretical studies on Transformer, are token-wise sparsity, where relevant information is contained in a limited number of tokens, and internal linear representations, which are interpretable representations of the input constructed by the model.

Contributions.  To understand why attention is a suitable architecture for addressing these features, we introduce single-location regression, a novel statistical task where attention-based predictors excel (Section 2). In a nutshell, this task is a regression problem with a sequence of tokens as input. The key novelty is that only one token determines the prediction, and the location of this token is a latent random variable that changes based on the input sequence. Consequently, solving the task requires first identifying the location of the relevant token, which can be done by learning a latent linear projection, followed by performing regression on that token.

To tackle this problem, we propose a dedicated predictor, which turns out to be a simplified version of a non-linear self-attention layer. We show that this attention-based predictor is asymptotically Bayes optimal, whereas more standard linear regressors fail to perform better than the null predictor.
We then analyze the training dynamics of the proposed predictor, when trained to minimize the theoretical risk by projected gradient descent. Despite the non-convexity of the problem and the non-linearity of this transformer-based method, we show that the learned predictor successfully retrieves the underlying structure of the task and thus solves single-location regression.

Organization.  Section 2 presents the mathematical framework of single-location regression, followed by motivations from language processing.
Section 3 is dedicated to defining our predictor and explaining its connection with attention. We then move on to the mathematical study, from both statistical (Section 4) and optimization (Section 5) points of view.
Section 6 presents the outline of the proof of our main mathematical result, while Section 7 concludes the paper.

## 2. Single-location regression task

In this section, we describe our statistical task, and connect it to language processing motivations.

### 2.1. Statistical setting

We consider a regression scenario where the inputs are sequences of $L$ independent random tokens(^1^11For the sake of simplicity, we interchangeably use the terms “token” and “embedding”, although they have different meanings in the NLP community.)
$(X_{1},\ldots,X_{L})$ taking values in $\mathbb{R}^{d}$.
The output $Y\in\mathbb{R}$ is assumed to be given by

$$ $\displaystyle Y$ $\displaystyle=X_{J_{0}}^{\top}v^{\star}+\xi,$ ( $P_{\mathrm{learn}}$ ) $$

where $J_{0}$ is a latent discrete random variable on $\{1,\ldots,L\}$ and,
conditionally on $J_{0}$,

$$ $\left\{\begin{array}[]{lll}X_{J_{0}}&\sim&{\mathcal{N}}\Big{(}\sqrt{\frac{d}{2 }}k^{\star},\gamma^{2}I_{d}\Big{)}\\ X_{\ell}&\sim&{\mathcal{N}}(0,I_{d})\quad\textnormal{for}\quad\ell\neq J_{0}\, .\end{array}\right.$ $$

In the above formulation, ${\mathcal{N}}(\mu,\Sigma)$ denotes the normal distribution with expectation $\mu$ and covariance matrix $\Sigma$, and $I_{d}$ is the identity matrix of size $d\times d$. All vectors are considered as column matrices, and the noise term $\xi$ is assumed to be a centered random variable independent of $X$ and $J_{0}$, with finite second-order moment $\varepsilon^{2}$. Conditionally on $J_{0}$, the tokens $(X_{j})_{1\leqslant j\leqslant L}$ are assumed to be independent.

The parameters of the regression problem ($P_{\mathrm{learn}}$) are the unknown vectors $k^{\star}$ and $v^{\star}$, both assumed to be on the unit sphere $\mathbb{S}^{d-1}$ in dimension $d$, i.e., $\|k^{\star}\|_{2}=\|v^{\star}\|_{2}=1$. The output is determined by a specific token in the sentence, indexed by the discrete random variable $J_{0}$ on $\{1,\ldots,L\}$. This token can be detected via its mean, which is proportional to $k^{\star}$, contrarily to the others which have zero mean. Once $X_{J_{0}}$ is identified, the prediction is formed as a linear projection in the direction $v^{\star}$. Therefore, the originality and difficulty of this task lies in the fact that the response $Y$ is linearly related to a single informative token $X_{J_{0}}$, whose location varies from sequence to sequence—in this sense, the problem is sparse, but with a random support.

A knee-jerk reaction would be to fit a linear model to the pair $(X_{1}^{\top},\ldots,X_{L}^{\top},Y)$. One might also consider tackling the problem with classical statistical approaches dedicated to sparsity, such as a Lasso estimator or a group-Lasso technique (Hastie et al., ). However, as we will see (in Section 4), all linear predictors fail due to the unknown and changing location of $J_{0}$.
We note in addition that $\mathbb{E}[\|X_{\ell}\|_{2}^{2}]=d$ when $\ell\neq J_{0}$, while $\mathbb{E}[\|X_{J_{0}}\|_{2}^{2}]=d/2+\gamma^{2}d$. Therefore, choosing $\gamma^{2}=1/2$ implies that
tokens are of the same squared norm in expectation, whether they are discriminatory of not. This shows that any approach based on comparing the magnitude of the tokens does not yield meaningful results. Ultimately, it is necessary to implement a more sophisticated approach, capable of taking into account the characteristics of the problem.

Finally, note that our task shares similarities with single-index models (McCullagh and Nelder, ) and mixtures of linear regressions (De Veaux, ). However, in our case, solving the task requires first learning $k^{\star}$ in order to identify $J_{0}$, followed by linear regression. Thus, $\eqref{pb:learning_pb}$ has a more structured nature, involving sequence-valued inputs and incorporating a single-location pattern.

### 2.2. Language processing motivation

The structure of the task ($P_{\mathrm{learn}}$) is motivated by natural language processing (NLP), and more specifically by two features, token-wise sparsity and internal linear representations, as we detail next.

Figure: (a) Examples of input-output pairs. The input is a text containing two sentences (e.g., a question and an answer), and the task is to perform sentiment analysis only for the second sentence. The $Y$ label is symbolized here by shades of color, where green (resp. red) corresponds to positive (resp. negative) feelings. The relevant information to determine the label is sparse, typically concentrated in a single token (in grey): changing this token flips the output label.
Refer to caption: x1.png

Token-wise sparsity.  In many NLP tasks, the most relevant information is contained in a few tokens, where we recall that tokens correspond to small text units (typically, words or subwords), which are embedded in ${\mathbb{R}}^{d}$ using a learnt dictionary. This sparsity structure is revealed by the line of work on sparse attention (see, e.g., Martins and Astudillo, ; Niculae and Blondel, ; Correia et al., ; Child et al., ; Jaszczur et al., ; Kim et al., ; Farina et al., ), which obtains similar performance to full attention despite attending to a small fraction of tokens at each step.
To illustrate this, we consider a simple sentiment analysis task in Figure 1(a), and observe that changing one token flips the output label.
This is modeled in ($P_{\mathrm{learn}}$) by having the output $Y$ depend on a single token $J_{0}$, whose location furthermore varies depending on the input, as in NLP.

Internal linear representations.  Linear projections of internal representations of Transformer (a.k.a. linear probing) allows to retrieve interpretable information about the input (see, e.g., Bolukbasi et al., ; Burns et al., ; Li et al., , and references therein). Such a linear structure is also present in the learned token embeddings that are fed as input to language models (Mikolov et al., , ; Bolukbasi et al., ; Nanda et al., ; Wen-Yi and Mimno, ). In our task ($P_{\mathrm{learn}}$), the two directions $k^{\star}$ and $v^{\star}$ have to be learned by the model in order to solve the task. Figure 2 gives an example of such directions for the toy task described above. Note that this illustration relies on initial embeddings, but we emphasize that similar structures also appear in the intermediate representations of Transformer. This is shown in Figure 1(b), where we observe that pretrained Transformer architectures indeed build internal representations that are sufficient to solve the toy NLP task with a linear classifier.

Figure: Figure 2. Modeling of an NLP task within our statistical setting ($P_{\mathrm{learn}}$). The token embeddings $X_{1},\dots,X_{L}$ are constructed by adding the embeddings of each word and a positional encoding. For illustration purposes, we assume that each token corresponds to a word, and that the positional encoding solely depends on the part of the sentence (before or after the question mark), which differs from usual practice. Then, let the direction $k^{\star}$ encode both the notion of sentiment and the position in the second part of the sentence. Thus only the last token of the sentence is aligned (positively) with $k^{\star}$, and we have $J_{0}=L$. As for $v^{\star}$, it encodes whether the word is associated with a positive or negative sentiment. Note that several tokens are positively or negatively aligned with $v^{\star}$, but the output $Y$ only depends on the token $J_{0}$. This illustrates the interest of having two latent directions $k^{\star}$ and $v^{\star}$, one that filters the informative token and one that aligns with the output $Y$.
Refer to caption: x3.png

We acknowledge that our modeling of NLP tasks presents limitations such as fixed sequence length, independent tokens, and output depending only on a single token.
More complex and realistic models could be considered, but they require costly technical adjustments. Moreover, as we argue above, our problem ($P_{\mathrm{learn}}$) still preserves interesting aspects of NLP tasks, which makes it a relevant test bed for theoretical study of Transformer. Furthermore, from a statistical perspective, this is an original task that requires the implementation of a customized estimation strategy. It is precisely in this context that attention models prove their effectiveness, as we demonstrate next.

## 3. An attention-based predictor to solve the regression task

In this section, we propose a predictor adapted to the problem ($P_{\mathrm{learn}}$) and discuss its connection with attention. In order to make our point as clear as possible, the construction is divided into three steps. We represent the input sequence in a matrix format $\mathbb{X}\in{\mathbb{R}}^{L\times d}$, where $\mathbb{X}=(X_{1}|X_{2}|\cdots|X_{L})^{\top}$.

Step 1: An oracle non-differentiable predictor.  If the vectors $(k^{\star},v^{\star})\in(\mathbb{S}^{d-1})^{2}$ were known, then a natural procedure to solve the task ($P_{\mathrm{learn}}$) would be to predict $Y$ from $\mathbb{X}$ via

$$ $T(\mathbb{X})=(\mathbb{X}v^{\star})_{j_{0}(\mathbb{X})}=X_{j_{0}(\mathbb{X})}^ {\top}v^{\star}\,,\quad\textnormal{where}\quad j_{0}(\mathbb{X})=\operatorname *{arg\,max}_{1\leqslant\ell\leqslant L}\,(\mathbb{X}k^{\star})_{\ell}\,.$ (1) $$

The $\operatorname*{arg\,max}$ part detects the location $J_{0}$ by exploiting the fact that all $X_{\ell}$ have zero mean except $X_{J_{0}}$, while the $\mathbb{X}v^{\star}$ part exploits the linear relationship $Y=X_{J_{0}}^{\top}v^{\star}+\xi$.
In a more compact format, this ideal predictor can be rewritten as

$$ $\displaystyle T(\mathbb{X})=\sum_{\ell=1}^{L}\mathbbb{1}_{\operatorname*{arg\, max}(\mathbb{X}k^{\star})=\ell}(\mathbb{X}v^{\star})_{\ell}\,,$ $$

which is a linear regression in the direction $v^{\star}$ with non-differentiable weights depending on $k^{\star}$.

Step 2: A trainable predictor.  In practice, the vectors $k^{\star}$ and $v^{\star}$ are unknown and must be estimated from the data. In addition, the non-differentiability of the $\operatorname*{arg\,max}$ function poses significant optimization challenges. To solve this problem, the most common approach in machine learning is to replace $\operatorname*{arg\,max}$ with a softmax function with inverse temperature $\lambda>0$, i.e., for $z=(z_{1},\ldots,z_{L})\in~{}\mathbb{R}^{L}$, $[\mathrm{softmax}(\lambda z)]_{j}={e^{\lambda z_{j}}}/{\sum_{\ell=1}^{L}e^{
\lambda z_{\ell}}}$. This leads us to the model

$$ $T_{\lambda}^{(\text{soft},k,v)}(\mathbb{X})=\sum_{\ell=1}^{L}[\mathrm{softmax} (\lambda\mathbb{X}k)]_{\ell}(\mathbb{X}v)_{\ell}=\mathrm{softmax}\big{(} \lambda\underbrace{\mathbb{X}k}_{L\times 1}\big{)}^{\top}\underbrace{\mathbb{X }v}_{L\times 1},$ (2) $$

where $k,v\in\mathbb{S}^{d-1}$, and the superscript ‘soft’ is used to indicate the presence of the softmax function.

Step 3: The final predictor.  The softmax nonlinearity, by inducing a coupling between all tokens, significantly complicates the mathematical analysis. To alleviate this difficulty, we replace it by the component-wise nonlinear function $\mathrm{erf}(z)=\frac{2}{\sqrt{\pi}}\int_{0}^{z}e^{-t^{2}}dt$, which is differentiable, increasing on ${\mathbb{R}}$, and such that $\mathrm{erf}(-\infty)=-1$ and $\mathrm{erf}(\infty)=1$. We are therefore led to our operational model

$$ $\displaystyle T_{\lambda}^{(k,v)}(\mathbb{X})=\mathrm{erf}\big{(}\lambda \mathbb{X}k\big{)}^{\top}\mathbb{X}v=\sum_{\ell=1}^{L}\mathrm{erf}\big{(} \lambda{X}_{\ell}^{\top}k\big{)}X_{\ell}^{\top}v\,,$ (3) $$

where the $\mathrm{erf}$ function is applied component-wise.
We emphasize that empirically, this simplification of softmax using a component-wise nonlinearity has been shown not to degrade performance in Transformer architectures (Hron et al., ; Shen et al., ; Wortsman et al., ).

Connection to attention.  It turns out that our estimation method finds a natural interpretation in terms of attention models. To see this, consider a model consisting of a single attention layer with a single head (Vaswani et al., )

$$ $\displaystyle T_{\lambda}^{(Q,K,V,O)}(\mathbb{X})$ $\displaystyle=\mathrm{softmax}\Big{(}\lambda\underbrace{\mathbb{X}Q}_{L\times p }\underbrace{\vphantom{q}K^{\top}\mathbb{X}^{\top}}_{p\times L}\Big{)} \underbrace{\mathbb{X}V}_{L\times p}\underbrace{O^{\top}}_{p\times o}\,,$ (4) $$

where the dimensions $p,o\in\mathbb{N}^{*}$ are hyperparameters of the model, the softmax function is applied row by row, $Q,K,V\in\mathbb{R}^{d\times p}$ and $O\in\mathbb{R}^{o\times p}$ are the regular query, key, value, and output matrices, and $\lambda$ is usually taken to be $1/\sqrt{p}$.
In practice, the attention head is added to $\mathbb{X}$ via a skip connection, which enforces $o=d$.
In a nutshell, $K$ detects which tokens are relevant in the sentence, $V$ encodes the regression coefficient, and $Q$ encodes where we store the information.

In a supervised context, it is classical in practice to concatenate in first position an additional token [CLS] to the tokenized sentence $\mathbb{X}$ (see, e.g., Devlin et al., ). In this context, only the first coordinate of the output is used for the prediction task. Thus, we focus on the first row of (4), corresponding to the embedding of [CLS], namely

$$ $\displaystyle T_{\lambda}^{(Q,K,V,O)}(\mathbb{X})_{1}=\mathrm{softmax}\left( \lambda\,a\,K^{\top}\mathbb{X}^{\top}\right)\mathbb{X}VO^{\top},$ (5) $$

with $a=X_{\textnormal{[CLS]}}^{\top}Q\in{\mathbb{R}}^{1\times p}$, where $X_{\textnormal{[CLS]}}\in\mathbb{R}^{d}$ denotes the embedding of the [CLS] token.

It is important to note that only considering the first output coordinate is a valid simplification for a single attention layer, but not when multiple layers are stacked, as all coordinates of the attention output contribute. Nevertheless, even in this latter more realistic case, the [CLS] token—or the similar concepts of attention sinks and registers—has been empirically shown to play a crucial role (Clark et al., ; Darcet et al., ; Xiao et al., ). This is also confirmed by our experiment in Figure 1(b), where we show that the [CLS] token in pretrained Transformer architectures stores an internal representation of the sentence that is sufficient to solve simple NLP tasks with a linear classifier. This further motivates the need to understand how information is stored in this token.

It turns out that there is a direct connection between the model $T_{\lambda}^{(\text{soft},k,v)}(\mathbb{X})$ defined in (2) and the attention model $T_{\lambda}^{(Q,K,V,O)}(\mathbb{X})_{1}$ described in (5). To see this, take $o=1$, to adapt the model (5) for univariate regression, and set $p=1$, a reasonable assumption given both empirical and theoretical evidence suggesting that Transformer parameter matrices are low-rank (Aghajanyan et al., ; Kajitsuka and Sato, ). Then, let $Q\in{\mathbb{R}}^{d\times 1}$ be any vector with positive correlation with $X_{\textnormal{[CLS]}}$ (for instance it suffices to take $Q=X_{\textnormal{[CLS]}}$), and $O=1$. We then deduce that

$$ $T^{(Q,K,V,O)}_{\lambda}(\mathbb{X})_{1}=T_{\lambda X^{\top}_{\textnormal{[CLS] }}Q}^{(\text{soft},K,V)}(\mathbb{X})\,.$ $$

In other words, the attention layer (5) matches the considered predictor in (2) with a softmax inverse temperature proportional to the scalar product between $X_{\textnormal{[CLS]}}$ and $Q$.
Thus, our results, in particular the study of the training dynamics in Section 5, can be seen as a model of how Transformer builds internal linear representations of the input during training.

## 4. Risk of the oracle and of the linear predictors

Now that we have constructed our predictor $T_{\lambda}^{(k,v)}$ (see Eq. (3)), a first key question is to assess its statistical performance. Recall that $k,v\in\mathbb{S}^{d-1}$ are the two parameters of the model, and their purpose is to approximate their theoretical counterparts $k^{\star}$ and $v^{\star}$ defined in (1). This begs in particular the question of the performance of the oracle predictor $T_{\lambda}^{(k^{\star},v^{\star})}$.
To answer these questions, we introduce the risk of the predictor, which is measured by the mean squared error

$$ $\displaystyle{\mathcal{R}}_{\lambda}(k,v)$ $\displaystyle=\mathbb{E}\Big{[}\Big{(}Y-T_{\lambda}^{(k,v)}(\mathbb{X})\Big{)} ^{2}\Big{]}\,.$ (6) $$

To proceed with the analysis, we make the following assumption.

###### Assumption 1 .

The vectors $k^{\star},v^{\star}\in\mathbb{S}^{d-1}$ are orthogonal, i.e., $k^{\star\top}v^{\star}=0$.

This assumption is made everywhere in the paper, even though it is not reminded explicitly at each result. This assumption is relatively mild in a high-dimensional setting where any two independent vectors uniformly distributed on the sphere are close to being orthogonal.

Oracle predictor.  Our first result characterizes the risk of the proposed transformer model (3) with oracle parameters $(k^{\star},v^{\star})$.
All the proofs of the paper are deferred to the Appendix.

###### Theorem 1 .

There exists a function $\mathcal{R}_{\lambda}^{<}:{\mathbb{R}}^{5}\to{\mathbb{R}}$ such that, for any $(k,v)\in(\mathbb{S}^{d-1})^{2}$,

$$ $\mathcal{R}_{\lambda}(k,v)=\mathcal{R}_{\lambda}^{<}(\kappa,\nu,\theta,\eta, \rho)\,,$ $$

where $\kappa:=k^{\top}k^{\star}$, $\nu:=v^{\top}v^{\star}$, $\theta:=v^{\top}k^{\star}$, $\eta:=k^{\top}v^{\star}$, and $\rho:=k^{\top}v$. A closed-form expression of $\mathcal{R}_{\lambda}^{<}$ is given in Appendix B.
In particular,

$$ $\displaystyle\mathcal{R}_{\lambda}(k^{\star},v^{\star})$ $\displaystyle=\mathcal{R}_{\lambda}^{<}(1,1,0,0,0)$ $\displaystyle=\gamma^{2}-2\gamma^{2}\,\mathrm{erf}\bigg{(}\lambda\sqrt{\frac{d }{2(1+2\lambda^{2}\gamma^{2})}}\bigg{)}+\gamma^{2}\zeta\Big{(}\lambda\sqrt{ \frac{d}{2}},\lambda^{2}\gamma^{2}\Big{)}+(L-1)\zeta(0,\lambda^{2})+ \varepsilon^{2}\,,$ $$

where, for $t,\gamma\in\mathbb{R}$,

$$ $\zeta(t,\gamma^{2}):=\mathbb{E}\left[\mathrm{erf}^{2}(t+G)\right]\,,\qquad G \sim\mathcal{N}(0,\gamma^{2})\,.$ (7) $$

This result is fundamental for the analysis of gradient descent studied in the next section since it reduces the dimension of the dynamical system defined by the optimization dynamics. Before delving into the optimization analysis, we study below the statistical optimality of the estimator $\mathcal{R}_{\lambda}(k^{\star},v^{\star})$ and its comparison with linear regression.

Asymptotic Bayes optimality.  Let us start by observing that the Bayes risk associated with problem ($P_{\mathrm{learn}}$) is larger than $\varepsilon^{2}$, which follows from elementary properties of the conditional expectation (Le Gall, , Chapter 11). Indeed, using the Pythagorean theorem, one easily shows that

$$ $\mathbb{E}[(Y-\mathbb{E}[Y|X])^{2}]\geqslant\mathbb{E}[(Y-\mathbb{E}[Y|X,J_{0} ])^{2}]=\mathbb{E}[\xi^{2}]=\varepsilon^{2}\,.$ (8) $$

Then, the following corollary to Theorem 1 shows that the oracle predictor achieves the Bayes-optimal risk in the asymptotic scaling $L\ll 1/\lambda^{2}\ll d$.

###### Corollary 2 .

Assume a joint asymptotic scaling where $d\to\infty$ and $L=o(d)$. Taking $\lambda$ such that $\lambda\sqrt{d}\to\infty$ and $\lambda\sqrt{L}\to 0$, we have

$$ $\mathcal{R}_{\lambda}(k^{\star},v^{\star})\xrightarrow{}\varepsilon^{2}\,.$ $$

Thus, in this asymptotic regime, the oracle predictor $T_{\lambda}^{(k^{\star},v^{\star})}$ is asymptotically Bayes optimal.

Note that Corollary 2 holds for any finite $L\in{\mathbb{N}}_{>0}$, but $L$ may also tend to infinity, as long as $L=o(d)$.
Let us give an intuition on why this result holds and where the scalings of $L$ and $\lambda$ intervene. The oracle predictor can be decomposed as

$$ $\displaystyle T_{\lambda}^{(k^{\star},v^{\star})}(\mathbb{X})=\underbrace{X_{J _{0}}^{\top}v^{\star}}_{=\mathbb{E}[Y|\mathbb{X},J_{0}]}\mathrm{erf}( \underbrace{\lambda X_{J_{0}}^{\top}k^{\star}}_{=\Theta(\lambda\sqrt{d})})+ \sum_{j\neq J_{0}}\underbrace{X_{j}^{\top}v^{\star}}_{=\Theta(1)}\mathrm{erf}( \underbrace{\lambda X_{j}^{\top}k^{\star}}_{=\Theta(\lambda)})$ (9) $$

With the scaling $\lambda\sqrt{d}\to\infty$, the argument of the first $\mathrm{erf}$ nonlinearity diverges to infinity with $d$. Thus it reaches the saturating part of $\mathrm{erf}$, so the first term in (9) converges to $\mathbb{E}[Y|\mathbb{X},J_{0}]$. On the other hand, the argument of the $\mathrm{erf}$ nonlinearities inside the sum are of order $\lambda=o(1)$. Thus they are in the linear part of $\mathrm{erf}$. Therefore, the sum consists of $L-1$ independent terms, each of magnitude $\lambda$. As a consequence, the whole sum is of order $\Theta(\lambda\sqrt{L})$, and we get

$$ $\displaystyle T_{\lambda}^{(k^{\star},v^{\star})}(\mathbb{X})\approx\mathbb{E} [Y|\mathbb{X},J_{0}]+\Theta(\lambda\sqrt{L})\,.$ $$

Due to the scaling $\lambda\sqrt{L}\to 0$, we obtain that the second term decays to zero, and the oracle predictor therefore implements the conditional expectation of $Y$ given $\mathbb{X}$ and $J_{0}$. This is the best that we can hope for: the predictor succeeds in inferring the latent variable $J_{0}$, then gives the best possible prediction of $Y$ given $\mathbb{X}$ and $J_{0}$.
We also see here the crucial role played by the nonlinearity $\mathrm{erf}$, whose linear part acts for $j\neq J_{0}$ and saturating part for $j=J_{0}$. In particular, such a reasoning would not hold if we had simply taken a linear function instead of $\mathrm{erf}$.

Linear model.  The asymptotic optimality of our oracle predictor is particularly striking in comparison to the risk of the optimal linear predictor. More precisely, let

$$ $\beta^{\star}\in\operatorname*{arg\,min}_{\beta\in{\mathbb{R}}^{dL}}\mathbb{E} \Big{[}(Y-(X_{1}^{\top},\ldots,X_{L}^{\top})\beta)^{2}\Big{]}$ $$

be the optimal linear predictor for the regression task ($P_{\mathrm{learn}}$). Its associated risk is
$\mathcal{R}(\beta^{\star})=\mathbb{E}\big{[}(Y-(X_{1}^{\top},\ldots,X_{L}^{
\top})\beta^{\star})^{2}\big{]}$. Both the optimal predictor and its risk can be explicitly characterized as follows.

###### Proposition 3 .

Let $p_{j}=\mathbb{P}(J_{0}=j)$ for $j\in\{1,\dots,L\}$. Then the optimal linear predictor is parameterized by

$$ $\beta^{\star}=\begin{pmatrix}b_{1}v^{\star}\\ \vdots\\ b_{L}v^{\star}\end{pmatrix}\,,\quad b_{j}=\frac{\gamma^{2}p_{j}}{1+p_{j}( \gamma^{2}-1)}\,,$ $$

and its risk is

$$ $\mathcal{R}(\beta^{\star})=\varepsilon^{2}+\gamma^{2}-\gamma^{4}\sum_{j=1}^{L} \frac{p_{j}^{2}}{1+p_{j}(\gamma^{2}-1)}\,.$ $$

In particular,

$$ $\mathcal{R}(\beta^{\star})\geqslant\varepsilon^{2}+\gamma^{2}-\gamma^{2}( \gamma^{2}+1)\max_{j=1,\dots,L}p_{j}\,.$ $$

This result calls for a few comments. If the number of tokens is $L=1$ or if $J_{0}$ is a constant location (meaning that one $p_{j}$ is equal to $1$ while the others are equal to 0 0), then the learning problem ($P_{\mathrm{learn}}$) corresponds to a standard linear regression. In this case, $\mathcal{R}(\beta^{\star})=\varepsilon^{2}$, and the linear predictor $(X_{1},\ldots,X_{L})\mapsto(X_{1}^{\top},\ldots,X_{L}^{\top})\beta^{\star}$ achieves the Bayes risk.

Figure: Figure 3. Risk of the oracle predictor (Theorem 1, solid lines) and of the best linear predictor (Proposition 3, dashed lines), depending on the dimensions $d$ and $L$. The oracle predictor outperforms the linear predictor when scaling $d$. We take $\varepsilon^{2}=0$, $\gamma=1/\sqrt{2}$, $\lambda=1/d^{0.4}$, and all $p_{j}$ equal to $1/L$.
Refer to caption: x4.png

At the other end of the spectrum, in the case where $J_{0}$ is uniform over $\{1,\dots,L\}$, the formula for the risk of the linear predictor simplifies to $\mathcal{R}(\beta^{\star})=\varepsilon^{2}+\gamma^{2}-\frac{\gamma^{4}}{\gamma
^{2}+L-1}$. When $L\to\infty$, this risk tends to $\varepsilon^{2}+\gamma^{2}$, that is, the performance of the null predictor. In other words, the optimal linear predictor performs no better than always predicting zero. More generally, this conclusion is true in any limit where $L\to\infty$ and $\max p_{j}\to 0$. This can be explained by the fact that the location of the relevant token for prediction is random, varying from sentence to sentence. Unable to leverage this latent information, the linear regressor balances all its coefficients, resulting in uniformly poor prediction performance. This stands in sharp contrast to Corollary 2, which shows that the oracle predictor $T_{\lambda}^{(k^{\star},v^{\star})}$ is able to account for the complexity of the task, at least asymptotically. This is also illustrated by Figure 3, which compares the value of the risks given by Theorem 1 and Proposition 3. However, implementing the oracle predictor requires knowledge of the parameters $k^{\star}$ and $v^{\star}$. Our goal in the next section is therefore to show that gradient descent is able to recover these parameters.

###### Assumption 1 .

###### Theorem 1 .

###### Corollary 2 .

###### Proposition 3 .

## 5. Gradient descent provably recovers the oracle predictor

This section is devoted to the analysis of the optimization dynamics in $(k,v)\in(\mathbb{S}^{d-1})^{2}$ of the risk

$$ ${\mathcal{R}}_{\lambda}(k,v)=\mathbb{E}\Big{[}\Big{(}Y-T_{\lambda}^{(k,v)}( \mathbb{X})\Big{)}^{2}\Big{]}=\mathbb{E}\Big{[}\Big{(}Y-\mathrm{erf}\big{(} \lambda\mathbb{X}k\big{)}^{\top}\mathbb{X}v\Big{)}^{2}\Big{]}\,.$ $$

We emphasize that ${\mathcal{R}}_{\lambda}(k,v)$ is a theoretical risk, which depends on the distribution of the pair $(\mathbb{X},Y)$ (defined in Section 2). In practice, an empirical version of this risk is minimized. As we show experimentally (see Figure 5), the stochastic dynamics induced by the empirical version of the risk are qualitatively similar to the deterministic dynamics of the theoretical risk. Therefore, in the remainder of the article, we focus on the theoretical risk to avoid overcomplicating the analysis. The transition to empirical risk is left for future research.

Our optimization method is the Projected (Riemannian) Gradient Descent (PGD), described below.

###### Definition 1 (PGD) .

Given an initialization $(k_{0},v_{0})\in(\mathbb{S}^{d-1})^{2}$, a step size $\alpha>0$, and an inverse temperature sequence $(\lambda_{t})_{t\geqslant 0}$, the sequence $(k_{t},v_{t})_{t\geqslant 0}\in(\mathbb{S}^{d-1})^{2}$ is recursively defined by

$$ $\displaystyle\begin{split}k_{t+1}&=\mathrm{Proj}_{\mathbb{S}^{d-1}}(k_{t}- \alpha(I_{d}-k_{t}k_{t}^{\top})\nabla_{k}\mathcal{R}_{\lambda_{t}}(k_{t},v_{t} ))=\frac{k_{t}-\alpha(I_{d}-k_{t}k_{t}^{\top})\nabla_{k}\mathcal{R}_{\lambda_{ t}}(k_{t},v_{t})}{\left\|k_{t}-\alpha(I_{d}-k_{t}k_{t}^{\top})\nabla_{k} \mathcal{R}_{\lambda_{t}}(k_{t},v_{t})\right\|_{2}}\,,\\ v_{t+1}&=\mathrm{Proj}_{\mathbb{S}^{d-1}}(v_{t}-\alpha(I_{d}-v_{t}v_{t}^{\top} )\nabla_{v}\mathcal{R}_{\lambda_{t}}(k_{t},v_{t}))=\frac{v_{t}-\alpha(I_{d}-v_ {t}v_{t}^{\top})\nabla_{v}\mathcal{R}_{\lambda_{t}}(k_{t},v_{t})}{\left\|v_{t} -\alpha(I_{d}-v_{t}v_{t}^{\top})\nabla_{v}\mathcal{R}_{\lambda_{t}}(k_{t},v_{t })\right\|_{2}}\,,\end{split}$ (10) $$

where $\mathrm{Proj}_{\mathbb{S}^{d-1}}$ denotes the Euclidean projection on the unit sphere of ${\mathbb{R}}^{d}$.

The operators $(I_{d}-k_{t}k_{t}^{\top})$ and $(I_{d}-v_{t}v_{t}^{\top})$ correspond to Riemannian gradient descent (Boumal, , Section 4.3), meaning that we compute the gradient of the risk on the Riemannian manifold $(\mathbb{S}^{d-1})^{2}$. In other words, the gradient step is performed on the tangent space to the sphere at the current iterate. This is a precaution we are taking because, in the analysis of the dynamics, we rely on an expression of the risk (6) that is valid only on this manifold.
In addition, this ensures that the subsequent projection on $\mathbb{S}^{d-1}$ is always well-defined, despite the fact that the sphere is a non-convex set, because iterates always avoid the pathological cases $k=0$ or $v=0$.

Experimentally, we observe in Figure 4(a) that PGD is able to recover the oracle parameters $(k^{\star},v^{\star})$. Note that running the PGD iterates (10) involves computing the gradients $\nabla_{k}\mathcal{R}_{\lambda_{t}}(k_{t},v_{t})$ and $\nabla_{v}\mathcal{R}_{\lambda_{t}}(k_{t},v_{t})$, which is non-trivial a priori. A direct approach using Monte Carlo simulations would require a large number of sample points to reduce variance, which is computationally intractable in particular in high-dimension, and in any case gives an approximate result. Instead, we leverage our closed form formula for $\mathcal{R}_{\lambda}^{<}$ from Theorem 1 to get (nearly) exact values for the gradients. Interestingly, we also observe in Figure 4(a) that $v$ aligns with $v^{\star}$ much faster than $k$ aligns with $k^{\star}$. This is typical of two-timescale dynamics, which is a common framework in analysis of non-convex learning dynamics (Heusel et al., ; Dagréou et al., ; Hong et al., ; Marion and Berthier, ; Berthier et al., ; Marion et al., ).

Figure: (a) From a random initialization on $(\mathbb{S}^{d-1})^{2}$.
Refer to caption: x5.png

Moving on to the mathematical study, even with the formula for $\mathcal{R}_{\lambda}^{<}$, a full analysis of the dynamics (10) is difficult. For instance, the dynamics (10) can be formulated in terms of the five variables of $\mathcal{R}_{\lambda}^{<}$, but then one needs to study a $5$-dimensional highly nonlinear dynamical system.
In the following, we consider the case where the parameters are initialized on the submanifold of $(\mathbb{S}^{d-1})^{2}$

$$ $\mathcal{M}=\{(k,v)\in\mathbb{S}^{d-1}\times\mathbb{S}^{d-1},k^{\top}v^{\star} =0,v^{\top}k^{\star}=0,k^{\top}v=0\}\,.$ (11) $$

We introduce this manifold on the one hand owing to the observation in Figure 4(a)(right) that the dynamics converge to this manifold even when initialized on the sphere, and on the other hand because this allows to reduce the problem to a lower-dimensional subspace and to simplify the expression of the risk. Cleary, due to Assumption 1, the oracle parameters $(k^{\star},v^{\star})$ belong to ${\mathcal{M}}$. A first key property of this manifold is invariance under the PGD dynamics.

###### Lemma 4 .

The manifold $\mathcal{M}$ is invariant under the PGD dynamics (10), in the sense that if $(k_{t},v_{t})\in\mathcal{M}$, then $(k_{t+1},v_{t+1})\in\mathcal{M}$.

This lemma shows that, if the initialization is taken on the manifold, then it is enough to understand the dynamics on the manifold to conclude. Such analysis on the manifold is tractable. This yields Theorem 5, our main result, which shows that
the sequence $(k_{t},v_{t})_{t\geqslant 0}$ converges to the oracle values $(k^{\star},v^{\star})$ (up to a sign) as $t\to\infty$, for any small enough step size, and a constant inverse temperature.

###### Theorem 5 .

Take a constant inverse temperature $\lambda_{t}\equiv\lambda>0$. Then there exists $\overline{\alpha}>0$ such that, for any step size $\alpha\leqslant\overline{\alpha}$, and for a generic initialization $(k_{0},v_{0})\in\mathcal{M}$,

$$ $(k_{t},v_{t})\xrightarrow[t\to\infty]{}\pm(k^{\star},v^{\star}).$ $$

This result shows that, despite the non-convexity of the risk, the attention layer trained by PGD can recover the underlying structure of the problem. Convergence to $(k^{\star},v^{\star})$ *or* $(-k^{\star},-v^{\star})$ is not at all problematic, since $T_{\lambda}^{(k^{\star},v^{\star})}=T_{\lambda}^{(-k^{\star},-v^{\star})}$ by symmetry of the $\mathrm{erf}$ function. Furthermore, recovery is guaranteed for a generic initialization on ${\mathcal{M}}$, in the sense that the pathological pairs $(k_{0},v_{0})\in{\mathcal{M}}$ such that PGD fails to recover the oracle parameters are of Lebesgue measure zero.
The results of Theorem 5 are illustrated by Figure 4(b). We observe that, due to roundoff errors, the dynamics are not exactly on the manifold but stay very close to the manifold.

We emphasize that the manifold ${\mathcal{M}}$ depends on the unknown parameters $k^{\star}$ and $v^{\star}$, making it impractical to initialize directly on the manifold. If the initialization is not on ${\mathcal{M}}$, more diverse phenomena are possible. As already pointed out in Figure 4(a), it is possible to obtain recovery of $(k^{\star},v^{\star})$ and convergence to the manifold ${\mathcal{M}}$ from a general initialization on the sphere. This suggests that our analysis on the manifold is relevant, and completing the analysis for a general initialization is left for future work. However, we note that using a decreasing inverse temperature sequence $\lambda_{t}$ is crucial for the recovery of $(k^{\star},v^{\star})$ when initialized out of ${\mathcal{M}}$. Indeed, to the best of our experiments, an iteration-independent choice of $\lambda$ does not consistently lead to the recovery of $k^{\star}$ and $v^{\star}$ in this case (see Appendix D). This contrasts with the behavior on the manifold proven in Theorem 5.

To investigate these behaviors, a fruitful direction would be to investigate the (local) stability of the manifold ${\mathcal{M}}$ for the PGD dynamics. If the manifold is indeed stable, one can hope to transfer the analysis on the manifold to dynamics initialized close to the manifold. Furthermore, recall that, in high dimension, random vectors on the sphere are close to being orthogonal. Thus, with high probability, a uniform initialization in $(\mathbb{S}^{d-1})^{2}$ falls in the neighborhood of the manifold ${\mathcal{M}}$, so that the local analysis should allow to conclude.

The proof of the theorem relies on a detailed analysis of the dynamics of the PGD algorithm on the invariant manifold ${\mathcal{M}}$, in particular the properties of its stationary points. These arguments, which lie at the intersection of dynamical systems and topology, are of independent interest. A key idea is to reduce the problem to a two-dimensional system depending only on $|\kappa|=|k^{\top}k^{\star}|$ and $|\nu|=|v^{\top}v^{\star}|$.
The main steps of the proof and intermediate results are given in the next section, while the core of the proofs is in Appendix A.

Figure: Figure 5. Convergence of stochastic PGD to the oracle parameters from a random initialization on $(\mathbb{S}^{d-1})^{2}$. Left: Excess risk as a function of the number of steps. Middle left: Alignment $|\kappa|=|k^{\top}k^{\star}|$ and $|\nu|=|v^{\top}v^{\star}|$ with the oracle parameters. Middle right: Trajectories of $\kappa$ and $\nu$ in two repetitions of the experiment. Each repetition corresponds to a color, the trajectory starts in the middle and ends at a corner of the plot. Right: Distance to the invariant manifold ${\mathcal{M}}$. In all plots except the middle right one, the experiment is repeated $30$ times with independent random initializations, and $95\%$ percentile intervals are plotted. Parameters are $d=80$, $L=10$, $\gamma=\sqrt{1/2}$, $\lambda_{t}=2/(1+10^{-4}t)$, and a batch size of $5$. More details are given in Appendix D.
Refer to caption: x7.png

###### Definition 1 (PGD) .

###### Lemma 4 .

###### Theorem 5 .

## 6. Outline of the proof of Theorem 5

This section outlines the essential steps for the proof of Theorem 5. For clarity, the proofs are to be found in Appendix A, except the proof of Proposition 10.

Notation.  In this section, we consider a constant inverse temperature schedule $\lambda_{t}\equiv\lambda>0$, as in Theorem 5. For this reason, it is not necessary to make explicit the dependence of ${\mathcal{R}}_{\lambda}$ and ${\mathcal{R}}_{\lambda}^{<}$ on $\lambda$, and we use the lighter notations ${\mathcal{R}}$ and ${\mathcal{R}}^{<}$ instead.

Step 1: Invariant manifold & reparameterization.  We first show that the risk $\mathcal{R}(k,v)$ has a simpler expression when considered on the manifold $\mathcal{M}$.

###### Lemma 6 .

The risk ${\mathcal{R}}(k,v)$ restricted to $\mathcal{M}$ has the form

$$ $\displaystyle{{\mathcal{R}}(k,v)}$ $\displaystyle=\gamma^{2}-2\gamma^{2}v^{\top}v^{\star}\,\mathrm{erf}\left( \lambda\sqrt{\frac{d}{2(1+2\lambda^{2}\gamma^{2})}}k^{\top}k^{\star}\right)+ \gamma^{2}\zeta\Big{(}\lambda\sqrt{\frac{d}{2}}\,k^{\top}k^{\star},\lambda^{2} \gamma^{2}\Big{)}$ $\displaystyle\qquad+(L-1)\zeta(0,\lambda^{2})+\varepsilon^{2},$ $$

where, for $t,\gamma\in\mathbb{R}$,

$$ $\zeta(t,\gamma^{2}):=\mathbb{E}\left[\mathrm{erf}^{2}(t+G)\right]\,,\qquad G \sim\mathcal{N}(0,\gamma^{2})\,.$ $$

This expression has two main consequences. First, we use it to prove that the manifold ${\mathcal{M}}$ is invariant by PGD, according to Lemma 4.
Second, we observe that the risk on the manifold depends on the variables $(k,v)\in\mathbb{S}^{d-1}\times\mathbb{S}^{d-1}$ only through the two scalar quantities

$$ $\kappa=k^{\top}k^{\star}\quad\textnormal{and}\quad\nu=v^{\top}v^{\star}\,.$ $$

This suggests studying the dynamics in terms of the reduced variables $(\kappa,\nu)\in[-1,1]^{2}$. More precisely, in the following, we denote by $\mathcal{R}^{<}$ the risk function $\mathcal{R}$ reparameterized as a function of $(\kappa,\nu)$, i.e., we let

$$ ${{\mathcal{R}}^{<}(\kappa,\nu)}=\gamma^{2}-2\gamma^{2}\nu\,\mathrm{erf}\left( \lambda\sqrt{\frac{d}{2(1+2\lambda^{2}\gamma^{2})}}\kappa\right)+\gamma^{2} \zeta\Big{(}\lambda\sqrt{\frac{d}{2}}\,\kappa,\lambda^{2}\gamma^{2}\Big{)}+(L- 1)\zeta(0,\lambda^{2})+\varepsilon^{2}\,.$ $$

Note that, with a slight abuse of notation, we use ${\mathcal{R}}^{<}$ to denote both the function of five variables $(\kappa,\nu,\theta,\rho,\eta)$ (as in Theorem 1) and the function of only the first two variables $(\kappa,\nu)$. There should be no confusion, as both functions coincide on the manifold ${\mathcal{M}}$ where $\theta=\rho=\eta=0$.
We also denote the corresponding PGD iterates using this reparameterization by $(\kappa_{t},\nu_{t}):=(k_{t}^{\top}k^{\star},v_{t}^{\top}v^{\star})$. With this notation, the following lemma reformulates the PGD iterations as an autonomous discrete dynamical system in terms of $(\kappa_{t},\nu_{t})$.

###### Lemma 7 .

When initialized on the manifold ${\mathcal{M}}$, the PGD iterations (10) can be reformulated in terms of the autonomous discrete dynamical system

$$ $\displaystyle(\kappa_{t+1},\nu_{t+1})$ $\displaystyle=g(\kappa_{t},\nu_{t})\,,$ (12) $$

where the mapping $g:[-1,1]^{2}\to[-1,1]^{2}$ is given by

$$ $\displaystyle g(\kappa,\nu)=\left(\frac{\kappa-\alpha(\partial_{\kappa} \mathcal{R}^{<}(\kappa,\nu))(1-\kappa^{2})}{\sqrt{1+\alpha^{2}(\partial_{ \kappa}\mathcal{R}^{<}(\kappa,\nu))^{2}(1-\kappa^{2})}}\,,\quad\frac{\nu- \alpha(\partial_{\nu}\mathcal{R}^{<}(\kappa,\nu))(1-\nu^{2})}{\sqrt{1+\alpha^{ 2}(\partial_{\nu}\mathcal{R}^{<}(\kappa,\nu))^{2}(1-\nu^{2})}}\right).$ (13) $$

Step 2: Analysis of the stationary points.  Regarding the dynamics restricted to the invariant manifold $\mathcal{M}$, we can characterize the limit points of the PGD iterates as follows.

###### Proposition 8 .

For a sufficiently small step size $\alpha$ and for any $(k_{0},v_{0})\in\mathcal{M}$, the risk ${\mathcal{R}}^{<}$ is decreasing along the PGD iterates.
Furthermore, the distance between successive PGD iterates tends to zero, and,
if $(\kappa,\nu)$ is an accumulation point of the sequence of iterates $(\kappa_{t},\nu_{t})_{t\geqslant 0}$, then

$$ $(1-\kappa^{2})\partial_{\kappa}\mathcal{R}^{<}(\kappa,\nu)=0\quad\textnormal{ and}\quad(1-\nu^{2})\partial_{\nu}\mathcal{R}^{<}(\kappa,\nu)=0\,.$ (14) $$

We stress that the system (14) of equations corresponds to fixed points of the dynamics (12)–(13). We next solve this system of equations.

###### Proposition 9 .

The points $(\kappa,\nu)\in[-1,1]^{2}$ satisfying (14) are $(\kappa,\nu)=(\pm 1,\pm 1)$(^2^22This notation is used to designate any extreme point of the square $[-1,1]^{2}$, i.e., $(\kappa,\nu)=(1,1)$, $(1,-1)$, $(-1,1)$, and $(-1,-1)$.) and $(\kappa,\nu)=(0,0)$.

The identity $(\kappa,\nu)=(\pm 1,\pm 1)$ corresponds to the situation where the variables $(k,v)$ are aligned (up to sign) with the targets $(k^{\star},v^{\star})$. As the next proposition shows, these are the only global minima of ${\mathcal{R}}^{<}$.

###### Proposition 10 .

The fixed points of the dynamics can be classified as follows:

- $(i)$
The points $(\kappa,\nu)=(-1,1)$ and $(1,-1)$ are global maxima of $\mathcal{R}^{<}$ on $[-1,1]^{2}$.
- $(ii)$
The points $(\kappa,\nu)=(1,1)$ and $(-1,-1)$ are global minima of $\mathcal{R}^{<}$ on $[-1,1]^{2}$.
- $(iii)$
The point $(\kappa,\nu)=(0,0)$ is a saddle point of $\mathcal{R}^{<}$ on $[-1,1]^{2}$.

The fixed points of the dynamics as well as the vector field

$$ $(\kappa,\nu)\mapsto-(\partial_{\kappa}\mathcal{R}^{<}(\kappa,\nu)(1-\kappa^{2} ),\partial_{\nu}\mathcal{R}^{<}(\kappa,\nu)(1-\nu^{2}))$ $$

are displayed in Figure 6.

Figure: Figure 6. Dynamics in $(\kappa,\nu)$ on the manifold $\mathcal{M}$. In (a), the fixed points of the dynamics are represented; the minimizers, saddle point, and maximizers are respectively depicted in yellow, blue and red. In (b), the vector field $(\kappa,\nu)\mapsto-(\partial_{\kappa}\mathcal{R}^{<}(\kappa,\nu)(1-\kappa^{2} ),\partial_{\nu}\mathcal{R}^{<}(\kappa,\nu)(1-\nu^{2}))$ is displayed (the colormap corresponds to the magnitude of the vector field).
Refer to caption: x8.png

Step 3: Convergence to global minima.  The convergence of the sequence of iterates $(\kappa_{t},\nu_{t})_{t\geqslant 0}$ to a global minimum is shown in two stages. First, we show that the iterates converge to one of the five fixed points described in Proposition 10.

###### Proposition 11 .

For a sufficiently small step size $\alpha$, the sequence of iterates $(\kappa_{t},\nu_{t})_{t\geqslant 0}$ converges to one of the five fixed points $\{(\pm 1,\pm 1),(0,0)\}$.

###### Proof.

According to Proposition 8, the distance between successive iterates $(\kappa_{t},\nu_{t})$ tends to zero. Therefore, the set of accumulation points of the sequence $(\kappa_{t},\nu_{t})_{t\geqslant 0}$ is connected (Lange, , Proposition 12.4.1). Since there is a finite number of possible accumulation points (by Proposition 9),
we deduce that the sequence has a unique accumulation point. Furthermore, the sequence belongs to a compact. Thus, it converges, and its limit is one of the five fixed points.
∎

It remains to precisely characterize the limit of the sequence $(\kappa_{t},\nu_{t})_{t\geqslant 0}$. To this aim, we begin by showing key properties of the gradient mapping $g$.

###### Proposition 12 .

For a sufficiently small step size $\alpha$, the mapping $g$ is a local diffeomorphism around $(0,0)$, whose Jacobian matrix has one eigenvalue in $(0,1)$ and one eigenvalue in $(1,\infty)$. Furthermore, it is injective on $[-1,1]^{2}$, differentiable, and its Jacobian is non-degenerate.

These properties enable us to apply the Center-Stable Manifold theorem (Shub, , Theorem III.7) to deduce the next proposition.

###### Proposition 13 .

For a sufficiently small step size $\alpha$, the set of initializations such that the sequence $(\kappa_{t},\nu_{t})_{t\geqslant 0}$ converges to $(-1,1)$, $(1,-1)$, or $(0,0)$ has Lebesgue measure zero (with respect to the Lebesgue measure on the manifold ${\mathcal{M}}$).

Combining Proposition 11 and Proposition 13, we conclude that, provided the step size $\alpha$ is chosen small enough, the sequence $(\kappa_{t},\nu_{t})_{t\geqslant 0}$ almost surely converges to one of the minimizers, $(1,1)$ or $(-1,-1)$. This convergence is almost sure with respect to the Lebesgue measure on the manifold ${\mathcal{M}}$. Indeed, Proposition 13 ensures that the pathological initializations converging towards a maximizer or a saddle point are of Lebesgue measure zero. This concludes the proof of Theorem 5.

###### Lemma 6 .

###### Lemma 7 .

###### Proposition 8 .

###### Proposition 9 .

###### Proposition 10 .

###### Proposition 11 .

###### Proof.

###### Proposition 12 .

###### Proposition 13 .

## 7. Conclusion

This paper introduced single-location regression, a novel statistical task where the relevant information in the input sequence is supported by a single token. We analyzed the statistical properties and optimization dynamics of a natural estimator for this task, which simplifies to a basic attention layer. We hope this work encourages further research into how Transformer architectures address sparsity and long-range dependencies, while simultaneously constructing internal linear representations of their input—–an aspect with significant implications for interpretability. Beyond NLP, potential applications include problems connected to sparse sequential modeling such as anomaly detection in time series. A natural extension of our framework is when relevant information is spread across a few input tokens rather than just one, which relates to multi-head attention. Future mathematical analyses should consider extensions to general initialization schemes and stochastic dynamics. Our numerical experiments (Figures 4(a) and 5) yield encouraging results in both of these directions.

#### Acknowledgments

Authors thank Peter Bartlett, Linus Bleistein, Alex Damian, Spencer Frei, and Clément Mantoux for fruitful discussions and feedback. P.M. is supported by a Google PhD Fellowship. R.B. acknowledges support from the ANR and the Ministère de l’Enseignement Supérieur et de la Recherche.

## Appendix A Proofs of the main results

### A.1. Proof of Lemma 6 and Theorem 1

We recall the formula for the risk

$$ ${\mathcal{R}}(k,v)=\mathbb{E}\Big{[}\Big{(}Y-\sum_{\ell=1}^{L}\mathrm{erf}( \lambda X_{\ell}^{\top}k)X_{\ell}^{\top}v\Big{)}^{2}\Big{]}$ $$

and the data model

$$ $\displaystyle Y$ $\displaystyle=X_{J_{0}}^{\top}v^{\star}+\xi,$ $$

where

$$ $J_{0}\sim\mathcal{U}(\{1,\ldots,L\})\quad\text{and}\quad\left\{\begin{array}[] {lll}X_{J_{0}}&\sim&{\mathcal{N}}\Big{(}\sqrt{\frac{d}{2}}k^{\star},\gamma^{2} I_{d}\Big{)}\\ X_{\ell}&\sim&{\mathcal{N}}(0,I_{d})\quad\textnormal{for}\quad\ell\neq J_{0}. \end{array}\right.$ $$

In the above expression for the risk, we can condition on the value of $J_{0}$. Actually, the conditioned risk is independent of $J_{0}$. Thus in this section, we assume without loss of generality that $J_{0}=1$ a.s.:

$$ ${\mathcal{R}}(k,v)=\mathbb{E}\Big{[}\Big{(}X_{1}^{\top}v^{\star}+\xi-\mathrm{ erf}(\lambda X_{1}^{\top}k)X_{1}^{\top}v-\sum_{\ell=2}^{L}\mathrm{erf}(\lambda X _{\ell}^{\top}k)X_{\ell}^{\top}v\Big{)}^{2}\Big{]}\,,$ (15) $$

where

$$ $\left\{\begin{array}[]{lll}X_{1}&\sim&{\mathcal{N}}\Big{(}\sqrt{\frac{d}{2}}k^ {\star},\gamma^{2}I_{d}\Big{)}\\ X_{\ell}&\sim&{\mathcal{N}}(0,I_{d})\quad\textnormal{for}\quad\ell\geqslant 2. \end{array}\right.$ $$

We rewrite this quantity in terms of multivariate standard Gaussian random variables. Using Assumption 1, we get

$$ $\displaystyle{\mathcal{R}}(k,v)$ $\displaystyle=\mathbb{E}\Big{[}\Big{(}\gamma\widetilde{X}_{1}^{\top}v^{\star}+ \xi-\mathrm{erf}\Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}k_{*}^{\top}k+\gamma \widetilde{X}_{1}^{\top}k\Big{)}\Big{)}\Big{(}\sqrt{\frac{d}{2}}k_{*}^{\top}v+ \gamma\widetilde{X}_{1}^{\top}v\Big{)}$ $\displaystyle\qquad-\sum_{\ell=2}^{L}\mathrm{erf}(\lambda X_{\ell}^{\top}k)X_{ \ell}^{\top}v\Big{)}^{2}\Big{]}\,,$ $$

where $\widetilde{X}_{1},X_{2},\dots,X_{L}\sim{\mathcal{N}}(0,I_{d})$.
This can be formulated in terms of the five scalar quantities $\kappa=k^{\top}k^{\star}$, $\nu=v^{\top}v^{\star}$, $\theta=v^{\top}k^{\star}$, $\eta=k^{\top}v^{\star}$, and $\rho=k^{\top}v$. Indeed, we have

$$ $\displaystyle\begin{split}&{\mathcal{R}}(k,v)={\mathcal{R}}^{<}(\kappa,\nu, \theta,\eta,\rho)\\ &\quad:=\mathbb{E}\Big{[}\Big{(}\gamma G_{1}^{v^{\star}}+\xi-\Big{(}\sqrt{ \frac{d}{2}}\theta+\gamma G_{1}^{v}\Big{)}\mathrm{erf}\Big{(}\lambda\Big{(} \sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)}-\sum_{\ell=2}^{L}G_{ \ell}^{v}\mathrm{erf}(\lambda G_{\ell}^{k})\Big{)}^{2}\Big{]}\,,\end{split}$ (16) $$

where

$$ $\displaystyle\begin{pmatrix}G_{1}^{v^{\star}}\\ G_{1}^{v}\\ G_{1}^{k}\end{pmatrix},\dots,\begin{pmatrix}G_{L}^{v^{\star}}\\ G_{L}^{v}\\ G_{L}^{k}\end{pmatrix}\underset{\text{i.i.d.}}{\sim}{\mathcal{N}}\left(0, \begin{pmatrix}1&\nu&\eta\\ \nu&1&\rho\\ \eta&\rho&1\end{pmatrix}\right)\,.$ (17) $$

This last expression only involves the five parameters $\kappa,\nu,\theta,\eta,\rho$, which play a role either explicitly in the function or as parameters of the covariance of the random variables. This proves the first statement of Theorem 1. A computation of a closed-form formula for this expectation is given in Appendix B.

On the manifold ${\mathcal{M}}$ defined by $\theta=\eta=\rho=0$, we can simplify the expressions (LABEL:eq:risk-5-params-1)–(17)

$$ $\displaystyle{\mathcal{R}}^{<}(\kappa,\nu,0,0,0)=\mathbb{E}\Big{[}\Big{(} \gamma G_{1}^{v^{\star}}+\xi-\gamma G_{1}^{v}\mathrm{erf}\Big{(}\lambda\Big{(} \sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)}-\sum_{\ell=2}^{L}G_{ \ell}^{v}\mathrm{erf}(\lambda G_{\ell}^{k})\Big{)}^{2}\Big{]}$ $$

where
$\begin{pmatrix}G_{1}^{v^{\star}}\\
G_{1}^{v}\end{pmatrix},\dots,\begin{pmatrix}G_{L}^{v^{\star}}\\
G_{L}^{v}\end{pmatrix}\underset{\text{i.i.d.}}{\sim}{\mathcal{N}}\left(0,
\begin{pmatrix}1&\nu\\
\nu&1\\
\end{pmatrix}\right)$, $G_{1}^{k},\dots,G_{L}^{k}\underset{\text{i.i.d.}}{\sim}{\mathcal{N}}(0,1)$, and $\xi\sim{\mathcal{N}}(0,\varepsilon^{2})$ are independent.

We first expand in $\xi$ and obtain

$$ $\displaystyle{\mathcal{R}}^{<}(\kappa,\nu,0,0,0)=\varepsilon^{2}+\mathbb{E} \Big{[}\Big{(}\gamma G_{1}^{v^{\star}}-\gamma G_{1}^{v}\mathrm{erf}\Big{(} \lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)}-\sum_{ \ell=2}^{L}G_{\ell}^{v}\mathrm{erf}(\lambda G_{\ell}^{k})\Big{)}^{2}\Big{]}\,.$ $$

We now expand the square, as follows:

$$ $\displaystyle{\mathcal{R}}^{<}(\kappa,\nu,0,0,0)$ $\displaystyle=\varepsilon^{2}+\gamma^{2}\mathbb{E}\left[(G_{1}^{v^{\star}})^{2 }\right]-2\gamma^{2}\mathbb{E}\Big{[}G_{1}^{v^{\star}}G_{1}^{v}\mathrm{erf} \Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)} \Big{]}$ $\displaystyle\quad+\gamma^{2}\mathbb{E}\Big{[}(G_{1}^{v})^{2}\mathrm{erf}^{2} \Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)} \Big{]}$ $\displaystyle\quad-2\sum_{\ell=2}^{L}\gamma\mathbb{E}\Big{[}\Big{(}G_{1}^{v^{ \star}}-G_{1}^{v}\mathrm{erf}\Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+ \gamma G_{1}^{k}\Big{)}\Big{)}\Big{)}G_{\ell}^{v}\mathrm{erf}(\lambda G_{\ell} ^{k})\Big{]}$ $\displaystyle\quad+\sum_{\ell,m=2}^{L}\mathbb{E}[G_{\ell}^{v}\mathrm{erf}( \lambda G_{\ell}^{k})G_{m}^{v}\mathrm{erf}(\lambda G_{m}^{k})]\,.$ $$

We address each term in this sum separately.

- •
Since $G_{1}^{v^{\star}}\sim{\mathcal{N}}(0,1)$, $\gamma^{2}\mathbb{E}\left[(G_{1}^{v^{\star}})^{2}\right]=\gamma^{2}$.
- •
Since $\begin{pmatrix}G_{1}^{v^{\star}}\\
G_{1}^{v}\end{pmatrix}\sim{\mathcal{N}}\left(0,\begin{pmatrix}1&\nu\\
\nu&1\\
\end{pmatrix}\right)$ is independent from $G_{1}^{k}\sim{\mathcal{N}}(0,1)$, we have
$\displaystyle-2\gamma^{2}\mathbb{E}\Big{[}G_{1}^{v^{\star}}G_{1}^{v}\mathrm{
erf}\Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{
)}\Big{]}$
$\displaystyle=-2\gamma^{2}\mathbb{E}\Big{[}G_{1}^{v^{\star}}G_{1}^{v}\Big{]}
\mathbb{E}\Big{[}\mathrm{erf}\Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+
\gamma G_{1}^{k}\Big{)}\Big{)}\Big{]}$
$\displaystyle=-2\gamma^{2}\nu\mathbb{E}\Big{[}\mathrm{erf}\Big{(}\lambda\Big{(
}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)}\Big{]}\ .$
Finally, using Lemma 18$(ii)$, we obtain
$\displaystyle-2\gamma^{2}\mathbb{E}\Big{[}G_{1}^{v^{\star}}G_{1}^{v}\mathrm{
erf}\Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{
)}\Big{]}=-2\gamma^{2}\nu\mathrm{erf}\Big{(}\lambda\sqrt{\frac{d}{2}}\frac{
\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\Big{)}\ .$
- •
Since $G_{1}^{v},G_{1}^{k}\sim_{\text{i.i.d.}}{\mathcal{N}}(0,1)$, we have
$\displaystyle\gamma^{2}\mathbb{E}\Big{[}(G_{1}^{v})^{2}\mathrm{erf}^{2}\Big{(}
\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)}\Big{]}$
$\displaystyle=\gamma^{2}\mathbb{E}\Big{[}(G_{1}^{v})^{2}\Big{]}\mathbb{E}\Big{
[}\mathrm{erf}^{2}\Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{
k}\Big{)}\Big{)}\Big{]}$
$\displaystyle=\gamma^{2}\mathbb{E}\Big{[}\mathrm{erf}^{2}\Big{(}\lambda\Big{(}
\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)}\Big{]}\,.$
Using the definition of $\zeta$ in Eq. (7), we have
$\displaystyle\gamma^{2}\mathbb{E}\Big{[}(G_{1}^{v})^{2}\mathrm{erf}^{2}\Big{(}
\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)}\Big{]}$
$\displaystyle=\gamma^{2}\mathbb{E}\Big{[}(G_{1}^{v})^{2}\Big{]}\mathbb{E}\Big{
[}\mathrm{erf}^{2}\Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{
k}\Big{)}\Big{)}\Big{]}$
$\displaystyle=\gamma^{2}\zeta\Big{(}\lambda\sqrt{\frac{d}{2}}\kappa,\lambda^{2
}\gamma^{2}\Big{)}\,.$
- •
For $\ell=2,\dots,L$, $(G_{1}^{v^{\star}},G_{1}^{v},G_{1}^{k})$, $G_{\ell}^{v}$, and $G_{\ell}^{k}$ are independent. Thus
$\displaystyle\mathbb{E}\Big{[}\Big{(}G_{1}^{v^{\star}}-G_{1}^{v}\mathrm{erf}
\Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)}
\Big{)}G_{\ell}^{v}\mathrm{erf}(\lambda G_{\ell}^{k})\Big{]}$
$\displaystyle\qquad=\mathbb{E}\Big{[}\Big{(}G_{1}^{v^{\star}}-G_{1}^{v}\mathrm
{erf}\Big{(}\lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big
{)}\Big{)}\Big{]}\mathbb{E}\Big{[}G_{\ell}^{v}\Big{]}\mathbb{E}\Big{[}\mathrm{
erf}(\lambda G_{\ell}^{k})\Big{]}=0\,,$
where in the last step we use $\mathbb{E}[G_{\ell}^{v}]=0$.
- •
Finally, to tackle the last term, we address the cases $\ell\neq m$ and $\ell=m$ separately. If $\ell\neq m$, as $G_{\ell}^{v},G_{\ell}^{k},G_{m}^{v}$, and $G_{m}^{k}$ are independent, we have
$\displaystyle\mathbb{E}[G_{\ell}^{v}\mathrm{erf}(\lambda G_{\ell}^{k})G_{m}^{v
}\mathrm{erf}(\lambda G_{m}^{k})]=\mathbb{E}[G_{\ell}^{v}]\mathbb{E}[\mathrm{
erf}(\lambda G_{\ell}^{k})]\mathbb{E}[G_{m}^{v}]\mathbb{E}[\mathrm{erf}(
\lambda G_{m}^{k})]=0\,.$
If $\ell=m$, as $G_{\ell}^{v},G_{\ell}^{k}\sim_{\text{i.i.d.}}{\mathcal{N}}(0,1)$, we have
$\displaystyle\mathbb{E}[(G_{\ell}^{v})^{2}\mathrm{erf}^{2}(\lambda G_{\ell}^{k
})]=\mathbb{E}[(G_{\ell}^{v})^{2}]\mathbb{E}[\mathrm{erf}^{2}(\lambda G_{\ell}
^{k})]=\zeta(0,\lambda^{2})\,.$

Putting together these computations, we obtain

$$ $\displaystyle{\mathcal{R}}^{<}(\kappa,\nu,0,0,0)$ $\displaystyle=\varepsilon^{2}+\gamma^{2}-2\gamma^{2}\nu\mathrm{erf}\Big{(} \lambda\sqrt{\frac{d}{2}}\frac{\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\Big{)} +\gamma^{2}\zeta\Big{(}\lambda\sqrt{\frac{d}{2}}\kappa,\lambda^{2}\gamma^{2} \Big{)}$ $\displaystyle\quad+(L-1)\zeta(0,\lambda^{2})\,.$ $$

This proves Lemma 6. Taking $\kappa=\nu=1$ proves Theorem 1.

### A.2. Proof of Corollary 2

Recall that, according to Theorem 1,

$$ $\displaystyle\mathcal{R}_{\lambda}(k^{\star},v^{\star})$ $\displaystyle=\gamma^{2}-2\gamma^{2}\,\mathrm{erf}\bigg{(}\lambda\sqrt{\frac{d }{2(1+2\lambda^{2}\gamma^{2})}}\bigg{)}+\gamma^{2}\zeta\Big{(}\lambda\sqrt{ \frac{d}{2}},\lambda^{2}\gamma^{2}\Big{)}+(L-1)\zeta(0,\lambda^{2})+ \varepsilon^{2}\,,$ $$

where, for $t,\gamma\in\mathbb{R}$,

$$ $\zeta(t,\gamma^{2}):=\mathbb{E}\left[\mathrm{erf}^{2}(t+\gamma G)\right]\,, \qquad G\sim\mathcal{N}(0,1)\,.$ $$

We compute the limit of each term separately. First, we have

$$ $\lambda\sqrt{\frac{d}{2(1+2\lambda^{2}\gamma^{2})}}\sim\frac{\lambda\sqrt{d}}{ \sqrt{2}}\xrightarrow{d\to\infty}\infty\,.$ (18) $$

Therefore, the second term of $\mathcal{R}_{\lambda}(k^{\star},v^{\star})$ tends to $-2\gamma^{2}$. To handle the third term, note by Jensen’s inequality that

$$ $1\geqslant\zeta\Big{(}\lambda\sqrt{\frac{d}{2}},\lambda^{2}\gamma^{2}\Big{)}= \mathbb{E}\left[\mathrm{erf}^{2}\Big{(}\lambda\sqrt{\frac{d}{2}}+\lambda\gamma G \Big{)}\right]\geqslant\mathbb{E}\left[\mathrm{erf}\Big{(}\lambda\sqrt{\frac{d }{2}}+\lambda\gamma G\Big{)}\right]^{2}\,.$ $$

Thus, by Lemma 18$(ii)$,

$$ $1\geqslant\zeta\Big{(}\lambda\sqrt{\frac{d}{2}},\lambda^{2}\gamma^{2}\Big{)} \geqslant\mathrm{erf}^{2}\Big{(}\lambda\sqrt{\frac{d}{2(1+2\lambda^{2}\gamma^{ 2})}}\Big{)}\to 1\,,$ $$

where we used (18).
Thus the third term of $\mathcal{R}_{\lambda}(k^{\star},v^{\star})$ converges to $\gamma^{2}$.
As for the fourth term, observe by Lemma 17 that

$$ $\mathrm{erf}^{2}(u)\leqslant\frac{4}{\pi}u^{2}\,,$ $$

hence

$$ $0\leqslant\zeta(0,\lambda^{2})\leqslant\frac{4}{\pi}\lambda^{2}\mathbb{E}[G^{2 }]=\frac{4}{\pi}\lambda^{2}\,.$ $$

Since $\lambda\sqrt{L}\to 0$, we get

$$ $(L-1)\zeta(0,\lambda^{2})=\mathcal{O}(\lambda^{2}L)=o(1)\,.$ $$

Putting everything together, we obtain

$$ $\mathcal{R}_{\lambda}(k^{\star},v^{\star})\xrightarrow{d\to\infty}\gamma^{2}-2 \gamma^{2}+\gamma^{2}+0+\varepsilon^{2}=\varepsilon^{2}\,.$ $$

Since we already know by (8) that the Bayes risk is lower-bounded by $\varepsilon^{2}$, this proves that the Bayes risk is asymptotically equal to $\varepsilon^{2}$, and that the oracle predictor is asymptotically Bayes optimal.

### A.3. Proof of Proposition 3

Let us first introduce a useful notation for the proof. If $M$ is a block matrix, we denote by $M_{[ij]}$ its $(i,j)$-th block, and likewise, if $u$ is a block vector, we denote by $u_{[j]}$ its $j$-th block.
Next, note that

$$ $\displaystyle\mathbb{E}[Y^{2}]$ $\displaystyle=\varepsilon^{2}+\mathbb{E}\left[((v^{\star})^{\top}X_{J_{0}})^{2 }\right]$ $\displaystyle=\varepsilon^{2}+\gamma^{2}\|v^{\star}\|_{2}^{2}$ $\displaystyle=\varepsilon^{2}+\gamma^{2},$ $$

since $\|v^{\star}\|_{2}^{2}=1$. Recall that

$$ $\beta^{\star}\in\operatorname*{arg\,min}_{\beta\in{\mathbb{R}}^{dL}}\mathbb{E} \Big{[}(Y-(X_{1}^{\top},\ldots,X_{L}^{\top})\beta)^{2}\Big{]}$ $$

is the optimal linear predictor. The classical formula for linear regression shows that

$$ $\displaystyle\beta^{\star}$ $\displaystyle=\left(\mathbb{E}\left[\begin{pmatrix}X_{1}\\ \vdots\\ X_{L}\end{pmatrix}(X_{1}^{\top},\ldots,X_{L}^{\top})\right]\right)^{-1}\mathbb {E}\left[((v^{\star})^{\top}X_{J_{0}}+\xi)\begin{pmatrix}X_{1}\\ \vdots\\ X_{L}\end{pmatrix}\right].$ $$

On the one hand, let

$$ $M=\begin{pmatrix}X_{1}\\ \vdots\\ X_{L}\end{pmatrix}(X_{1}^{\top},\ldots,X_{L}^{\top})\,.$ $$

Then $\mathbb{E}[M]=\mathbb{E}[\mathbb{E}[M|J_{0}]]$, and $\mathbb{E}[M|J_{0}]$ is a block-diagonal matrix, where, for $j,j^{\prime}\in\{1,\dots,L\}$,

$$ $\mathbb{E}[M|J_{0}=j]_{[j^{\prime},j^{\prime}]}=\delta_{j\neq j^{\prime}}I_{d} +\delta_{j=j^{\prime}}(\gamma^{2}I_{d}+\frac{d}{2}k^{\star}(k^{\star})^{\top})\,.$ $$

Thus

$$ $\mathbb{E}[M]_{[j^{\prime},j^{\prime}]}=(1-p_{j^{\prime}})I_{d}+p_{j^{\prime}} (\gamma^{2}I_{d}+\frac{d}{2}k^{\star}(k^{\star})^{\top})=I_{d}+p_{j^{\prime}}( \gamma^{2}-1)I_{d}+p_{j^{\prime}}\frac{d}{2}k^{\star}(k^{\star})^{\top}\,.$ $$

On the other hand, let

$$ $u=((v^{\star})^{\top}X_{J_{0}}+\xi)\begin{pmatrix}X_{1}\\ \vdots\\ X_{L}\end{pmatrix}\,.$ $$

Then

$$ $\displaystyle\mathbb{E}\left[u\right]$ $\displaystyle=\mathbb{E}\left[\begin{pmatrix}X_{1}\\ \vdots\\ X_{L}\end{pmatrix}X_{J_{0}}^{\top}\right]v^{\star}=\mathbb{E}\left[\mathbb{E} \left[\begin{pmatrix}X_{1}\\ \vdots\\ X_{L}\end{pmatrix}X_{J_{0}}^{\top}\right]\middle|J_{0}\right]v^{\star}$ $\displaystyle=\begin{pmatrix}p_{1}(\gamma^{2}I_{d}&+&\frac{d}{2}k^{\star}(k^{ \star})^{\top})\\ &\vdots&\\ p_{L}(\gamma^{2}I_{d}&+&\frac{d}{2}k^{\star}(k^{\star})^{\top})\end{pmatrix}v^ {\star}=\gamma^{2}\begin{pmatrix}p_{1}v^{\star}\\ \vdots\\ p_{L}v^{\star}\end{pmatrix},$ $$

since, by Assumption 1, $k^{\star\top}v^{\star}=0$.

Since $\mathbb{E}[M]$ is a block-diagonal matrix and $\mathbb{E}[u]$ is a block vector, we get by standard computation rules for block matrices

$$ $\beta^{\star}_{[j]}=(\mathbb{E}[M]^{-1}\mathbb{E}[u])_{[j]}=\mathbb{E}[M]_{[j, j]}^{-1}\mathbb{E}[u]_{[j]}=\Big{(}I_{d}+p_{j}(\gamma^{2}-1)I_{d}+p_{j}\frac{d }{2}k^{\star}(k^{\star})^{\top}\Big{)}^{-1}\gamma^{2}p_{j}v^{\star}\,.$ $$

Recall the Sherman-Morrison formula (Press et al., , Section 2.7.1), which states that for any vectors $u,v\in\mathbb{R}^{d}$, $(I_{d}+uu^{\top})^{-1}v=\left(I_{d}-uu^{\top}/(1+u^{\top}u)\right)v$.
Applying this formula with orthogonal vectors, we obtain

$$ $\displaystyle\beta^{\star}_{[j]}$ $\displaystyle=\left(1+p_{j}(\gamma^{2}-1)\right)^{-1}\gamma^{2}p_{j}v^{\star}= \frac{\gamma^{2}p_{j}}{1+p_{j}(\gamma^{2}-1)}v^{\star}\,,$ $$

which shows the first formula of the proposition.
Finally, the risk associated with the optimal linear predictor $(X_{1}^{\top},\ldots,X_{L}^{\top})\mapsto(X_{1}^{\top},\ldots,X_{L}^{\top})
\beta^{\star}$ is given by

$$ $\displaystyle\mathcal{R}(\beta^{\star})$ $\displaystyle=\mathbb{E}[Y^{2}]-\mathbb{E}[Y(X_{1}^{\top}\ldots X_{L}^{\top}) \beta^{\star}]$ $\displaystyle=\varepsilon^{2}+\gamma^{2}-\gamma^{2}\cdot\begin{pmatrix}p_{1}(v ^{\star})^{\top},&\dots,&p_{L}(v^{\star})^{\top}\end{pmatrix}\begin{pmatrix} \beta^{\star}_{[1]}\\ \vdots\\ \beta^{\star}_{[L]}\end{pmatrix}$ $\displaystyle=\varepsilon^{2}+\gamma^{2}-\gamma^{4}\sum_{j=1}^{L}\frac{p_{j}^{ 2}}{1+p_{j}(\gamma^{2}-1)}\,.$ (19) $$

This shows the formula for the risk given in the Proposition. To obtain the last bound, observe that, if $\gamma^{2}\geqslant 1$, we have $1+p_{j}(\gamma^{2}-1)\geqslant 1$. If $\gamma^{2}\leqslant 1$, since $p_{j}\leqslant 1$, we have $1+p_{j}(\gamma^{2}-1)\geqslant 1+(\gamma^{2}-1)=\gamma^{2}$. Thus we obtain $1+p_{j}(\gamma^{2}-1)\geqslant\min(1,\gamma^{2})$. Therefore,

$$ $\displaystyle\mathcal{R}(\beta^{\star})$ $\displaystyle\geqslant\varepsilon^{2}+\gamma^{2}-\max(\gamma^{4},\gamma^{2}) \sum_{j=1}^{L}{p_{j}^{2}}$ $\displaystyle\geqslant\varepsilon^{2}+\gamma^{2}-\max(\gamma^{4},\gamma^{2}) \sum_{j=1}^{L}{p_{j}}\cdot\max_{j=1,\dots,L}{p_{j}}$ $\displaystyle\geqslant\varepsilon^{2}+\gamma^{2}-(\gamma^{4}+\gamma^{2})\max_{ j=1,\dots,L}{p_{j}}$ $\displaystyle\geqslant\varepsilon^{2}+\gamma^{2}-\gamma^{2}(\gamma^{2}+1)\max_ {j=1,\dots,L}{p_{j}}\,.$ $$

When all $p_{j}$ are equal to $1/L$, all terms in the sum are equal, and Eq. (19) simplifies to

$$ $\mathcal{R}(\beta^{\star})=\varepsilon^{2}+\gamma^{2}-L\gamma^{4}\frac{\frac{1 }{L^{2}}}{1+\frac{1}{L}(\gamma^{2}-1)}=\varepsilon^{2}+\gamma^{2}-\frac{\gamma ^{4}}{L+\gamma^{2}-1}\,.$ $$

### A.4. Proof of Lemma 4

As a first step in the proof, we prove the next lemma, which is the key towards the invariance property we are aiming at, in that it shows that, for a point on the manifold ${\mathcal{M}}$ (defined by $\theta=\eta=\rho=0$), the gradient of the risk does not “push” the point outside of the manifold.
Its proof leverages the expression of the risk as a function of five parameters derived in the previous section

###### Lemma 14 .

At any point $(\kappa,\nu,\theta,\eta,\rho)$ such that $\theta=\eta=\rho=0$, we have $\partial_{\theta}{\mathcal{R}}^{<}=\partial_{\eta}{\mathcal{R}}^{<}=\partial_{
\rho}{\mathcal{R}}^{<}=0$.

###### Proof.

We use Eq. (LABEL:eq:risk-5-params-1)–(17) and change signs in the square function:

$$ $\displaystyle{\mathcal{R}}^{<}(\kappa,\nu,\theta,\eta,\rho)$ $\displaystyle\quad=\mathbb{E}\Big{[}\Big{(}\gamma G_{1}^{v^{\star}}+\xi-\Big{( }\sqrt{\frac{d}{2}}\theta+\gamma G_{1}^{v}\Big{)}\mathrm{erf}\Big{(}\lambda \Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)}-\sum_{\ell=2}^{ L}G_{\ell}^{v}\mathrm{erf}(\lambda G_{\ell}^{k})\Big{)}^{2}\Big{]}$ $\displaystyle\quad=\mathbb{E}\Big{[}\Big{(}\gamma(-G_{1}^{v^{\star}})-\xi-\Big {(}\sqrt{\frac{d}{2}}(-\theta)+\gamma(-G_{1}^{v})\Big{)}\mathrm{erf}\Big{(} \lambda\Big{(}\sqrt{\frac{d}{2}}\kappa+\gamma G_{1}^{k}\Big{)}\Big{)}$ $\displaystyle\qquad-\sum_{\ell=2}^{L}(-G_{\ell}^{v})\mathrm{erf}(\lambda G_{ \ell}^{k})\Big{)}^{2}\Big{]}\,,$ $$

where

$$ $\displaystyle\begin{pmatrix}G_{1}^{v^{\star}}\\ G_{1}^{v}\\ G_{1}^{k}\end{pmatrix},\dots,\begin{pmatrix}G_{L}^{v^{\star}}\\ G_{L}^{v}\\ G_{L}^{k}\end{pmatrix}\underset{\text{i.i.d.}}{\sim}{\mathcal{N}}\left(0, \begin{pmatrix}1&\nu&\eta\\ \nu&1&\rho\\ \eta&\rho&1\end{pmatrix}\right)\,,\qquad\xi\sim{\mathcal{N}}(0,\varepsilon^{2} )\,.$ $$

Thus

$$ $\displaystyle\begin{pmatrix}-G_{1}^{v^{\star}}\\ -G_{1}^{v}\\ G_{1}^{k}\end{pmatrix},\dots,\begin{pmatrix}-G_{L}^{v^{\star}}\\ -G_{L}^{v}\\ G_{L}^{k}\end{pmatrix}\underset{\text{i.i.d.}}{\sim}{\mathcal{N}}\left(0, \begin{pmatrix}1&\nu&-\eta\\ \nu&1&-\rho\\ -\eta&-\rho&1\end{pmatrix}\right)\,,\qquad-\xi\sim{\mathcal{N}}(0,\varepsilon^ {2})\,.$ $$

As a consequence,

$$ $\displaystyle{\mathcal{R}}^{<}(\kappa,\nu,\theta,\eta,\rho)={\mathcal{R}}^{<}( \kappa,\nu,-\theta,-\eta,-\rho)\,.$ $$

Taking the partial derivative in $\theta$, we are led to

$$ $\partial_{\theta}{\mathcal{R}}^{<}(\kappa,\nu,\theta,\eta,\rho)=-{\mathcal{R}} ^{<}(\kappa,\nu,-\theta,-\eta,-\rho)\,.$ $$

At a point such that $\theta=\eta=\rho=0$, this gives $\partial_{\theta}{\mathcal{R}}^{<}(\kappa,\nu,0,0,0)=-\partial_{\theta}{
\mathcal{R}}^{<}(\kappa,\nu,0,0,0)$
and thus $\partial_{\theta}{\mathcal{R}}^{<}(\kappa,\nu,0,0,0)=0$. The proof for the other two derivatives $\partial_{\eta}{\mathcal{R}}$, $\partial_{\rho}{\mathcal{R}}$ is identical.
∎

We now complete the proof of Lemma 4. By the chain rule for total derivatives applied to $R(k,v)={\mathcal{R}}^{<}(\kappa,\nu,\theta,\eta,\rho)$, and then by Lemma 14, on the manifold ${\mathcal{M}}$, we have

$$ $\displaystyle\nabla_{k}\mathcal{R}$ $\displaystyle=(\partial_{\kappa}\mathcal{R}^{<})k^{\star}+(\partial_{\eta} \mathcal{R}^{<})v^{\star}+(\partial_{\rho}\mathcal{R}^{<})v=(\partial_{\kappa} \mathcal{R}^{<})k^{\star}\,,$ (20) $$

and, similarly,

$$ $\displaystyle\nabla_{v}\mathcal{R}$ $\displaystyle=(\partial_{\nu}\mathcal{R}^{<})v^{\star}+(\partial_{\theta} \mathcal{R}^{<})k^{\star}+(\partial_{\rho}\mathcal{R})k=(\partial_{\nu} \mathcal{R}^{<})v^{\star}\,.$ (21) $$

Recall the formulas for the PGD updates

$$ $\displaystyle k_{t+1}$ $\displaystyle=\mathrm{Proj}_{\mathbb{S}^{d-1}}(k_{t}-\alpha(I-k_{t}k_{t}^{\top })\nabla_{k}\mathcal{R}(k_{t},v_{t}))=\frac{k_{t}-\alpha(I-k_{t}k_{t}^{\top}) \nabla_{k}\mathcal{R}(k_{t},v_{t})}{\left\|k_{t}-\alpha(I-k_{t}k_{t}^{\top}) \nabla_{k}\mathcal{R}(k_{t},v_{t})\right\|_{2}},$ $\displaystyle v_{t+1}$ $\displaystyle=\mathrm{Proj}_{\mathbb{S}^{d-1}}(v_{t}-\alpha(I-v_{t}v_{t}^{\top })\nabla_{v}\mathcal{R}(k_{t},v_{t}))=\frac{v_{t}-\alpha(I-v_{t}v_{t}^{\top}) \nabla_{v}\mathcal{R}(k_{t},v_{t})}{\left\|v_{t}-\alpha(I-v_{t}v_{t}^{\top}) \nabla_{v}\mathcal{R}(k_{t},v_{t})\right\|_{2}}\,.$ $$

Let $c_{k}=\left\|k_{t}-\alpha(I-k_{t}k_{t}^{\top})\nabla_{k}\mathcal{R}(k_{t},v_{t
})\right\|_{2}$ and $c_{v}=\left\|v_{t}-\alpha(I-v_{t}v_{t}^{\top})\nabla_{v}\mathcal{R}(k_{t},v_{t
})\right\|_{2}$.
Then, if $(k_{t},v_{t})\in\mathcal{M}$,

$$ $\displaystyle(v^{\star})^{\top}k_{t+1}$ $\displaystyle=\frac{(v^{\star})^{\top}k_{t}-\alpha(v^{\star})^{\top}(I-k_{t}k_ {t}^{\top})(\partial_{\kappa}\mathcal{R}^{<}(\kappa_{t},\nu_{t}))k^{\star}}{c_ {k}}=0,$ $\displaystyle(k^{\star})^{\top}v_{t+1}$ $\displaystyle=\frac{(k^{\star})^{\top}v_{t}-\alpha(k^{\star})^{\top}(I-v_{t}v_ {t}^{\top})(\partial_{\nu}\mathcal{R}^{<}(\kappa_{t},\nu_{t}))v^{\star}}{c_{v} }=0,$ $$

and

$$ $\displaystyle v_{t+1}^{\top}k_{t+1}$ $\displaystyle=\frac{v_{t}^{\top}k_{t}-\alpha(\partial_{\nu}\mathcal{R}^{<})((I -v_{t}v_{t}^{\top})v^{\star})^{\top}k_{t}-\alpha(\partial_{\kappa}\mathcal{R}^ {<})((I-k_{t}k_{t}^{\top})k^{\star})^{\top}v_{t}}{c_{v}c_{k}}$ $\displaystyle\qquad+\frac{\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<})( \partial_{\nu}\mathcal{R}^{<})((I-k_{t}k_{t}^{\top})k^{\star})^{\top}(I-v_{t}v _{t}^{\top})v^{\star}}{c_{v}c_{k}}=0\,,$ $$

where we have omitted the dependence of $(\partial_{\kappa}\mathcal{R}^{<})$ and $(\partial_{\nu}\mathcal{R}^{<})$ in $(\kappa_{t},\nu_{t})$ in the last expression for the ease of readability.
Note that the last term is equal to zero since

$$ $((I-k_{t}k_{t}^{\top})k^{\star})^{\top}(I-v_{t}v_{t}^{\top})v^{\star}=(k^{ \star}-\kappa_{t}k_{t})^{\top}(v^{\star}-\nu_{t}v_{t})=0\,.$ $$

This shows that $(k_{t+1},v_{t+1})\in\mathcal{M}$.

###### Lemma 14 .

###### Proof.

### A.5. Proof of Lemma 7

By definition of the PGD iterates and by (20)–(21), one has

$$ $\displaystyle\kappa_{t+1}$ $\displaystyle=k_{t+1}^{\top}k^{\star}=\frac{\kappa_{t}-\alpha\partial_{\kappa} \mathcal{R}^{<}(\kappa_{t},\nu_{t})(k^{\star})^{\top}(I-k_{t}k_{t}^{\top})k^{ \star}}{\sqrt{1+\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<})^{2}\|(I-k_{t}k_{t }^{\top})k^{\star}\|_{2}^{2}}}=\frac{\kappa_{t}-\alpha(\partial_{\kappa} \mathcal{R}^{<})(1-\kappa_{t}^{2})}{\sqrt{1+\alpha^{2}(\partial_{\kappa} \mathcal{R}^{<})^{2}(1-\kappa_{t}^{2})}},$ $\displaystyle\nu_{t+1}$ $\displaystyle=v_{t+1}^{\top}v^{\star}=\frac{\nu_{t}-\alpha\partial_{\nu} \mathcal{R}^{<}(\kappa_{t},\nu_{t})(v^{\star})^{\top}(I-v_{t}v_{t}^{\top})v^{ \star}}{\sqrt{1+\alpha^{2}(\partial_{\nu}\mathcal{R}^{<})^{2}\|(I-v_{t}v_{t}^{ \top})v^{\star}\|_{2}^{2}}}=\frac{\nu_{t}-\alpha(\partial_{\nu}\mathcal{R}^{<} )(1-\nu_{t}^{2})}{\sqrt{1+\alpha^{2}(\partial_{\nu}\mathcal{R}^{<})^{2}(1-\nu_ {t}^{2})}},$ $$

where we have used the Pythagorean theorem and the idempotent property of projection matrices for the denominator.

### A.6. Proof of Proposition 8

In this proof, $C$ denotes a constant that does not depend on the step $t$ nor on the step size $\alpha$, and which may vary from line to line.
First note that the risk $\mathcal{R}^{<}$ is $C^{\infty}$ on the compact set $[-1,1]^{2}$. In particular, it is a $\Lambda$-smooth function for some $\Lambda>0$, in the sense that its gradient is $\Lambda$-Lipschitz continuous. Thus

$$ $\displaystyle\mathcal{R}^{<}(\kappa_{t+1},\nu_{t+1})$ $\displaystyle\leqslant\mathcal{R}^{<}(\kappa_{t},\nu_{t})+(\nabla\mathcal{R}^{ <}(\kappa_{t},\nu_{t}))^{\top}\begin{pmatrix}\kappa_{t+1}-\kappa_{t}\\ \nu_{t+1}-\nu_{t}\end{pmatrix}+\frac{\Lambda}{2}\left\|\begin{pmatrix}\kappa_{ t+1}-\kappa_{t}\\ \nu_{t+1}-\nu_{t}\end{pmatrix}\right\|_{2}^{2}\,,$ $$

i.e.,

$$ $\displaystyle\mathcal{R}^{<}$ $\displaystyle(\kappa_{t+1},\nu_{t+1})-\mathcal{R}^{<}(\kappa_{t},\nu_{t})$ $\displaystyle\leqslant(\partial_{\kappa}\mathcal{R}^{<})(\kappa_{t+1}-\kappa_{ t})+(\partial_{\nu}\mathcal{R}^{<})(\nu_{t+1}-\nu_{t})+\frac{\Lambda}{2}\left[ (\kappa_{t+1}-\kappa_{t})^{2}+(\nu_{t+1}-\nu_{t})^{2}\right].$ (22) $$

Our goal in the following computations is to derive an inequality of the form

$$ $\displaystyle\mathcal{R}^{<}(\kappa_{t+1},\nu_{t+1})-\mathcal{R}^{<}(\kappa_{t },\nu_{t})$ $\displaystyle\leqslant-\alpha(\partial_{\kappa}\mathcal{R}^{<})^{2}(1-\kappa_{ t}^{2})-\alpha(\partial_{\nu}\mathcal{R}^{<})^{2}(1-\nu_{t}^{2})$ $\displaystyle\qquad+C\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<})^{2}(1-\kappa _{t}^{2})+C\alpha^{2}(\partial_{\nu}\mathcal{R}^{<})^{2}(1-\nu_{t}^{2})\,,$ $$

which shall give us a descent lemma for $\alpha$ small enough.
To this aim, observe that, by definition of the iterates $(\kappa_{t},\nu_{t})$ given by (12)–(13), one has

$$ $\displaystyle\kappa_{t+1}-\kappa_{t}$ $\displaystyle=\left[\frac{1}{\sqrt{1+\alpha^{2}(\partial_{\kappa}\mathcal{R}^{ <})^{2}(1-\kappa_{t}^{2})}}-1\right]\kappa_{t}-\frac{\alpha(\partial_{\kappa} \mathcal{R}^{<})(1-\kappa_{t}^{2})}{\sqrt{1+\alpha^{2}(\partial_{\kappa} \mathcal{R}^{<})^{2}(1-\kappa_{t}^{2})}}$ (23) $\displaystyle=-\alpha(\partial_{\kappa}\mathcal{R}^{<})(1-\kappa_{t}^{2})$ $\displaystyle\qquad+\left[\frac{1}{\sqrt{1+\alpha^{2}(\partial_{\kappa} \mathcal{R}^{<})^{2}(1-\kappa_{t}^{2})}}-1\right](\kappa_{t}-\alpha(\partial_{ \kappa}\mathcal{R}^{<})(1-\kappa_{t}^{2}))\,.$ $$

As a consequence,

$$ $\displaystyle|\kappa_{t+1}-\kappa_{t}+\alpha(\partial_{\kappa}\mathcal{R}^{<}) (1-\kappa_{t}^{2})|$ $\displaystyle\leqslant\Big{|}\frac{1}{\sqrt{1+\alpha^{2}(\partial_{\kappa} \mathcal{R}^{<})^{2}(1-\kappa_{t}^{2})}}-1\Big{|}|\kappa_{t}-\alpha(\partial_{ \kappa}\mathcal{R}^{<})(1-\kappa_{t}^{2})|$ $\displaystyle\leqslant\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<})^{2}(1- \kappa_{t}^{2})|\kappa_{t}-\alpha(\partial_{\kappa}\mathcal{R}^{<})(1-\kappa_{ t}^{2})|$ $\displaystyle\leqslant C\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<})^{2}(1- \kappa_{t}^{2})\,,$ (24) $$

where the second inequality holds by Lemma 16 and the last bound holds since the function $(\kappa,\nu)\mapsto|\kappa-\alpha(\partial_{\kappa}\mathcal{R}^{<}(\kappa,\nu)
)(1-\kappa^{2})|$ is uniformly bounded for all $\alpha\leqslant 1$.
This bound has two implications. First,

$$ $\displaystyle(\partial_{\kappa}\mathcal{R}^{<})(\kappa_{t+1}-\kappa_{t})+ \alpha(\partial_{\kappa}\mathcal{R}^{<})^{2}(1-\kappa_{t}^{2})$ $\displaystyle=(\partial_{\kappa}\mathcal{R}^{<})((\kappa_{t+1}-\kappa_{t})+ \alpha(\partial_{\kappa}\mathcal{R}^{<})(1-\kappa_{t}^{2}))$ $\displaystyle\leqslant|\partial_{\kappa}\mathcal{R}^{<}||\kappa_{t+1}-\kappa_{ t}+\alpha(\partial_{\kappa}\mathcal{R}^{<})(1-\kappa_{t}^{2})|$ $\displaystyle\leqslant C\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<})^{2}(1- \kappa_{t}^{2})\,,$ (25) $$

where we use the fact that $|\partial_{\kappa}\mathcal{R}^{<}|$ is bounded, and the bound (24).
Second, since the square function is Lipschitz on compact sets, we have

$$ $\displaystyle|(\kappa_{t+1}-\kappa_{t})^{2}-(\alpha(\partial_{\kappa}\mathcal{ R}^{<})(1-\kappa_{t}^{2}))^{2}|\leqslant C\alpha^{2}(\partial_{\kappa}\mathcal {R}^{<})^{2}(1-\kappa_{t}^{2})\,.$ $$

Thus

$$ $\displaystyle(\kappa_{t+1}-\kappa_{t})^{2}$ $\displaystyle\leqslant\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<})^{2}(1- \kappa_{t}^{2})^{2}+C\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<})^{2}(1-\kappa _{t}^{2})$ $\displaystyle\leqslant C\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<})^{2}(1- \kappa_{t}^{2})\,.$ (26) $$

We also obtain analogous bounds to (25)–(26) for $\nu$, namely

$$ $\displaystyle(\partial_{\nu}\mathcal{R}^{<})(\nu_{t+1}-\nu_{t})+\alpha( \partial_{\nu}\mathcal{R}^{<})(1-\nu_{t}^{2})\leqslant C\alpha^{2}(\partial_{ \nu}\mathcal{R}^{<})^{2}(1-\nu_{t}^{2})\,,$ (27) $$

and

$$ $(\nu_{t+1}-\nu_{t})^{2}\leqslant C\alpha^{2}(\partial_{\nu}\mathcal{R}^{<})^{2 }(1-\nu_{t}^{2})\,.$ (28) $$

Plugging the bounds (25)–(28) into Eq. (22), we obtain the desired inequality

$$ $\displaystyle\mathcal{R}^{<}(\kappa_{t+1},\nu_{t+1})-\mathcal{R}^{<}(\kappa_{t },\nu_{t})$ $\displaystyle\leqslant-\alpha(\partial_{\kappa}\mathcal{R}^{<})^{2}(1-\kappa_{ t}^{2})-\alpha(\partial_{\nu}\mathcal{R}^{<})^{2}(1-\nu_{t}^{2})$ $\displaystyle\qquad+C\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<})^{2}(1-\kappa _{t}^{2})+C\alpha^{2}(\partial_{\nu}\mathcal{R}^{<})^{2}(1-\nu_{t}^{2})\,.$ $$

By choosing the step size $\alpha\leqslant\frac{1}{2C}$, this ensures that

$$ $\displaystyle\mathcal{R}^{<}(\kappa_{t+1},\nu_{t+1})-\mathcal{R}^{<}(\kappa_{t },\nu_{t})$ $\displaystyle\leqslant-\frac{\alpha}{2}(\partial_{\kappa}\mathcal{R}^{<})^{2}( 1-\kappa_{t}^{2})-\frac{\alpha}{2}(\partial_{\nu}\mathcal{R}^{<})^{2}(1-\nu_{t }^{2}).$ $$

This shows that the risk is decreasing along the PGD iterates.
Next, introducing ${\mathcal{R}}_{\min}^{<}=\min_{(\kappa,\nu)\in[0,1]^{2}}{\mathcal{R}}^{<}(
\kappa,\nu)$ and using a telescopic sum, we have,
for all $T\geqslant 0$,

$$ $\displaystyle\mathcal{R}^{<}(\kappa_{0},\nu_{0})-{\mathcal{R}}^{<}_{\min}$ $\displaystyle\geqslant\mathcal{R}^{<}(\kappa_{0},\nu_{0})-\mathcal{R}^{<}( \kappa_{T},\nu_{T})$ $\displaystyle\geqslant\frac{\alpha}{2}\sum_{t=0}^{T-1}\left[(\partial_{\kappa} \mathcal{R}^{<})^{2}(1-\kappa_{t}^{2})+(\partial_{\nu}\mathcal{R}^{<})^{2}(1- \nu_{t}^{2})\right].$ $$

Since the left-hand side is finite, and the terms of the sum are nonnegative, we conclude that the series converges as $T\to\infty$. In particular, the generic term $(\partial_{\kappa}\mathcal{R}^{<})^{2}(1-\kappa_{t}^{2})+(\partial_{\nu}
\mathcal{R}^{<})^{2}(1-\nu_{t}^{2})$ of the series converges to 0 as $t\to\infty$. Therefore, the accumulation points $(\kappa_{\infty},\nu_{\infty})$ satisfy

$$ $\left\{\begin{array}[]{l}\partial_{\kappa}\mathcal{R}^{<}(\kappa_{\infty},\nu_ {\infty})=0\quad\text{or}\quad\kappa_{\infty}^{2}=1\\ \partial_{\nu}\mathcal{R}^{<}(\kappa_{\infty},\nu_{\infty})=0\quad\text{or} \quad\nu_{\infty}^{2}=1.\end{array}\right.$ $$

Inspecting identity (23), we observe that the convergence of the general term also implies $\kappa_{t+1}-\kappa_{t}\to 0$. We obtain similarly that $\nu_{t+1}-\nu_{t}\to 0$.

### A.7. Proof of Proposition 9

Recall that the risk in terms of $(\kappa,\nu)$ is given by

$$ ${{\mathcal{R}}^{<}(\kappa,\nu)}=\gamma^{2}-2\gamma^{2}\nu\,\mathrm{erf}\left( \frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\right)+\gamma^ {2}\zeta\Big{(}\lambda\sqrt{\frac{d}{2}}\,\kappa,\lambda^{2}\gamma^{2}\Big{)}+ (L-1)\zeta(0,\lambda^{2})+\varepsilon^{2}\,.$ $$

Then the gradients of ${\mathcal{R}}^{<}$ are given by

$$ $\displaystyle\partial_{\kappa}$ $\displaystyle\mathcal{R}^{<}(\kappa,\nu)$ $\displaystyle=-2\gamma^{2}\lambda\sqrt{\frac{d}{2(1+2\lambda^{2}\gamma^{2})}} \mathrm{erf}^{\prime}\bigg{(}\frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{ 2}\gamma^{2}}}\bigg{)}\bigg{(}\nu-\mathrm{erf}\bigg{(}\frac{\lambda\sqrt{d/2} \kappa}{\sqrt{(1+2\lambda^{2}\gamma^{2})(1+4\lambda^{2}\gamma^{2})}}\bigg{)} \bigg{)}$ $$

and

$$ $\partial_{\nu}\mathcal{R}^{<}(\kappa,\nu)=-2\gamma^{2}\mathrm{erf}\bigg{(} \frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\bigg{)}\,.\\$ $$

Therefore, the solutions of the system (14) satisfy

$$ $\begin{cases}-\nu+\mathrm{erf}(c_{1}\kappa)=0\textnormal{ or }\kappa=\pm 1\\ \kappa=0\textnormal{ or }\nu=\pm 1\,,\\ \end{cases}$ $$

with $c_{1}=\frac{\lambda}{\sqrt{4\lambda^{2}\gamma^{2}+1}}\sqrt{\frac{d}{2(1+2
\lambda^{2}\gamma^{2})}}$.
The solutions of this system are

$$ $(\kappa,\nu)=(0,0)\text{ or }(\kappa,\nu)=(\pm 1,\pm 1)\,.$ $$

### A.8. Proof of Proposition 10

Since ${\mathcal{R}}^{<}$ is a smooth function, the extrema of this function on $[-1,1]^{2}$ are either critical points (admitting null derivatives) or points on the boundary of the square $[-1,1]^{2}$. Starting with critical points, the only critical point is $(0,0)$, and it is a saddle point. Indeed, the Hessian of ${\mathcal{R}}^{<}$ at (0,0) is

$$ $H_{{\mathcal{R}}^{<}}(0,0)=-\frac{4}{\sqrt{\pi}}\gamma^{2}\lambda\sqrt{\frac{d }{2(1+2\lambda^{2}\gamma^{2})}}\underbrace{\begin{pmatrix}c&1\\ 1&0\end{pmatrix}}_{:=M}\,$ $$

where $c=-\frac{2\lambda}{\sqrt{\pi(4\lambda^{2}\gamma^{2}+1)}}\sqrt{\frac{d}{2(1+2
\lambda^{2}\gamma^{2})}}<0$. Then, as $\mathrm{det}(M)=-1$, the two eigenvalues of $H_{{\mathcal{R}}^{<}}(0,0)$ have opposite signs, $(0,0)$ is thus a saddle point. The extrema of ${\mathcal{R}}^{<}$ must therefore be on the boundary of the square, which we examine next.

For any $(\kappa,\nu)\in(-1,1)^{2}$, one has, by inspecting the signs of the gradients given in the proof of Proposition 9,

$$ ${\mathcal{R}}^{<}(1,1)<{\mathcal{R}}^{<}(\kappa,1)<{\mathcal{R}}^{<}(-1,1)\, \quad\textnormal{and}\quad{\mathcal{R}}^{<}(1,1)<{\mathcal{R}}^{<}(1,\nu)<{ \mathcal{R}}^{<}(1,-1)\,.$ $$

This shows that the minimum of ${\mathcal{R}}^{<}$ on $\{(\kappa,1),\kappa\in[-1,1]\}\cup\{(1,\nu),\nu\in[-1,1]\}$ is reached at $(1,1)$, and the maximum is reached both at $(1,-1)$ and $(-1,1)$, since ${\mathcal{R}}^{<}$ is even. Using again evenness of ${\mathcal{R}}^{<}$, we conclude that the extrema of ${\mathcal{R}}^{<}$ on the whole boundary of the square, and thus on the whole square, are the minimizers $(1,1)$ and $(-1,-1)$, and the maximizers $(1,-1)$ and $(-1,1)$.

### A.9. Proof of Proposition 12

We prove the statements of the proposition one by one.

The mapping $g$ is a local diffeomorphism around $(0,0)$, whose Jacobian matrix has one eigenvalue in $(0,1)$ and one eigenvalue in $(1,\infty)$.  Consider the Taylor expansion of the first component $g(\kappa,\nu)_{1}$ of $g(\kappa,\nu)$. Since $\partial_{\kappa}\mathcal{R}^{<}(0,0)=0$, and $\mathcal{R}^{<}$ is smooth, letting $x=(\kappa,\nu)$, we have $(\partial_{\kappa}\mathcal{R}^{<}(\kappa,\nu))^{2}=O(\|x\|^{2})$. Thus,

$$ $\displaystyle g(\kappa,\nu)_{1}$ $\displaystyle=\frac{\kappa-\alpha(\partial_{\kappa}\mathcal{R}^{<}(\kappa,\nu) )(1-\kappa^{2})}{\sqrt{1+\alpha^{2}(\partial_{\kappa}\mathcal{R}^{<}(\kappa, \nu))^{2}(1-\kappa^{2})}}$ $\displaystyle=\frac{\kappa-\alpha(\partial_{\kappa}\mathcal{R}^{<}(\kappa,\nu) )(1-\kappa^{2})}{\sqrt{1+O(\|x\|^{2})}}$ $\displaystyle=(\kappa-\alpha(\partial_{\kappa}\mathcal{R}^{<}(\kappa,\nu))(1- \kappa^{2}))\left(1+O(\|x\|^{2})\right)$ $\displaystyle=\kappa-\alpha\partial_{\kappa}\mathcal{R}^{<}(\kappa,\nu)+O(\|x \|^{2})\,.$ $$

Proceeding similarly with the second component of $g$, we obtain that the Jacobian of $g$ at $(0,0)$ is given by

$$ $J_{g}(0,0)=I_{2}-\alpha H_{{\mathcal{R}}^{<}}(0,0)=I_{2}+\alpha\cdot\frac{4}{ \sqrt{\pi}}\gamma^{2}\lambda\sqrt{\frac{d}{2(1+2\lambda^{2}\gamma^{2})}} \underbrace{\begin{pmatrix}c&1\\ 1&0\end{pmatrix}}_{=:M}\,,$ $$

where $c=-\frac{2\lambda}{\sqrt{\pi(4\lambda^{2}\gamma^{2}+1)}}\sqrt{\frac{d}{2(1+2
\lambda^{2}\gamma^{2})}}<0$. Since $\mathrm{det}(M)=-1$, one can choose $\alpha$ small enough so that one eigenvalue of $J_{g}(0,0)$ is strictly between 0 0 and $1$ and the other one is strictly larger than $1$. Therefore, $J_{g}(0,0)$ is invertible, showing that $g$ is a local diffeomorphism around $(0,0)$.

The mapping $g$ is differentiable on $[-1,1]^{2}$, and its Jacobian is not degenerate.  The mapping $g$ is clearly differentiable as a composition of differentiable function. The more delicate part is to show that its Jacobian cannot be degenerate.
To show this statement, observe first that, for $x\in[-1,1]^{2}$, we may write $g(x)=x+\alpha h(x)$, where the first component of $h$ is given by

$$ $\displaystyle h(\kappa,\nu)_{1}$ $\displaystyle=\frac{1}{\alpha}(g(\kappa,\nu)_{1}-\kappa)$ $\displaystyle=\frac{1}{\alpha}\Big{(}\frac{\kappa-\alpha(\partial_{\kappa} \mathcal{R}^{<}(\kappa,\nu))(1-\kappa^{2})}{\sqrt{1+\alpha^{2}(\partial_{ \kappa}\mathcal{R}^{<}(\kappa,\nu))^{2}(1-\kappa^{2})}}-\kappa\Big{)}$ $\displaystyle=\underbrace{\frac{\kappa}{\alpha}\Big{(}\frac{1}{\sqrt{1+\alpha^ {2}(\partial_{\kappa}\mathcal{R}^{<}(\kappa,\nu))^{2}(1-\kappa^{2})}}-1\Big{)} }_{=:f^{(1)}_{\alpha}(\kappa,\nu)}-\underbrace{\frac{(\partial_{\kappa} \mathcal{R}^{<}(\kappa,\nu))(1-\kappa^{2})}{\sqrt{1+\alpha^{2}(\partial_{ \kappa}\mathcal{R}^{<}(\kappa,\nu))^{2}(1-\kappa^{2})}}}_{=:f^{(2)}_{\alpha}( \kappa,\nu)}\,.$ $$

Let us prove that the gradient of $h(\kappa,\nu)_{1}$ is bounded uniformly over $\alpha\leqslant 1$. The uniform boundedness is clear for the gradient of $f^{(2)}_{\alpha}$, which writes as a composition of functions with uniformly bounded gradients for $\alpha\leqslant 1$.
Moving on to $f^{(1)}_{\alpha}$ and letting

$$ $\displaystyle g:\left\{\begin{array}[]{ll}[-1,1]\times[0,B]&\to{\mathbb{R}}\\ (a,b)&\mapsto\frac{a}{\alpha}\big{(}\frac{1}{\sqrt{1+\alpha^{2}b}}-1\big{)}\\ \end{array}\right.\,,\quad B=\sup_{(\kappa,\nu)\in[-1,1]^{2}}(\partial_{\kappa }\mathcal{R}^{<}(\kappa,\nu))^{2}(1-\kappa^{2})\,,$ $$

we observe that $f^{(1)}_{\alpha}$ is the composition of $g$ with a smooth function independent of $\alpha$. In particular, it suffices to show the uniform boundedness of $\nabla g$ to deduce the one of $\nabla f^{(1)}_{\alpha}$.
We further have, by Lemma 16, and for $\alpha\leqslant 1$,

$$ $\big{|}\partial_{a}g(a,b)\big{|}=\frac{1}{\alpha}\Big{|}\frac{1}{\sqrt{1+ \alpha^{2}b}}-1\Big{|}\leqslant\alpha b\leqslant B$ $$

and

$$ $\big{|}\partial_{b}g(a,b)\big{|}=\Big{|}-\frac{\alpha a}{2(1+\alpha^{2}b)^{3/2 }}\Big{|}\leqslant\frac{\alpha}{2}\leqslant\frac{1}{2}\,.$ $$

Therefore, the gradient of $h(\kappa,\nu)_{1}$ is bounded uniformly over $\alpha\leqslant 1$. Proceeding similarly with the gradient of $h(\kappa,\nu)_{2}$, we obtain that the Jacobian of $h(\kappa,\nu)$ is uniformly bounded over $\alpha\leqslant 1$. Recall now that $J_{g}(\kappa,\nu)=I_{2}+\alpha J_{h}(\kappa,\nu)$. Therefore, taking $\alpha$ small enough, we obtain that the eigenvalues of $J_{g}$ have to be bounded away from zero.

The mapping $g$ is injective.  The computation above shows that $h$ is $\beta$-Lipschitz continuous with $\beta$ independent of $\alpha$ (for $\alpha$ small enough).
In particular we can choose $\alpha$ such that $\alpha<1/\beta$. Now,
let $x\neq y\in[-1,1]^{2}$ be such that $g(x)=g(y)$. Then

$$ $\|x-y\|\leqslant\alpha\|h(x)-h(y)\|\leqslant\alpha\beta\|x-y\|<\|x-y\|\,.$ $$

This is a contradiction, showing that $g$ is injective.

### A.10. Proof of Proposition 13

Recall that $(1,-1)$ and $(-1,1)$ are maxima of the risk $\mathcal{R}^{<}$ on $[-1,1]^{2}$ by Proposition 10, and that the value of the risk decreases along the iterates of PGD by Proposition 8. Thus the only possible way to converge to these points is to start the dynamics from them.

The case of the point $(0,0)$ is more delicate. We apply the Center-Stable Manifold theorem (Shub, , Theorem III.7) to $g$, which is a local diffeomorphism around $(0,0)$ by Proposition 12. This guarantees the existence of a local center-stable manifold $W_{\text{loc}}^{\text{cs}}$, which verifies the following properties. First, its codimension is equal to the number of eigenvalues of $J_{g}(0,0)$ of magnitude larger than $1$, that is, $1$, by Proposition 12. Hence it has Lebesgue measure zero. Second, there exists a neighborhood $B$ of 0 0 such that $\bigcap_{t=0}^{\infty}g^{-t}(B)\subset W_{\text{loc}}^{\text{cs}}$. Then, let $W^{s}$ be the set of all $x$ which converge to $(0,0)$ under the gradient map $g$, and take $x\in W^{s}$. Then there exists a $T$ such that $g^{t}(x)\in B$ for all $t\geqslant T$. This means that $g^{T}(x)\in\bigcap_{s=0}^{\infty}g^{-s}(B)$, and thus $g^{T}(x)\in W_{\text{loc}}^{\text{cs}}$. So, $x\in g^{-T}(W_{\text{loc}}^{\text{cs}})$. We have just shown that

$$ $W^{s}\subset\bigcup_{T\geqslant 0}g^{-T}(W_{\text{loc}}^{\text{cs}})\,.$ $$

Finally, we prove that the pre-image of sets of measure zero by $g^{T}$ has measure zero for any $T\geqslant 0$. This shall conclude the proof of the result since countable unions of sets of measure zero have measure zero. To show this, note that $g$ is injective by Proposition 12, and therefore $g^{T}$ is injective too. This allows to define an inverse $g^{-T}$ of $g^{T}$ defined on the image of $g^{T}$, and the pre-image by $g^{T}$ of $W_{\text{loc}}^{\text{cs}}$ is exactly the image by $g^{-T}$ of $W_{\text{loc}}^{\text{cs}}$ (intersected with the domain of definition of $g^{-T}$). Furthermore, by Proposition 12, the Jacobian of $g^{T}$ is invertible. This guarantees that $g^{-T}$ is differentiable by the inverse function theorem. The conclusion follows by recalling that differentiable functions map sets of measure zero to sets of measure zero.

## Appendix B Expression of the risk beyond the invariant manifold

In this appendix, we provide an expression of the risk ${\mathcal{R}}$ beyond the manifold ${\mathcal{M}}$ that extends the one provided in Lemma 6. This result is not needed to prove Theorem 5, and its proof is more involved that the one of Lemma 6. However, we provide it since it might be relevant to follow-up works that would study the dynamics if not initialized on the invariant manifold ${\mathcal{M}}$. It is also useful for the numerical simulations (see Appendix D).

###### Proposition 15 .

We have the closed-form expression

$$ $\displaystyle\mathcal{R}_{\lambda}^{<}(\kappa,\nu,\theta,\eta,\rho)= \varepsilon^{2}+\gamma^{2}$ $\displaystyle-2\gamma^{2}\nu\mathrm{erf}\bigg{(}\frac{\lambda\sqrt{d/2}\kappa} {\sqrt{1+2\lambda^{2}\gamma^{2}}}\bigg{)}-2\lambda\gamma^{2}\sqrt{\frac{d}{2}} \eta\theta\frac{1}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\mathrm{erf}^{\prime}\bigg{ (}\frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\bigg{)}$ $\displaystyle-\frac{2\lambda^{2}\gamma^{4}\eta\rho}{1+2\lambda^{2}\gamma^{2}} \mathrm{erf}^{\prime\prime}\bigg{(}\frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2 \lambda^{2}\gamma^{2}}}\bigg{)}+(\frac{d}{2}\theta^{2}+\gamma^{2})\zeta\Big{(} \lambda\sqrt{\frac{d}{2}}\,\kappa,\lambda^{2}\gamma^{2}\Big{)}$ $\displaystyle+\sqrt{\frac{d}{2}}\left(\theta\rho-\frac{\lambda^{2}\gamma^{2} \rho^{2}\kappa}{1+2\lambda^{2}\gamma^{2}}\right)\frac{4\lambda\gamma^{2}}{ \sqrt{1+2\lambda^{2}\gamma^{2}}}\mathrm{erf}\bigg{(}\frac{\lambda\sqrt{d/2}\, \kappa}{\sqrt{(1+4\lambda^{2}\gamma^{2})(1+2\lambda^{2}\gamma^{2})}}\bigg{)} \mathrm{erf}^{\prime}\bigg{(}\frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{ 2}\gamma^{2}}}\bigg{)}$ $\displaystyle+\frac{4\lambda^{2}\gamma^{4}\rho^{2}}{\sqrt{\pi}\sqrt{1+4\lambda ^{2}\gamma^{2}}(1+2\lambda^{2}\gamma^{2})}\mathrm{erf}^{\prime}\bigg{(}-\frac{ \lambda\sqrt{d}\kappa}{\sqrt{1+4\lambda^{2}\gamma^{2}}}\bigg{)}$ $\displaystyle+(L-1)\left[\zeta(0,\lambda^{2})+\frac{8\lambda^{2}}{\pi\sqrt{1+4 \lambda^{2}}(1+2\lambda^{2})}\rho^{2}\right]+\frac{4\lambda^{2}}{(1+2\lambda^{ 2})\pi}(L-1)(L-2)\rho^{2}$ $\displaystyle+\frac{4\lambda(L-1)\rho}{\sqrt{(1+2\lambda^{2})\pi}}\left(\sqrt{ \frac{d}{2}}\theta\,\mathrm{erf}\bigg{(}\frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1 +2\lambda^{2}\gamma^{2}}}\bigg{)}+\frac{\lambda\gamma^{2}\rho}{\sqrt{1+2 \lambda^{2}\gamma^{2}}}\,\mathrm{erf}^{\prime}\bigg{(}\frac{\lambda\sqrt{d/2} \kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\bigg{)}\right)\,.$ $$

###### Proof.

We first recall the notations for the five scalar products that are used throughout this proof.

$$ $\displaystyle\nu=v^{\top}v^{\star}\,,\quad\kappa=k^{\top}k^{\star}\,,\quad \theta=v^{\top}k^{\star}\,,\quad\eta=k^{\top}v^{\star}\,,\quad\rho=k^{\top}v\,.$ $$

A first decomposition.  We start back from the expression (15) obtained for the risk. By expanding in $\xi$, then expanding the square, we obtain

$$ $\displaystyle{\mathcal{R}}(k,v)$ $\displaystyle=\mathbb{E}\Big{(}\Big{(}X_{1}^{\top}v^{\star}-\sum_{\ell=1}^{L}X _{\ell}^{\top}v\,\mathrm{erf}(\lambda X_{\ell}^{\top}k)\Big{)}^{2}\Big{)}+ \varepsilon^{2}$ $\displaystyle=\mathbb{E}\Big{(}\Big{(}X_{1}^{\top}v^{\star}-X_{1}^{\top}v\, \mathrm{erf}(\lambda X_{1}^{\top}k)-\sum_{\ell=2}^{L}X_{\ell}^{\top}v\,\mathrm {erf}(\lambda X_{\ell}^{\top}k)\Big{)}^{2}\Big{)}+\varepsilon^{2}$ $\displaystyle=\underbrace{\vphantom{\sum_{\ell=2}^{L}}\mathbb{E}\Big{(}\big{(} X_{1}^{\top}v^{\star}-X_{1}^{\top}v\,\mathrm{erf}(\lambda X_{1}^{\top}k)\big{) }^{2}\Big{)}}_{=:\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{rgb}{ 0,0.5,1}\pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1}{0.5 0}{0}{0}R_{1}}+\underbrace{\sum_{\ell=2}^{L}\mathbb{E}\Big{(}\big{(}X_{\ell}^{ \top}v\,\mathrm{erf}(\lambda X_{\ell}^{\top}k)\big{)}^{2}\Big{)}}_{=:\color[ rgb]{0,0.75,0.16}\definecolor[named]{pgfstrokecolor}{rgb}{0,0.75,0.16} \pgfsys@color@cmyk@stroke{0.92}{0}{0.59}{0.25}\pgfsys@color@cmyk@fill{0.92}{0} {0.59}{0.25}R_{2}}$ $\displaystyle\quad+\underbrace{\sum_{\ell\neq j\geqslant 2}^{L}\mathbb{E}\Big{ (}X_{\ell}^{\top}v\,\mathrm{erf}(\lambda X_{\ell}^{\top}k)X_{j}^{\top}v\, \mathrm{erf}(\lambda X_{j}^{\top}k)\Big{)}}_{=:\color[rgb]{0.68,0.36,1} \definecolor[named]{pgfstrokecolor}{rgb}{0.68,0.36,1}\pgfsys@color@cmyk@stroke {0.32}{0.64}{0}{0}\pgfsys@color@cmyk@fill{0.32}{0.64}{0}{0}R_{3}}$ $\displaystyle\quad\underbrace{-2\sum_{\ell=2}^{L}\mathbb{E}\Big{(}\big{(}X_{1} ^{\top}v^{\star}-X_{1}^{\top}v\,\mathrm{erf}(\lambda X_{1}^{\top}k)\big{)}X_{ \ell}^{\top}v\,\mathrm{erf}(\lambda X_{\ell}^{\top}k)\Big{)}}_{=:\color[rgb]{ 1,0.47,0.62}\definecolor[named]{pgfstrokecolor}{rgb}{1,0.47,0.62} \pgfsys@color@cmyk@stroke{0}{0.53}{0.38}{0}\pgfsys@color@cmyk@fill{0}{0.53}{0. 38}{0}R_{4}}+\,\varepsilon^{2}\,.$ $$

Computation of $R_{1}$.  By expanding the square,

$$ $\displaystyle\mathbb{E}\Big{(}\big{(}X_{1}^{\top}v^{\star}$ $\displaystyle-X_{1}^{\top}v\,\mathrm{erf}(\lambda X_{1}^{\top}k)\big{)}^{2} \Big{)}$ $\displaystyle=\mathbb{E}\Big{(}\big{(}X_{1}^{\top}v^{\star}\big{)}^{2}\Big{)}- 2\mathbb{E}\Big{(}X_{1}^{\top}v^{\star}X_{1}^{\top}v\,\mathrm{erf}(\lambda X_{ 1}^{\top}k)\Big{)}+\mathbb{E}\Big{(}\big{(}X_{1}^{\top}v\,\mathrm{erf}(\lambda X _{1}^{\top}k)\big{)}^{2}\Big{)}\,.$ $$

These three terms are computed hereafter. First we have

$$ $\mathbb{E}\Big{(}\big{(}X_{1}^{\top}v^{\star}\big{)}^{2}\Big{)}=\Big{(}\mathbb {E}\big{(}X_{1}^{\top}v^{\star}\big{)}\Big{)}^{2}+\text{Var}\big{(}X_{1}^{\top }v^{\star}\big{)}=(\sqrt{\frac{d}{2}}(k^{\star})^{\top}v^{\star})^{2}+\gamma^{ 2}={\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{rgb}{0,0.5,1} \pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1}{0.50}{0}{0} \gamma^{2}}\,.$ $$

Second,

$$ $\displaystyle\mathbb{E}\Big{(}$ $\displaystyle X_{1}^{\top}v^{\star}X_{1}^{\top}v\,\mathrm{erf}(\lambda X_{1}^{ \top}k)\Big{)}$ $\displaystyle=\mathbb{E}\left[\left(\sqrt{\frac{d}{2}}(k^{\star})^{\top}v^{ \star}+Z_{1}\right)\left(\sqrt{\frac{d}{2}}(k^{\star})^{\top}v+Z_{2}\right)\, \mathrm{erf}\left(\lambda\sqrt{\frac{d}{2}}(k^{\star})^{\top}k+\lambda Z_{3} \right)\right]\,,$ $\displaystyle=\mathbb{E}\left[Z_{1}\left(\sqrt{\frac{d}{2}}\theta+Z_{2}\right) \,\mathrm{erf}\left(\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\right)\right ]\,,$ $$

with

$$ $\displaystyle\begin{pmatrix}Z_{1}\\ Z_{2}\\ Z_{3}\end{pmatrix}$ $\displaystyle\sim\mathcal{N}\left(0,\gamma^{2}\begin{pmatrix}1&v^{\top}v^{ \star}&k^{\top}v^{\star}\\ v^{\top}v^{\star}&1&v^{\top}k\\ k^{\top}v^{\star}&v^{\top}k&1\end{pmatrix}\right)=\mathcal{N}\left(0,\gamma^{2 }\begin{pmatrix}1&\nu&\eta\\ \nu&1&\rho\\ \eta&\rho&1\end{pmatrix}\right)\,.$ $$

Recall the multivariate version of Stein’s lemma (Stein, ), which states that, when $Z,G_{1},\ldots,G_{p}$ are centered and jointly Gaussian, and $\sigma:{\mathbb{R}}^{p}\to{\mathbb{R}}$,

$$ $\displaystyle\mathbb{E}\left[Z\sigma(G_{1},\ldots,G_{p})\right]=\sum_{i=1}^{p} \operatorname*{Cov}(Z,G_{i})\mathbb{E}\left[\partial_{i}\sigma(G_{1},\ldots,G_ {p})\right]\,.$ $$

Therefore,

$$ $\displaystyle\mathbb{E}\Big{(}X_{1}^{\top}v^{\star}X_{1}^{\top}v\mathrm{erf}( \lambda X_{1}^{\top}k)\Big{)}$ $\displaystyle=\gamma^{2}\nu\mathbb{E}\left[\,\mathrm{erf}\left(\lambda\sqrt{ \frac{d}{2}}\kappa+\lambda Z_{3}\right)\right]+\lambda\gamma^{2}\eta\mathbb{E} \left[\left(\sqrt{\frac{d}{2}}\theta+Z_{2}\right)\,\mathrm{erf}^{\prime}\left( \lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\right)\right]$ $\displaystyle=\gamma^{2}\nu\mathbb{E}\left[\,\mathrm{erf}\left(\lambda\sqrt{ \frac{d}{2}}\kappa+\lambda Z_{3}\right)\right]+\lambda\gamma^{2}\sqrt{\frac{d} {2}}\eta\theta\mathbb{E}\left[\,\mathrm{erf}^{\prime}\left(\lambda\sqrt{\frac{ d}{2}}\kappa+\lambda Z_{3}\right)\right]$ $\displaystyle\qquad+\lambda^{2}\gamma^{4}\eta\rho\mathbb{E}\left[\mathrm{erf}^ {\prime\prime}\left(\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\right)\right]$ $\displaystyle={\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{rgb}{ 0,0.5,1}\pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1}{0.5 0}{0}{0}\gamma^{2}\nu\mathrm{erf}\left(\frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+ 2\lambda^{2}\gamma^{2}}}\right)+\sqrt{\frac{d}{2}}\frac{\lambda\gamma^{2}\eta \theta}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\mathrm{erf}^{\prime}\left(\frac{ \lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\right)}$ $\displaystyle\qquad{\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{ rgb}{0,0.5,1}\pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1 }{0.50}{0}{0}+\frac{\lambda^{2}\gamma^{4}\eta\rho}{1+2\gamma^{2}\lambda^{2}} \mathrm{erf}^{\prime\prime}\left(\frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2 \lambda^{2}\gamma^{2}}}\right)}$ $$

by using Lemma 18$(i)-(iii)$.
Finally, using again Stein’s lemma and Lemma 18$(iv)-(vi)$, the computation of the last term is as follows:

$$ $\displaystyle{\mathbb{E}\Big{[}\big{(}X_{1}^{\top}v\,\mathrm{erf}(\lambda X_{1 }^{\top}k)\big{)}^{2}\Big{]}}$ $\displaystyle=\mathbb{E}\left[\bigg{(}\sqrt{\frac{d}{2}}(k^{\star})^{\top}v+Z_ {2}\bigg{)}^{2}\,\mathrm{erf}\bigg{(}\lambda\sqrt{\frac{d}{2}}k^{\top}k^{\star }+\lambda Z_{3}\bigg{)}^{2}\right]$ $\displaystyle=\mathbb{E}\left[\frac{d}{2}\theta^{2}\,\mathrm{erf}^{2}\bigg{(} \lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)}\right]+2\mathbb{E}\left[ \sqrt{\frac{d}{2}}\theta Z_{2}\,\mathrm{erf}^{2}\bigg{(}\lambda\sqrt{\frac{d}{ 2}}\kappa+\lambda Z_{3}\bigg{)}\right]$ $\displaystyle\;+\mathbb{E}\left[Z_{2}^{2}\,\mathrm{erf}^{2}\bigg{(}\lambda \sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)}\right]$ $\displaystyle=\frac{d}{2}\theta^{2}\mathbb{E}\left[\mathrm{erf}^{2}\bigg{(} \lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)}\right]$ $\displaystyle\;+4\lambda\gamma^{2}\sqrt{\frac{d}{2}}\theta\rho\mathbb{E}\left[ \,\mathrm{erf}\bigg{(}\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)}\, \mathrm{erf}^{\prime}\bigg{(}\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3} \bigg{)}\right]+\gamma^{2}\mathbb{E}\left[\,\mathrm{erf}^{2}\bigg{(}\lambda \sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)}\right]$ $\displaystyle\;+2\lambda\gamma^{2}\rho\mathbb{E}\left[Z_{2}\,\mathrm{erf}\bigg {(}\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)}\mathrm{erf}^{\prime} \bigg{(}\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)}\right]$ $\displaystyle=(\frac{d}{2}\theta^{2}+\gamma^{2})\mathbb{E}\left[\mathrm{erf}^{ 2}\bigg{(}\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)}\right]$ $\displaystyle\;+4\lambda\gamma^{2}\sqrt{\frac{d}{2}}\theta\rho\mathbb{E}\left[ \,\mathrm{erf}\bigg{(}\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)}\, \mathrm{erf}^{\prime}\bigg{(}\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3} \bigg{)}\right]$ $\displaystyle\;+2\lambda^{2}\gamma^{4}\rho^{2}\left(\mathbb{E}\left[\mathrm{ erf}\bigg{(}\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)}\mathrm{erf}^ {\prime\prime}\bigg{(}\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\bigg{)} \right]+\mathbb{E}\left[(\mathrm{erf}^{\prime})^{2}\bigg{(}\lambda\sqrt{\frac{ d}{2}}\kappa+\lambda Z_{3}\bigg{)}\right]\right)$ $\displaystyle=(\frac{d}{2}\theta^{2}+\gamma^{2})\zeta\Big{(}\lambda\sqrt{\frac {d}{2}}\,\kappa,\lambda^{2}\gamma^{2}\Big{)}$ $\displaystyle\;+4\lambda\gamma^{2}\sqrt{\frac{d}{2}}\theta\rho\mathbb{E}\left[ \,\mathrm{erf}\left(\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\right)\, \mathrm{erf}^{\prime}\left(\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\right )\right]$ $\displaystyle\;+\frac{2\lambda^{2}\gamma^{4}\rho^{2}}{1+2\lambda^{2}\gamma^{2} }\left(-2\lambda\sqrt{\frac{d}{2}}\kappa\,\mathbb{E}\left[\mathrm{erf}\left( \lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\right)\mathrm{erf}^{\prime}\left (\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\right)\right]\right.$ $\displaystyle\;\left.+\mathbb{E}\left[(\mathrm{erf}^{\prime})^{2}\left(\lambda \sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\right)\right]\right)$ $\displaystyle=(\frac{d}{2}\theta^{2}+\gamma^{2})\zeta\Big{(}\lambda\sqrt{\frac {d}{2}}\,\kappa,\lambda^{2}\gamma^{2}\Big{)}$ $\displaystyle\;+4\lambda\gamma^{2}\sqrt{\frac{d}{2}}\left(\theta\rho-\frac{ \lambda^{2}\gamma^{2}\rho^{2}\kappa}{1+2\lambda^{2}\gamma^{2}}\right)\mathbb{E }\left[\,\mathrm{erf}\left(\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3}\right )\,\mathrm{erf}^{\prime}\left(\lambda\sqrt{\frac{d}{2}}\kappa+\lambda Z_{3} \right)\right]$ $\displaystyle\;+\frac{2\lambda^{2}\gamma^{4}\rho^{2}}{1+2\lambda^{2}\gamma^{2} }\mathbb{E}\left[(\mathrm{erf}^{\prime})^{2}\left(\lambda\sqrt{\frac{d}{2}} \kappa+\lambda Z_{3}\right)\right]$ $\displaystyle={\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{rgb}{ 0,0.5,1}\pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1}{0.5 0}{0}{0}(\frac{d}{2}\theta^{2}+\gamma^{2})\zeta\Big{(}\lambda\sqrt{\frac{d}{2} }\,\kappa,\lambda^{2}\gamma^{2}\Big{)}}$ $\displaystyle{\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{rgb}{ 0,0.5,1}\pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1}{0.5 0}{0}{0}+\sqrt{\frac{d}{2}}\left(\theta\rho-\frac{\lambda^{2}\gamma^{2}\rho^{2 }\kappa}{1+2\lambda^{2}\gamma^{2}}\right)\frac{4\lambda\gamma^{2}}{\sqrt{1+2 \lambda^{2}\gamma^{2}}}\mathrm{erf}\bigg{(}\frac{\lambda\sqrt{d/2}\,\kappa}{ \sqrt{(1+4\lambda^{2}\gamma^{2})(1+2\lambda^{2}\gamma^{2})}}\bigg{)}\mathrm{ erf}^{\prime}\bigg{(}\frac{\lambda\sqrt{d/2}\,\kappa}{\sqrt{1+2\lambda^{2} \gamma^{2}}}\bigg{)}}$ $\displaystyle{\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{rgb}{ 0,0.5,1}\pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1}{0.5 0}{0}{0}+\frac{2\lambda^{2}\gamma^{4}\rho^{2}}{1+2\lambda^{2}\gamma^{2}}\left( \frac{2}{\sqrt{\pi}\sqrt{1+4\lambda^{2}\gamma^{2}}}\mathrm{erf}^{\prime}\bigg{ (}-\frac{\lambda\sqrt{d}\kappa}{\sqrt{1+4\lambda^{2}\gamma^{2}}}\bigg{)}\right)}$ $$

by Lemma 18$(iv)-(vi)$.

Computation of $R_{2}$.  We have

$$ $\displaystyle R_{2}=\sum_{\ell=2}^{L}\mathbb{E}\Big{(}\big{(}X_{\ell}^{\top}v \,\mathrm{erf}(\lambda X_{\ell}^{\top}k)\big{)}^{2}\Big{)}$ $\displaystyle=(L-1)\mathbb{E}\Big{(}\big{(}X_{2}^{\top}v\,\mathrm{erf}(\lambda X _{2}^{\top}k)\big{)}^{2}\Big{)}\,.$ $$

Thus, using previous calculations with $\gamma^{2}=1$, $\theta=0$, and $\kappa=0$, we obtain

$$ $\displaystyle R_{2}$ $\displaystyle=(L-1)\left[\zeta(0,\lambda^{2})+\frac{4\lambda^{2}}{\sqrt{\pi} \sqrt{4\lambda^{2}+1}(1+2\lambda^{2})}\rho^{2}\mathrm{erf}^{\prime}\left(0 \right)\right]$ $\displaystyle={\color[rgb]{0,0.75,0.16}\definecolor[named]{pgfstrokecolor}{rgb }{0,0.75,0.16}\pgfsys@color@cmyk@stroke{0.92}{0}{0.59}{0.25} \pgfsys@color@cmyk@fill{0.92}{0}{0.59}{0.25}(L-1)\left[\zeta(0,\lambda^{2})+ \frac{8\lambda^{2}}{\pi\sqrt{4\lambda^{2}+1}(1+2\lambda^{2})}\rho^{2}\right]}\,.$ $$

Computation of $R_{3}$.  Regarding the cross-product terms, by independence of the $(X_{\ell})$’s and Stein’s lemma, one gets

$$ $\displaystyle\mathbb{E}\Big{(}X_{\ell}^{\top}v\,\mathrm{erf}(\lambda X_{\ell}^ {\top}k)X_{j}^{\top}v\,\mathrm{erf}(\lambda X_{j}^{\top}k)\Big{)}$ $\displaystyle=\mathbb{E}\Big{(}X_{\ell}^{\top}v\,\mathrm{erf}(\lambda X_{\ell} ^{\top}k)\Big{)}\mathbb{E}\Big{(}X_{j}^{\top}v\,\mathrm{erf}(\lambda X_{j}^{ \top}k)\Big{)}=C^{2}\rho^{2}\,,$ $$

with $C:=\lambda\mathbb{E}(\mathrm{erf}^{\prime}(\lambda X_{\ell}^{\top}k))=2\lambda
/\sqrt{(1+2\lambda^{2})\pi}$ by Lemma 18$(i)$. This leads to

$$ ${\color[rgb]{0.68,0.36,1}\definecolor[named]{pgfstrokecolor}{rgb}{0.68,0.36,1} \pgfsys@color@cmyk@stroke{0.32}{0.64}{0}{0}\pgfsys@color@cmyk@fill{0.32}{0.64} {0}{0}R_{3}=\frac{4\lambda^{2}}{(1+2\lambda^{2})\pi}(L-1)(L-2)\rho^{2}}.$ $$

Computation of $R_{4}$.  We have, again by independence and Stein’s lemma,

$$ $\displaystyle\mathbb{E}\Big{(}\big{(}X_{1}^{\top}v^{\star}-X_{1}^{\top}v\, \mathrm{erf}(\lambda X_{1}^{\top}k)\big{)}$ $\displaystyle X_{\ell}^{\top}v\,\mathrm{erf}(\lambda X_{\ell}^{\top}k)\Big{)}$ $\displaystyle=\mathbb{E}\Big{(}X_{1}^{\top}v^{\star}-X_{1}^{\top}v\,\mathrm{ erf}(\lambda X_{1}^{\top}k)\Big{)}\mathbb{E}\Big{(}X_{\ell}^{\top}v\,\mathrm{ erf}(\lambda X_{\ell}^{\top}k)\Big{)}$ $\displaystyle=\Big{(}\sqrt{\frac{d}{2}}(k^{\star})^{\top}v^{\star}-\mathbb{E}( X_{1}^{\top}v\,\mathrm{erf}(\lambda X_{1}^{\top}k))\Big{)}\mathbb{E}\Big{(}X_{ \ell}^{\top}v\,\mathrm{erf}(\lambda X_{\ell}^{\top}k)\Big{)}$ $\displaystyle=-\mathbb{E}(X_{1}^{\top}v\,\mathrm{erf}(\lambda X_{1}^{\top}k)) \cdot C\rho$ $\displaystyle=-\frac{2\lambda\rho}{\sqrt{(1+2\lambda^{2})\pi}}\mathbb{E}(X_{1} ^{\top}v\,\mathrm{erf}(\lambda X_{1}^{\top}k))\,.$ $$

Note that, still using Stein’s lemma,

$$ $\displaystyle-\mathbb{E}($ $\displaystyle X_{1}^{\top}v\,\mathrm{erf}(\lambda X_{1}^{\top}k))$ $\displaystyle=-\mathbb{E}(\sqrt{\frac{d}{2}}(k^{\star})^{\top}v\,\mathrm{erf}( \lambda X_{1}^{\top}k))-\mathbb{E}((X_{1}^{\top}v-\sqrt{\frac{d}{2}}(k^{\star} )^{\top}v)\,\mathrm{erf}(\lambda X_{1}^{\top}k))$ $\displaystyle=-\mathbb{E}(\sqrt{\frac{d}{2}}\theta\,\mathrm{erf}(\lambda X_{1} ^{\top}k))-\mathrm{Cov}\Big{(}X_{1}^{\top}v,\,\mathrm{erf}(\lambda X_{1}^{\top }k)\Big{)}$ $\displaystyle=-\sqrt{\frac{d}{2}}\theta\,\mathbb{E}(\mathrm{erf}(\lambda X_{1} ^{\top}k))-\lambda\mathrm{Cov}\Big{(}X_{1}^{\top}v,X_{1}^{\top}k\Big{)}\mathbb {E}\Big{(}\,\mathrm{erf}^{\prime}(\lambda X_{1}^{\top}k)\Big{)}$ $\displaystyle=-\sqrt{\frac{d}{2}}\theta\,\mathrm{erf}\left(\frac{\lambda\sqrt{ d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\right)-\lambda\gamma^{2}(k^{\top} v){{\frac{1}{\sqrt{1+2\gamma^{2}\lambda^{2}}}\,\mathrm{erf}^{\prime}\left( \frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\right)}},$ $$

where we used that $\lambda X_{1}^{\top}k\overset{\mathcal{L}}{=}\lambda\sqrt{d/2}\kappa+G$ with $G\sim\mathcal{N}(0,\lambda^{2}\gamma^{2})$, in combination with Lemma 18$(i)-(ii)$.
Thus

$$ $\displaystyle{\color[rgb]{1,0.47,0.62}\definecolor[named]{pgfstrokecolor}{rgb} {1,0.47,0.62}\pgfsys@color@cmyk@stroke{0}{0.53}{0.38}{0} \pgfsys@color@cmyk@fill{0}{0.53}{0.38}{0}R_{4}=\frac{4\lambda(L-1)\rho}{\sqrt{ (1+2\lambda^{2})\pi}}\left(\sqrt{\frac{d}{2}}\theta\,\mathrm{erf}\Big{(}\frac{ \lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\Big{)}+\frac{\lambda \gamma^{2}\rho}{\sqrt{1+2\gamma^{2}\lambda^{2}}}\,\mathrm{erf}^{\prime}\Big{(} \frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\Big{)}\right)}.$ $$

All in all.  Putting everything together, we obtain

$$ $\displaystyle{{\mathcal{R}}(k,v)}=\varepsilon^{2}$ $\displaystyle+{\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{rgb}{ 0,0.5,1}\pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1}{0.5 0}{0}{0}\gamma^{2}-2\gamma^{2}\nu\mathrm{erf}\bigg{(}\frac{\lambda\sqrt{d/2} \kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\bigg{)}-2\lambda\gamma^{2}\sqrt{\frac {d}{2}}\eta\theta\frac{1}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\mathrm{erf}^{\prime }\bigg{(}\frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\bigg{ )}}$ $\displaystyle{\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{rgb}{ 0,0.5,1}\pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1}{0.5 0}{0}{0}-\frac{2\lambda^{2}\gamma^{4}\eta\rho}{1+2\lambda^{2}\gamma^{2}} \mathrm{erf}^{\prime\prime}\bigg{(}\frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2 \lambda^{2}\gamma^{2}}}\bigg{)}+(\frac{d}{2}\theta^{2}+\gamma^{2})\zeta\Big{(} \lambda\sqrt{\frac{d}{2}}\,\kappa,\lambda^{2}\gamma^{2}\Big{)}}$ $\displaystyle{\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{rgb}{ 0,0.5,1}\pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1}{0.5 0}{0}{0}+\sqrt{\frac{d}{2}}\left(\theta\rho-\frac{\lambda^{2}\gamma^{2}\rho^{2 }\kappa}{1+2\lambda^{2}\gamma^{2}}\right)\frac{4\lambda\gamma^{2}}{\sqrt{1+2 \lambda^{2}\gamma^{2}}}\mathrm{erf}\bigg{(}\frac{\lambda\sqrt{d/2}\,\kappa}{ \sqrt{(1+4\lambda^{2}\gamma^{2})(1+2\lambda^{2}\gamma^{2})}}\bigg{)}\mathrm{ erf}^{\prime}\bigg{(}\frac{\lambda\sqrt{d/2}\,\kappa}{\sqrt{1+2\lambda^{2} \gamma^{2}}}\bigg{)}}$ $\displaystyle{\color[rgb]{0,0.5,1}\definecolor[named]{pgfstrokecolor}{rgb}{ 0,0.5,1}\pgfsys@color@cmyk@stroke{1}{0.50}{0}{0}\pgfsys@color@cmyk@fill{1}{0.5 0}{0}{0}+\frac{4\lambda^{2}\gamma^{4}\rho^{2}}{\sqrt{\pi}\sqrt{1+4\lambda^{2} \gamma^{2}}(1+2\lambda^{2}\gamma^{2})}\mathrm{erf}^{\prime}\bigg{(}-\frac{ \lambda\sqrt{d}\kappa}{\sqrt{1+4\lambda^{2}\gamma^{2}}}\bigg{)}}$ $\displaystyle+{\color[rgb]{0,0.75,0.16}\definecolor[named]{pgfstrokecolor}{rgb }{0,0.75,0.16}\pgfsys@color@cmyk@stroke{0.92}{0}{0.59}{0.25} \pgfsys@color@cmyk@fill{0.92}{0}{0.59}{0.25}(L-1)\left[\zeta(0,\lambda^{2})+ \frac{8\lambda^{2}}{\pi\sqrt{1+4\lambda^{2}}(1+2\lambda^{2})}\rho^{2}\right]}+ {\color[rgb]{0.68,0.36,1}\definecolor[named]{pgfstrokecolor}{rgb}{0.68,0.36,1} \pgfsys@color@cmyk@stroke{0.32}{0.64}{0}{0}\pgfsys@color@cmyk@fill{0.32}{0.64} {0}{0}\frac{4\lambda^{2}}{(1+2\lambda^{2})\pi}(L-1)(L-2)\rho^{2}}$ $\displaystyle+{\color[rgb]{1,0.47,0.62}\definecolor[named]{pgfstrokecolor}{rgb }{1,0.47,0.62}\pgfsys@color@cmyk@stroke{0}{0.53}{0.38}{0} \pgfsys@color@cmyk@fill{0}{0.53}{0.38}{0}\frac{4\lambda(L-1)\rho}{\sqrt{(1+2 \lambda^{2})\pi}}\left(\sqrt{\frac{d}{2}}\theta\,\mathrm{erf}\bigg{(}\frac{ \lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\bigg{)}+\frac{ \lambda\gamma^{2}\rho}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\,\mathrm{erf}^{\prime} \bigg{(}\frac{\lambda\sqrt{d/2}\kappa}{\sqrt{1+2\lambda^{2}\gamma^{2}}}\right) }\,.$ $$

This concludes the proof.
∎

###### Proposition 15 .

###### Proof.

## Appendix C Technical results

This section gathers formulas that are useful in the proofs, in particular regarding expectation of functions of Gaussian random variables involving $\mathrm{erf}$.

###### Lemma 16 .

For $u\geqslant 0$,

$$ $\Big{|}\frac{1}{\sqrt{1+u}}-1\Big{|}\leqslant u\,.$ $$

###### Proof.

The argument of the absolute value is non-positive for $u\geqslant 0$, hence we need to show that

$$ $f(u):=1-\frac{1}{\sqrt{1+u}}-u$ $$

is non-positive for $u\geqslant 0$. Just note that

$$ $f(0)=0\quad\textnormal{and}\quad f^{\prime}(u)=\frac{1}{(1+u)^{3+2}}-1 \leqslant 0\,.$ $$

∎

Recall that the $\mathrm{erf}$ function is defined on $\mathbb{R}$ as

$$ $\mathrm{erf}(u)=\frac{2}{\sqrt{\pi}}\int_{0}^{u}e^{-t^{2}}dt\,.$ $$

###### Lemma 17 (Properties of the $\mathrm{erf}$ function) .

We have

$$ $\displaystyle\mathrm{erf}^{\prime}(u)$ $\displaystyle=\frac{2}{\sqrt{\pi}}e^{-u^{2}}\,,$ $\displaystyle\mathrm{erf}^{\prime\prime}(u)$ $\displaystyle=-\frac{4}{\sqrt{\pi}}ue^{-u^{2}}=-2u\mathrm{erf}^{\prime}(u)\,,$ $\displaystyle|\mathrm{erf}(u)|$ $\displaystyle\leqslant\frac{2}{\sqrt{\pi}}|u|\,.$ $$

###### Proof.

The first two statements are clear by usual differentiation rules. Regarding the last statement, since $\mathrm{erf}$ is an odd function, it is sufficient to prove the statement for $u\geqslant 0$. Moreover, $\mathrm{erf}$ is concave on $[0,\infty)$, so we get, for $u\geqslant 0$,

$$ $|\mathrm{erf}(u)|=|\mathrm{erf}(u)-\mathrm{erf}(0)|\leqslant\mathrm{erf}^{ \prime}(0)u=\frac{2}{\sqrt{\pi}}u\,,$ $$

which concludes the proof.
∎

###### Lemma 18 .

Let $G\sim\mathcal{N}(0,\gamma^{2})$. For $t\in\mathbb{R}$,

- (i)
$\mathbb{E}\left[\mathrm{erf}^{\prime}(t+G)\right]=\frac{1}{\sqrt{1+2\gamma^{2}
}}\mathrm{erf}^{\prime}\Big{(}\frac{t}{\sqrt{1+2\gamma^{2}}}\Big{)}$.
- (ii)
$\mathbb{E}\left[\mathrm{erf}(t+G)\right]=\mathrm{erf}\Big{(}\frac{t}{\sqrt{1+2
\gamma^{2}}}\Big{)}$.
- (iii)
$\mathbb{E}\left[\mathrm{erf}^{\prime\prime}(t+G)\right]=\frac{1}{1+2\gamma^{2}
}\mathrm{erf}^{\prime\prime}\Big{(}\frac{t}{\sqrt{1+2\gamma^{2}}}\Big{)}$.
- (iv)
$\mathbb{E}\left[(\mathrm{erf}^{\prime})^{2}(t+G)\right]=\frac{2}{\sqrt{\pi}
\sqrt{1+4\gamma^{2}}}\mathrm{erf}^{\prime}\Big{(}-\frac{\sqrt{2}t}{\sqrt{1+4
\gamma^{2}}}\Big{)}$.
- (v)
$(1+2\gamma^{2})\mathbb{E}[\mathrm{erf}(t+G)\mathrm{erf}^{\prime\prime}(t+G)]=-
2t\,\mathbb{E}[\mathrm{erf}(t+G)\mathrm{erf}^{\prime}(t+G)]-2\gamma^{2}\mathbb
{E}[(\mathrm{erf}^{\prime}(t+G))^{2}]$.
- (vi)
$\mathbb{E}\left[\mathrm{erf}(t+G)\mathrm{erf}^{\prime}(t+G)\right]=\frac{1}{
\sqrt{1+2\gamma^{2}}}\mathrm{erf}\Big{(}\frac{t}{\sqrt{(1+4\gamma^{2})(1+2
\gamma^{2})}}\Big{)}\mathrm{erf}^{\prime}\Big{(}\frac{t}{\sqrt{1+2\gamma^{2}}}
\Big{)}$.

###### Proof.

- (i)
By Lemma 17,
$\displaystyle\mathbb{E}\left[\mathrm{erf}^{\prime}(t+G)\right]$
$\displaystyle=\frac{\sqrt{2}}{\pi\gamma}\int e^{-(t+g)^{2}}e^{-\frac{g^{2}}{2
\gamma^{2}}}\mathrm{d}g$
$\displaystyle=\frac{\sqrt{2}}{\pi\gamma}\int e^{-\frac{g^{2}}{c}}e^{-2gt}e^{-t
^{2}}\mathrm{d}g\qquad\text{for}\quad c:=\frac{2\gamma^{2}}{1+2\gamma^{2}}$
$\displaystyle=\frac{\sqrt{2}}{\pi\gamma}\int e^{-\frac{(g+ct)^{2}}{c}+ct^{2}-t
^{2}}\mathrm{d}g$
$\displaystyle=\frac{\sqrt{2}}{\pi\gamma}e^{-t^{2}(1-c)}\underbrace{\int e^{-
\frac{(g+ct)^{2}}{c}}\mathrm{d}g}_{=\sqrt{\pi c}}$
$\displaystyle=\frac{2}{\sqrt{\pi(1+2\gamma^{2})}}\exp\left(-t^{2}\left(1-\frac
{2\gamma^{2}}{1+2\gamma^{2}}\right)\right)$
$\displaystyle=\frac{2}{\sqrt{\pi}\sqrt{1+2\gamma^{2}}}\exp\left(-\frac{t^{2}}{
1+2\gamma^{2}}\right)\,.$
- (ii)
By $(i)$,
$\displaystyle\mathbb{E}\left[\mathrm{erf}(t+G)\right]$
$\displaystyle=\int_{-\infty}^{t}\mathbb{E}\left[\mathrm{erf}^{\prime}(s+G)
\right]ds$
$\displaystyle=\int_{-\infty}^{t}\frac{2}{\sqrt{\pi}\sqrt{1+2\gamma^{2}}}\exp
\left(-\frac{s^{2}}{1+2\gamma^{2}}\right)ds$
$\displaystyle=\int_{-\infty}^{t/\sqrt{1+2\gamma^{2}}}\frac{2}{\sqrt{\pi}}\exp
\left(-u^{2}\right)ds$
$\displaystyle=\mathrm{erf}\Big{(}\frac{t}{\sqrt{1+2\gamma^{2}}}\Big{)}\,.$
- (iii)
By Lemma 17, and following the same steps as in $(i)$,
$\displaystyle\mathbb{E}\left[\mathrm{erf}^{\prime\prime}(t+G)\right]$
$\displaystyle=-\frac{2\sqrt{2}}{\sqrt{\pi}\gamma}\int(t+g)e^{-(t+g)^{2}}e^{-
\frac{g^{2}}{2\gamma^{2}}}dg$
$\displaystyle=-\frac{2\sqrt{2}}{\pi\gamma}e^{-t^{2}(1-c)}\int(t+g)e^{-\frac{(g
+ct)^{2}}{c}}dg$
$\displaystyle=-\frac{2\sqrt{2}}{\pi\gamma}e^{-t^{2}(1-c)}\Big{(}t\sqrt{\pi c}+
\sqrt{\pi c}\mathbb{E}({\mathcal{N}}(-ct,\frac{c}{2}))\Big{)}$
$\displaystyle=-\frac{2\sqrt{2c}}{\sqrt{\pi}\gamma}e^{-t^{2}(1-c)}(t-ct)$
$\displaystyle=-\frac{4}{\sqrt{\pi(1+2\gamma^{2})}}e^{-t^{2}(1-c)}\frac{1}{1+2
\gamma^{2}}t$
$\displaystyle=-\frac{4t}{\sqrt{\pi}(1+2\gamma^{2})^{3/2}}\exp\left(-\frac{t^{2
}}{1+2\gamma^{2}}\right)\,.$
- (iv)
By Lemma 17,
$\displaystyle\mathbb{E}\left[(\mathrm{erf}^{\prime})^{2}(t+G)\right]$
$\displaystyle=\frac{1}{\sqrt{2\pi}\gamma}\int(\mathrm{erf}^{\prime})^{2}(t+g)e
^{-\frac{g^{2}}{2\gamma^{2}}}\,\mathrm{d}g$
$\displaystyle=\frac{2\sqrt{2}}{\gamma\pi^{3/2}}\int e^{-2(t+g)^{2}}e^{-\frac{g
^{2}}{2\gamma^{2}}}\,\mathrm{d}g$
$\displaystyle=\frac{2\sqrt{2}}{\gamma\pi^{3/2}}\int e^{-\frac{g^{2}}{2\Gamma^{
2}}}e^{-4gt}e^{-2t^{2}}\,\mathrm{d}g\qquad\text{with}\quad\Gamma^{2}:=\gamma^{
2}/(1+4\gamma^{2})$
$\displaystyle=\frac{2\sqrt{2}}{\gamma\pi^{3/2}}\int e^{-\frac{(g+4\Gamma^{2}t)
^{2}}{2\Gamma^{2}}}e^{8\Gamma^{2}t^{2}}e^{-2t^{2}}\,\mathrm{d}g$
$\displaystyle=\frac{2\sqrt{2}}{\gamma\pi^{3/2}}e^{-2t^{2}(1-4\Gamma^{2})}\int e
^{-\frac{(g+4\Gamma^{2}t)^{2}}{2\Gamma^{2}}}\,\mathrm{d}g$
$\displaystyle=\frac{2\sqrt{2}}{\gamma\pi^{3/2}}e^{-2t^{2}(1-4\Gamma^{2})}\sqrt
{2\pi}\Gamma$
$\displaystyle=\frac{4}{\pi\sqrt{1+4\gamma^{2}}}\exp\left(-\frac{2t^{2}}{1+4
\gamma^{2}}\right)\,.$
- (v)
We use Lemma 17 and then Stein’s lemma:
$\displaystyle\mathbb{E}[\mathrm{erf}(t+G)$
$\displaystyle\mathrm{erf}^{\prime\prime}(t+G)]$
$\displaystyle=-2\mathbb{E}\left[(t+G)\mathrm{erf}(t+G)\mathrm{erf}^{\prime}(t+
G)\right]$
$\displaystyle=-2t\mathbb{E}\left[\mathrm{erf}(t+G)\mathrm{erf}^{\prime}(t+G)
\right]-2\mathbb{E}\left[G\mathrm{erf}(t+G)\mathrm{erf}^{\prime}(t+G)\right]$
$\displaystyle=-2t\mathbb{E}\left[\mathrm{erf}(t+G)\mathrm{erf}^{\prime}(t+G)\right]$
$\displaystyle\qquad-2\gamma^{2}\left(\mathbb{E}\left[\mathrm{erf}^{\prime}(t+G
)^{2}\right]+\mathbb{E}\left[\mathrm{erf}(t+G)\mathrm{erf}^{\prime\prime}(t+G)
\right]\right)\,.$
Reordering terms, this gives the desired equation.
- (vi)
We define the function
$\displaystyle f(t)=\mathbb{E}\left[\mathrm{erf}(t+G)\mathrm{erf}^{\prime}(t+G)
\right]\,.$
Then, using Lemma 18$(v)$, we have
$\displaystyle f^{\prime}(t)$
$\displaystyle=\mathbb{E}\left[\mathrm{erf}^{\prime}(t+G)^{2}\right]+\mathbb{E}
\left[\mathrm{erf}(t+G)\mathrm{erf}^{\prime\prime}(t+G)\right]$
$\displaystyle=\mathbb{E}\left[\mathrm{erf}^{\prime}(t+G)^{2}\right]-\frac{2t}{
1+2\gamma^{2}}\,\mathbb{E}\left[\mathrm{erf}(t+G)\mathrm{erf}^{\prime}(t+G)\right]$
$\displaystyle\qquad-\frac{2\gamma^{2}}{1+2\gamma^{2}}\mathbb{E}\left[(\mathrm{
erf}^{\prime}(t+G))^{2}\right]$
$\displaystyle=\frac{1}{1+2\gamma^{2}}\mathbb{E}\left[(\mathrm{erf}^{\prime}(t+
G))^{2}\right]-\frac{2t}{1+2\gamma^{2}}f(t)\,.$
We solve this differential equation by the method of variation of parameters: we have
$\displaystyle\frac{\mathrm{d}}{\mathrm{d}t}\left(f(t)e^{t^{2}/(1+2\gamma^{2})}
\right)=\frac{1}{1+2\gamma^{2}}\mathbb{E}\left[(\mathrm{erf}^{\prime}(t+G))^{2
}\right]e^{t^{2}/(1+2\gamma^{2})}\,.$
We use Lemmas 17 and 18$(iv)$:
$\displaystyle\frac{\mathrm{d}}{\mathrm{d}t}\left(f(t)e^{t^{2}/(1+2\gamma^{2})}\right)$
$\displaystyle=\frac{2}{\sqrt{\pi}}\frac{1}{(1+2\gamma^{2})\sqrt{1+4\gamma^{2}}
}\mathrm{erf}^{\prime}\left(-\frac{\sqrt{2}t}{\sqrt{1+4\gamma^{2}}}\right)e^{t
^{2}/(1+2\gamma^{2})}$
$\displaystyle=\frac{4}{\pi}\frac{1}{(1+2\gamma^{2})\sqrt{1+4\gamma^{2}}}e^{-2t
^{2}/(1+4\gamma^{2})}e^{t^{2}/(1+2\gamma^{2})}$
$\displaystyle=\frac{4}{\pi}\frac{1}{(1+2\gamma^{2})\sqrt{1+4\gamma^{2}}}\exp
\left(-\frac{t^{2}}{(1+2\gamma^{2})(1+4\gamma^{2})}\right)$
$\displaystyle=\frac{2}{\sqrt{\pi}}\frac{1}{(1+2\gamma^{2})\sqrt{1+4\gamma^{2}}
}\mathrm{erf}^{\prime}\left(\frac{t}{\sqrt{(1+2\gamma^{2})(1+4\gamma^{2})}}
\right)\,.$
As the distribution of $G$ is symmetric and $\mathrm{erf}$ is an odd function, we have that $f(0)=\mathbb{E}\left[\mathrm{erf}(G)\mathrm{erf}^{\prime}(G)\right]=0$. Thus integrating the above derivative, we obtain
$\displaystyle f(t)e^{t^{2}/(1+2\gamma^{2})}$
$\displaystyle=\frac{2}{\sqrt{\pi}}\frac{1}{(1+2\gamma^{2})\sqrt{1+4\gamma^{2}}
}\int_{0}^{t}\mathrm{d}s\,\mathrm{erf}^{\prime}\left(\frac{s}{\sqrt{(1+2\gamma
^{2})(1+4\gamma^{2})}}\right)$
$\displaystyle=\frac{2}{\sqrt{\pi}}\frac{1}{\sqrt{1+2\gamma^{2}}}\mathrm{erf}
\left(\frac{t}{\sqrt{(1+2\gamma^{2})(1+4\gamma^{2})}}\right)\,.$
Using again Lemma 17, we obtain the claimed result:
$f(t)=\frac{1}{\sqrt{1+2\gamma^{2}}}\mathrm{erf}^{\prime}\left(\frac{t}{\sqrt{1
+2\gamma^{2}}}\right)\mathrm{erf}\left(\frac{t}{\sqrt{(1+2\gamma^{2})(1+4
\gamma^{2})}}\right)\,.$

∎

###### Lemma 16 .

###### Proof.

###### Lemma 17 (Properties of the erf erf \mathrm{erf} roman_erf function) .

###### Proof.

###### Lemma 18 .

###### Proof.

## Appendix D Experimental details and additional results

Our code is available at

[https://github.com/PierreMarion23/single-location-regression](https://github.com/PierreMarion23/single-location-regression).

We use the Transformers (Wolf et al., ) and scikit-learn (Pedregosa et al., ) libraries for the experiment of Section 2, and JAX (Bradbury et al., ) for the experiment of Section 5.
All experiments run in a short time (less than one hour) on a standard laptop.

### D.1. Experiment of Section 2 (NLP motivations)

Data generation.  We use synthetically-generated data for this experiment. To create our train set, we generate sentences according to the patterns

The city is [SENTIMENT ADJ]. [PRONOUN] [COLOR ADJ] [ANIMAL] is [ADV] [SENTIMENT ADJ].

and

The city is [SENTIMENT ADJ]. [PRONOUN] [SENTIMENT ADJ] [ANIMAL] is [ADV] [COLOR ADJ].

where ADJ stands for adjective and ADV for adverb.
Note that the difference between the two patterns is that the locations of the sentiment and of the color adjectives are swapped. Each element between brackets corresponds to a word, which can take a few different values that are chosen manually. For instance, some possible sentiment adjectives are nice, clean, cute, delightful, mean, dirty, or nasty. A possible value for some words is $\emptyset$, meaning that we remove the word from the sentence, which creates more variety in sentence length. By doing the Cartesian product over the possible values of each word in brackets, we generate in this way a large number of examples. Then, the label associated to each example depends solely on the sentiment adjective appearing in the second sentence. For instance, the words nice, clean, cute, or delightful are associated to a label $+1$, while the words delightful, mean, and dirty are associated to a label $-1$.

We now explain how the test sets are generated. We generate four test sets in order to assess the robustness of the model to various out-of-distribution changes. The baseline test set uses the same sentence patterns and the same sentiment adjectives as in the training set, but other words in the example (e.g., animals, adverb) are different. In particular, a given sentence cannot appear both in the train set and in the test set. Then, we generate another test set by using sentiment adjectives that are not present in the training set. We emphasize that the sentiment adjective fully determines the label, so using unseen adjectives at test time makes the task significantly harder. The third test set uses the same adjectives as in the train set, but another sentence pattern, namely

Hello, how are you? Good evening, [PRONOUN] [COLOR ADJ] [ANIMAL] is [ADV] [SENTIMENT ADJ].

Finally, the fourth test set combines a different sentence pattern and unseen adjectives. The size of the datasets is given in Table 1. All datasets have the same number of $+1$ and $-1$ labels.

**Table 1. Size of the generated datasets.**
| Name | Number of examples |
| --- | --- |
| Train set | $15552$ |
| Test set | $4608$ |
| Test w. OOD tokens | $3072$ |
| Test w. OOD structure | $144$ |
| Test w. OOD structure+tokens | $96$ |

Model.  We recall that there exists several families of Transformer architectures, which in particular are not all best suited for sequence classification. An appropriate family is called encoder-only Transformer, and a foremost example is BERT (Devlin et al., ). We refer to Phuong and Hutter () for an introductory discussion of Transformer architectures and associated algorithms. Here, we use a pretrained BERT model from the Hugging Face Transformers library (Wolf et al., ), with the default configuration, namely bert-base-uncased. The model has $110$M parameters, $12$ layers, the tokens have dimension $d=768$, and each attention layer has $12$ heads. It was pretrained by masked language modeling, namely some tokens in the input are hidden, and the model learns to predict the missing tokens. We refer to Devlin et al. () for details on the architecture and pretraining procedure. We do not perform any fine-tuning on the model.

Experiment design.  Our experiment consists in performing logistic regression on embeddings of [CLS] tokens in the hidden layers of the pretrained BERT model, where we recall that the [CLS] token is a special token added to the beginning of each input sequence. This is a particular case of the so-called linear probing, which is a common technique in the field of LLMs interpretability. More precisely, let $\ell$ denote a layer index between 0 0 and $12$, where the index 0 0 corresponds to the input to the model (after tokenization and embedding in ${\mathbb{R}}^{d}$). Then, for each value of $\ell\in\{0,\dots,12\}$, we train a logistic regression classifier, where, for each example, the input to the classifier is the embedding of the [CLS] token at layer $\ell$ (that is, a $d$-dimensional vector), and the label is simply the label of the sentence as described above.

Results.  For $\ell=0$ (blue bar in Figure 1(b)), the embedding of [CLS] is a fixed vector that does not depend on the rest of the sequence, so the classifier has a pure-chance accuracy of $50\%$. However, as soon as $\ell>0$, thanks to the attention mechanism, the [CLS] token contains information about the sequence. We report in Figure 1(b) the average accuracy over $\ell\in\{1,\dots,12\}$ for the train set (in orange) and the test sets (in green). We observe that the information contained in the [CLS] token is actually very rich, since logistic regression achieves a perfect accuracy of $100\%$ in the train set. In other words, the data fed to the classifier is linearly separable. We emphasize that the size of the train set is significantly larger than the ambient dimension $d$, so it is far from trivial that this procedure would yield a linearly-separable dataset. Therefore, obtaining linearly-separable data demonstrates that the model constructs a linear representations of the input inside the [CLS] token. Moving on to the test sets, the accuracy on the baseline test set is very good ($95\%$), which suggests some generalization abilities of the model. The accuracy on the out-of-distribution test sets degrades (between $64\%$ and $75\%$), but remains largely superior to pure-chance performance. This suggests that the internal representation built by the Transformer model is to some extent universal, in the sense that it is robust to the specifics of the sentence structure and of the word choice.

### D.2. Experiment of Section 5 (Gradient descent recovers the oracle predictor)

We begin by providing additional results before giving experimental details.

PGD with an initialization on the sphere and constant inverse temperature schedule.  As emphasized in Section 5, the dynamics of PGD with a general initialization on $(\mathbb{S}^{d-1})^{2}$ depend on the choice of the inverse temperature schedule $\lambda_{t}$. The experiment presented in the main text in Figure 4(a) is for a decreasing schedule $\lambda_{t}=1/(1+10^{-4}t)$. We report in Figure 7 results when taking a constant inverse temperature. We observe distinct patterns depending on the value of this parameter. With a large inverse temperature (Figure 7(a)), we observe that the dynamics in $(\kappa,\nu)$ always escape the neighborhood of 0 0. Furthermore, the direction $v^{\star}$ is almost perfectly recovered, i.e., $\nu\approx 1$. However, the value of $k^{\star}$ is only partially recovered: the dynamics stabilize around $\kappa\approx 0.3$. Moreover, the excess risk plateaus at a high value, while the dynamics stay far away from the manifold ${\mathcal{M}}$. In the case of a smaller inverse temperature (Figure 7(b)), the situation is different. We observe that some initializations lead to a convergence to the point $(\kappa,\nu)=(0,0)$, in which case the dynamics stay far from the manifold ${\mathcal{M}}$. In other words, there is no recovery of $k^{\star}$ and $v^{\star}$. Other initializations lead to perfect recovery of $k^{\star}$ and $v^{\star}$. In all cases, the final excess risk is low.
Theoretical study of these observations is left for future work.

Figure: (a) For $\lambda_{t}=0.9$.
Refer to caption: x9.png

Implementation details.  The implementation of the PGD algorithm (10) requires to compute the gradient of the risk. To this aim, we use the formula for the risk given by Proposition 15. Note that all quantities appearing in this expression have explicit derivatives. The only quantity for which this is not directly clear is the function $\zeta$, which needs to be differentiated with respect to its first variable to compute the derivative of the risk with respect to $\kappa$. However, recall that $\zeta(t,\gamma^{2}):=\mathbb{E}\left[\mathrm{erf}^{2}(t+G)\right]$. Then, by Lemma (18),

$$ $\displaystyle\partial_{t}\zeta(t,\gamma^{2})$ $\displaystyle=2\mathbb{E}\left[(\mathrm{erf}\,\mathrm{erf}^{\prime})(t+G)\right]$ $\displaystyle=\frac{2}{\sqrt{1+2\gamma^{2}}}\mathrm{erf}\left(\frac{t}{\sqrt{( 1+4\gamma^{2})(1+2\gamma^{2})}}\right)\mathrm{erf}^{\prime}\left(\frac{t}{ \sqrt{1+2\gamma^{2}}}\right)\,.$ $$

Evaluating $\zeta$ itself (and not its derivative) is not required to simulate the dynamics, but is useful for reporting the value of the risk. For this, we also use the formula above, and use numerical quadrature to compute the value of

$$ $\zeta(t,\gamma^{2})=\int_{-\infty}^{t}\partial_{s}\zeta(s,\gamma^{2})ds\,.$ $$

We report in the figures the value of the excess risk, i.e., the risk ${\mathcal{R}}_{\lambda}(k,v)-\varepsilon^{2}$.
To compute the distance to the manifold ${\mathcal{M}}$, recall that it is defined by

$$ $\mathcal{M}=\{(k,v)\in\mathbb{S}^{d-1}\times\mathbb{S}^{d-1},k^{\top}v^{\star} =0,v^{\top}k^{\star}=0,k^{\top}v=0\}\,.$ $$

For a point $(k,v)\in\mathbb{S}^{d-1}\times\mathbb{S}^{d-1}$, its distance to ${\mathcal{M}}$ is therefore computed as

$$ $d_{\mathcal{M}}((k,v))=\sqrt{(k^{\top}v^{\star})^{2}+(v^{\top}k^{\star})^{2}+( k^{\top}v)^{2}}\,.$ $$

Parameter values.  The following table summarizes the value of the parameters in our experiments.

**Table 2. Parameter values for the experiments on recovery of the oracle predictor by gradient descent.**
| Name | Figure 4(a) | Figure 4(b) | Figure 5 | Figure 7(a) | Figure 7(b) |
| --- | --- | --- | --- | --- | --- |
| $d$ | $400$ | $400$ | $80$ | $400$ | $400$ |
| $L$ | $10$ | $10$ | $10$ | $10$ | $10$ |
| $\gamma$ | $1/\sqrt{2}$ | $1/\sqrt{2}$ | $1/\sqrt{2}$ | $1/\sqrt{2}$ | $1/\sqrt{2}$ |
| $\lambda_{t}$ | $1/(1+10^{-4}t)$ | $0.1$ | $2/(1+10^{-4}t)$ | $0.9$ | $0.1$ |
| $\alpha$ | $4\cdot 10^{-3}$ | $4\cdot 10^{-3}$ | $10^{-3}$ | $10^{-3}$ | $4\cdot 10^{-3}$ |
| Number of steps | $120$k | $20$k | $200$k | $120$k | $20$k |
| N. of repetitions | $30$ | $30$ | $30$ | $30$ | $30$ |
| Batch size | - | - | $5$ | - | - |
| $\varepsilon$ | 0 0 | 0 0 | $0.1$ | 0 0 | 0 0 |

## Peer Reviews

confidence: 3
contribution: 3
initial_rating: 6
presentation: 4
questions: 1. What's the function of input in Figure 1 (a)? It seems that the Y label just depends on the output and the input is not related to the sentimental label?
soundness: 3
strengths: 1. The paper is well-written and easy to follow. For example, the step-by-step illustration of how to connect the construction to the attention mechanism in Section 3 is helpful for understanding.
2. The choice of model is good, like using [CLS] property which is observed in empirical study in (5) is natural and reasonable, and using erf as nonlinear weight function is also reasonable. In general, the theoretical result is solid.
3. Also contain some empirical result for showing the convergence of constructed model
summary: This paper introduces a new theoretical approach to understand attention mechanisms by considering a task called single-location regression. The authors consider a simplified model that's related to self-attention layer and shows that the model can achieves asymptotic Bayes optimality, while linear regressors fail. The authors also use PGD to show that the non-convex loss function still converge.
weaknesses: 1. The setting is restricted to single position token, although it focus on the sparse attention settings and it's already difficult to analyze, it's still far from the real-world case. Besides, the authors haven't done experiments on real-world experiments (like sentimental tasks as shown in Figure 1) to support some claims in the paper, this may kind of reduce the impact of the theoretical analysis. But in general it's already good as a theoretical-centric paper.

---

confidence: 4
contribution: 2
initial_rating: 6
presentation: 3
questions: See weaknesses.
soundness: 3
strengths: The paper is well-written and easy to follow. A novel task called "single-location regression task" is introduced to satisfy the sparsity of the token and model real-world tasks to some extent. Despite the non-convexity and non-linearity, the paper is able to analyze the training dynamics and show the asymptotic Bayes optimality.
summary: This paper studies the ability of attention mechanisms to deal with token-wise sparsity and internal linear representations. In order to demonstrate the capability, the paper proposes a simplified version of a self-attention layer to solve the single-location regression task, showing an asymptotic Bayes optimality and analyzing training dynamics.
weaknesses: 1. The proposed task may be over-simplified and lack generality. For instance, it assumes that the tokens other than $X_{J_0}$ have zero mean and only one token contains information.
2. The paper shows the connection to a single self-attention layer by using the assumption that $p=1$. Although the low-rank property may come true after the training process, it is so strong to make this assumption directly.
3. It is uncommon to use the function $erf$ to replace the softmax function. To demonstrate the feasibility of this simplification, more explanations or theoretical backups should be provided.
4. The paper shows the asymptotic results of $k_t, v_t$, while a non-asymptotic result is needed to investigate the convergence rates of these two parameters.
5. The initialization is limited to the specific manifold, which is better to extend to a more general one.
6. The current experiments only validate the theoretical results on synthetic datasets. It is recommended that the authors consider adding some experiments on real datasets to test the effects.

---

confidence: 4
contribution: 3
initial_rating: 8
presentation: 4
questions: - Could you point out (and explain) the steps in your proofs that would break if softmax were considered instead of erf. My guess is that preserving the independence  is key (via elementwise application) but could sigmoid or any other nonlinear bounded increasing and differential elementwise activation work as well? It might be helpful to mention early on that the analysis could extend to a broader class of activations if that’s the case (modulo adjustments of the formulae in theorem 1).  
- Linear predictors are shown to fail at solving the task and the comparison to them is much appreciated. Do you have a sense of how non linear predictors would in turn perform, thus this could show how attention layers are to be preferred to fully-connected layers for instance in such contexts (an analogue of proposition 3 in this case may not be true and probably non trivial to show, but in any case, interesting to discuss or to investigate). 
- Are the tokens assumed to be independent (line 74) or independent conditionally on J_0 (line 85)? I did not read the proofs so I couldn’t figure it out  myself but would be good to clarify. More generally, could you explain at which points of your proofs the independence is needed to help readers understand how this assumption could be relaxed for future works concerned with more realistic scenarios.
- Minor: line 1832 "Our code is available at [XXX]" in the appendix. 
- Extra minor: line 469: a space is missing between "Figure 4a" and "(right)"
soundness: 4
strengths: - The paper is extremely well written and very easy and pleasant to read. 
- The analysis is theoretically strong and rigorous
- More generally, this work promotes an approach that is worth being acknowledged and valued: looking into a simpler problem than the ones practitioners can face, yet relevant, and solve it completely and rigorously.
- Additionally, the problem is well connected to practical concerns, with the authors made a convincing case for the significance of their analysis.
summary: This paper introduces a new task, the single location regression task, showing it is solvable by a predictor resembling an attention layer, when a linear predictor fails. The result is theoretically well grounded and of good significance given the limited theory on attention layers and their striking efficacy. This task relates to key famous NLP problems known in the existing literature, serving as a good testbed for studying Transformers through a theoretical lens. The statistical performance of this attention-like optimal predictor is shown to exceed the one of an optimal linear predictor, under minimal assumptions. (projected) Gradient descent, is demonstrated to reach the optimal solution, wiith experiments provided to support the theory.
weaknesses: By decreasing order of importance

- The present work’s approach is not so well connected to the existing literature in line 103: "note that our task shares similarities with single-index models (McCulllagh & Nelder, 1983) and mixtures of linear regressions (De Veaux, 1989)". I see the differences between those works and the present one being hightlighted in the following sentence , but the exact nature of these similarities is not clear. Could this connection be elaborated?
- Minor: In the caption of figure 2, it may be helpful to add a note about the size of the squares, that presumably indicates the level of alignment.
- line 234: "We emphasize that empirically this simplification of softmax using a component-wise nonlinearity has been shown not to degrade performance". The cited paper Wortsman et al, 2023 indeed indicates such behaviour but their experiments include a normalisation. 
- Broadly speaking, the question of whether softmax is needed in attention layers remains an open and unresolved one in the commuinity. To avoid overstating the case, consider rephrasing to reflect this ongoing debate. Note that I don’t think having used erf in your analysis diminushes the value of your work in any way.

---

confidence: 4
contribution: 2
initial_rating: 6
presentation: 3
questions: 1. What is the specific convergence rate in Theorem 5? Since this forms a key part of the contribution in characterizing the training dynamics, a more detailed presentation in the main paper would be beneficial.

2. In line 334, why is the entire sum on the order of $\Theta(\lambda \sqrt{L})$?

3. The PGD analysis relies on a relatively strong assumption that the initialization lies on the manifold. Could the authors discuss any possibilities for generalizing the current analysis to accommodate a broader range of initializations?
soundness: 3
strengths: 1. The mathematical analysis from both statistical and optimization perspectives is insightful, offering a comprehensive theoretical guarantee.

2. The paper is well-written and easy to follow.

3. Experiements are provided to support the theoretical findings.
summary: This work examines the transformer mechanism for solving the single-location regression task within a simplified non-linear self-attention setting. It provides a Bayes optimality guarantee for the oracle network predictor and demonstrates how the training dynamics allow the network to converge to this solution using projected gradient descent.
weaknesses: My main concern lies in the motivation for studying this specific setting, characterized by token-wise sparsity and internal linear representations.  While these features are relevant to real-world NLP scenarios, the essential mechanism for transformers to succeed in this setting is, first, to identify the underlying structure (the latent sparse pattern in this work) and then to perform a task-specific operation on this structure (linear transformations here). This intrinsic mechanism has been extensively explored across various settings (e.g., [1-3]), even with more realistic softmax attention. Thus, the technical significance of studying a simplified attention model in such a specific setting remains unclear. Could the authors elaborate on the specific technical difficulties encountered in this setting? What are the key technical challenges in extending the analysis to more realistic softmax attention?



[1] How Transformers Learn Causal Structure with Gradient Descent. Nichani et al., 2024

[2] Vision Transformers provably learn spatial structure. Jelassi et al, 2022

[3] Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannot. Wang et al., 2024

Meta-review: All reviewers find the paper written well presenting analysis of attention learning a rather simple problem. Authors argue that such thorough analysis is missing for Attention; even though done for a simpler setting, involves non-trivial complexities in the analysis. Other concerns were around model simplification such as removing softmax in attention for analysis. Overall I think this is a borderline paper

Decision: Accept (Poster)