SlowGuess/NeurIPS_2023_OCR huggingface dataset:
$$
S _ {d, d ^ {\prime}, i, j} = \| u \left(\tau_ {2 j, d - 1}, \tau_ {2 i, d ^ {\prime} - 1}\right) + u \left(\tau_ {2 j, d - 1}, \tau_ {2 i - 1, d ^ {\prime} - 1}\right) \| \leq \frac {1 6 D R _ {\epsilon}}{N} \| P _ {d, j} \left[ \bar {\theta} _ {N} ^ {(2)} \right] \| _ {2}. \tag {47}
$$
Proof of Corollary 3. This proof is in fact a direct combination of Theorems 1 and 3. By Theorem 1 we know there exists a weight  $\theta^{(2)*}$  that can reach zero loss for arbitrarily length  $N$ . Then it holds that  $\| \theta_{\lambda, N} \|_2 \leq \| \theta^{(2)*} \|$  as  $\theta_{\lambda, N}$  minimizes the regularized loss. Noticing that bounded weight implies bounded Lipschitzness of  $\mathbf{g}^{(2)}$ , the rest follows as Theorem 3.
We now show the limitation of interpretability from a single component, using a Lottery-Ticket-style argument by pruning from large random Transformers.
Theorem 2 (Indistinguishability From a Single Component). Consider any  $L$ -layer Transformer  $\mathcal{T}$  (Equation (10)) with embedding dimension  $m$ , attention dimension  $m_a$ , and projection function  $g$  as 2-layer ReLU MLP with width  $w$ . For any  $\delta \in (0,1)$  and  $N \in \mathbb{N}^+$ , consider a 4L-layer random Transformer  $\mathcal{T}_{\text{large}}$  with embedding dimension  $m_{\text{large}} = O(m \log (Lm / \delta))$ , attention dimension  $m_{\text{large},a} = O(m_a L \log \frac{m_a mLN}{\epsilon\delta})$ , and projection function  $g_{\text{large}}$  as 4-layer ReLU MLP with width  $w_{\text{large}} = O(\max \{m, w\} L \log \frac{w mLN}{\epsilon\delta})$ .
Assume that  $\| W\| _2\leq 1$  for every weight matrix  $W$  in  $\mathcal{T}$ , and suppose the weights are randomly sampled as  $W_{i,j}\sim U(-1,1)$  for every  $W\in \mathcal{T}_{large}$ . Then, with probability  $1 - \delta$  over the randomness of  $\mathcal{T}_{large}$ , there exists a nonstructural pruning (Definition 4) of  $\mathcal{T}_{large}$ , denoted as  $\tilde{\mathcal{T}}_{large}$ , which  $\epsilon$ -approximates  $\mathcal{T}$  with respect to  $\| \cdot \|_{1,2}$  for any input  $X\in \mathbb{R}^{m\times N}$  satisfying  $\| X\|_{1,2}\leq 1$ .<sup>19</sup>
Proof. We will first introduce some notation. For vector  $x \in \mathbb{R}^a$  and  $y \in \mathbb{R}^b$ , we will use  $x \oplus y$  to denote their concatenation. We will use  $0^a$  to denote the all-zero vector with dimension  $a$ . We will also assume without loss of generality that  $w \geq 2m$ .<sup>20</sup>
We will use  $\bar{\pmb{X}}$  to denote  $\left[ \begin{array}{c}\pmb {X}\\ 0^{(m_{\mathrm{large}} - m^{\prime})\times N} \end{array} \right]$  for  $X\in \mathbb{R}^{m^{\prime}\times N}$  with  $m^{\prime}\leq m_{\mathrm{large}}$
In the following, a random network refers to a network whose weights have entries sampled from a uniform distribution, i.e.  $W_{i,j} \sim U(-1,1)$  for every weight  $W$  in the random network.
We will first recall Lemma 2 from Pensia et al. (2020) which shows that a pruned 2-layer random network can approximate a linear function.
Lemma 2 (Approximating a linear function; Theorem 1 of Pensia et al. (2020) restated). Let  $W \in \mathbb{R}^{m' \times m}$ ,  $\| W \|_2 = O(1)$ , then for  $\sigma \in \{\mathrm{ReLU}, \mathcal{I}\}$ , where  $\mathcal{I}$  represents the identity operator, for a random network  $g(x) = W_2 \sigma(W_1 x)$  with  $W_2 \in \mathbb{R}^{m' \times h}$ ,  $W_1 \in \mathbb{R}^{h \times m}$  for hidden dimension
Here the input and output dimension of  $\widetilde{T}_{\mathrm{large}}$  is actually  $m_{\mathrm{large}}$  which is larger than  $m$ ; additional dimensions are padded with zeroes. The norm constraint can be easily extended to an arbitrary constant.
2 We can always pad dimensions if  $w$  is too small.
$h = O(m\log (\frac{mm^{\prime}}{\min\{\epsilon,\delta\}}))$  with probability  $1 - \delta$ , there exists boolean masking matrices  $M_1, M_2$ , such that for any  $x \in \mathbb{R}^w$ ,
$$
\left\| \left(M _ {2} \odot W _ {2}\right) \sigma \left(\left(M _ {1} \odot W _ {1}\right) x\right) - W x \right\| \leq \epsilon \| x \| _ {2},
$$
where  $\odot$  denotes the Hadamard product.
We then derive two approximation results Lemmas 3 and 4 based on Lemma 2.
Lemma 3. Under the setting of Theorem 2, with probability  $1 - 2\delta /3$  , for any  $l\in [L],l^{\prime}\in [4L - 1]$  , let  $\mathcal{T}^{(l)}$  be the  $l$  -th layer of  $\mathcal{T}$  , there exists a pruning of the  $(l^{\prime} - 1)$  -th and the  $(l^{\prime})$  -th layer  $\mathcal{T}_{large}^{(l^{\prime} - 1)},\mathcal{T}_{large}^{l^{\prime}}$  named  $\tilde{\mathcal{T}}_{large}^{(l^{\prime} - 1)},\tilde{\mathcal{T}}_{large}^{l^{\prime}}$  such that when defined on domain  $\| X\|_{1,2}\leq 2L,X\in \mathbb{R}^{m\times N},$
1.  $\tilde{\mathcal{T}}_{\text{large}}^{(l' - 1)}$  is independent of the last  $m_{\text{large}} - m$  rows of the input.
2.  $\tilde{\mathcal{T}}_{large}^{l^{\prime}}\circ \tilde{\mathcal{T}}_{large}^{(l^{\prime} - 1)}(\bar{X})$  is an  $\left(\frac{C}{1000L^2}\right)^{4L - 3}\epsilon$ -approximation of  $\overline{\mathcal{T}^{(l)}(\mathbf{X})}$  with respect to 1, 2-norm.
Lemma 4. Under the setting of Theorem 2, for any matrix  $W \in \mathbb{R}^{4m \times 4m}$ ,  $\| W \|_2 \leq 1$ , with probability  $1 - \delta / 4$ , for any  $l' \in [4L]$ , there exists a pruning of the  $l$ -th layer  $\mathcal{T}_{large}^{(l')}$ , named  $\tilde{\mathcal{T}}_{large}^{(l')}$  such that when defined on domain  $X \in \mathbb{R}^{m \times N}$ ,
1.  $\tilde{\mathcal{T}}_{\text{large}}^{(l')}$  is independent of the last  $m_{\text{large}} - 4m$  rows of the input.
2.  $a(x) = \tilde{\mathcal{T}}_{large}^{(l')}\left(\bar{X}\right)$  is an  $\left(\frac{C}{1000L^2}\right)^{4L}\epsilon$ -approximation of  $\hat{g}(\mathbf{X}) = \overline{W\mathbf{X}}$  with respect to 1, 2- norm.
The proof of Lemmas 3 and 4 is deferred to Appendix C.5.1 We can now prove the theorem.
We will first show with induction that if we 1) prune the  $(2l - 1)$ -th and  $2l$ -th layers of  $\mathcal{T}_{\mathrm{large}}$  to approximate  $\mathcal{T}^{(l)}$  for each  $l \in [L]$ , and 2) prune the  $2L + 1$  to  $4L$ -th layers of  $\mathcal{T}_{\mathrm{large}}$  to approximate identity, then the pruned large transformer will be an  $\epsilon$ -approximation of  $\mathcal{T}$  for any input  $\|X\|_{1,2} \leq 1$ . We will perform induction on  $l$ : Let  $\mathcal{T}^{(1:l)}$  define the composition of layer 1 to  $l$ , i.e.  $\mathcal{T}^{(1:l)}(\mathbf{X}) := \mathcal{T}^{(l)} \circ \mathcal{T}^{(l-1)} \circ \dots \circ \mathcal{T}^{(1)}(\mathbf{X})$ , and define  $\epsilon_l := \left(\frac{C}{1000L^2}\right)^{4L-3-l} \epsilon$ . Suppose that  $\mathcal{T}_{\mathrm{large}}^{(1:2l)}$  is an  $\epsilon_l$ -approximation of  $\mathcal{T}^{(1:l)}$ . Note that  $\| \mathcal{T}^{(1:l)}(\mathbf{X}) \|_{1,2} \leq (l + 1)$ , since each attention output has a bounded norm of 1 and every weight matrix in projection function  $g$  has spectral norm smaller than 1, hence the norm will at most increment 1 (due to residual connection) after each layer. We have that
$$
\left\| \tilde {\mathcal {T}} _ {\text {l a r g e}} ^ {(1: 2 l)} (\bar {\boldsymbol {X}}) \right\| _ {1, 2} \leq 4 l \leq 4 L.
$$
Then according to Lemma 13,  $\mathcal{T}^{(l + 1)}$  is  $(1 + 200L^2 /C)$ -Lipschitz on the set of intermediate outputs  $\{\left(\tilde{\mathcal{T}}_{\mathrm{large}}^{(1:2l)}(\bar{X})\right)_{1:m}|\| X\|_{1,2}\leq 1\}$ . We also have that  $\mathcal{T}^{(1:l)}(\pmb {X})$  is  $(1 + 200L^{2} / C)^{l}$ -Lipschitz. Now we can apply Lemma 5 to show that  $\mathcal{T}_{\mathrm{large}}^{(1:2l + 2)}$  can  $\epsilon^\prime$ -approximate  $\mathcal{T}^{(1:l + 1)}$  with
$$
\begin{array}{l} \epsilon^ {\prime} = \epsilon_ {l} (1 + 2 0 0 L ^ {2} / C) + \epsilon \left(\frac {C}{1 0 0 0 L ^ {2}}\right) ^ {4 L - 3} (1 + 2 0 0 L ^ {2} / C) ^ {l} + \epsilon_ {l} \left(\frac {C}{1 0 0 0 L ^ {2}}\right) ^ {4 L - 3} \epsilon \\ \leq \left(\frac {C}{1 0 0 0 L ^ {2}}\right) ^ {4 L - 4 - l} \epsilon = \epsilon_ {l + 1}. \\ \end{array}
$$
The induction is then completed and we have the composition of  $\tilde{\mathcal{T}}_{\mathrm{large}}^i$  for  $i\in [2L]$ $\epsilon_L$ -approximates the composition of  $\mathcal{T}$  with  $\epsilon_{L} = \left(\frac{C}{1000L^{2}}\right)^{3L - 3}\epsilon$ . We will then perform another induction showing that the composition of  $\tilde{\mathcal{T}}_{\mathrm{large}}^i$  for  $i\in [2L + l]$ $\epsilon_{l + L}$ -approximates  $\mathcal{T}$  with  $\epsilon_{l + L} = \left(\frac{C}{1000L^2}\right)^{3L - 3 - l}\epsilon$ . Suppose the statement holds for  $L - 1\geq l\geq 0$ .
The induction step is similar, because we have  $\mathcal{T}$  is  $(1 + 200L^2 /C)^L$  Lipschitz, by Lemma 5, it holds that the composition of  $\mathcal{T}_{\mathrm{large}}^i$  for  $i\in [2L + l + 1]\epsilon '$ -approximates  $\mathcal{T}$  with,
$$
\begin{array}{l} \epsilon^ {\prime} = \epsilon_ {l + L} + \epsilon \left(\frac {C}{1 0 0 0 L ^ {2}}\right) ^ {4 L} (1 + 2 0 0 L ^ {2} / C) ^ {L} + \epsilon_ {l + L} \epsilon \left(\frac {C}{1 0 0 0 L ^ {2}}\right) ^ {4 L} \\ \leq \epsilon \left(\frac {C}{1 0 0 0 L ^ {2}}\right) ^ {3 L - 4 - l} \epsilon = \epsilon_ {L + l + 1}. \\ \end{array}
$$
This concludes the induction and proves the first claim of the theorem. For the second claim, notice that through similar induction steps, we can prune arbitrary layer of  $\mathcal{T}_{\text{large}}$  to approximate identity function and obtain the same approximation rate, this concludes the proof for the second claim.
C.5.1 Helper lemmas for Theorem 2
Error Analysis Our first lemma shows that the composition of  $\epsilon$ -approximation can approximate the composition of the original function.
1.  $\tilde{\mathcal{T}}_{\text{large}}^{(l')}$  is independent of the last  $m_{\text{large}} - 4m$  rows of the input.
2.  $a(x) = \tilde{\mathcal{T}}_{large}^{(l^{\prime})}\left(\bar{X}\right)$  is an  $\left(\frac{C}{1000L^2}\right)^{4L}\epsilon$ -approximation of  $\hat{g}(\boldsymbol{X}) = \overline{W\boldsymbol{X}}$  with respect to 1, 2- norm.
Proof. One can prune the value matrix on layer  $l'$  to zero and the rest is a direct consequence of Lemmas 2 and 20.
Lemma 5. Given three metric spaces  $A, B, C$  equipped with same metric  $\| \cdot \|$ . Suppose  $f_1: A \to B$ ,  $f_2: B \to C$  are  $\epsilon_1, \epsilon_2$ -approximations of  $g_1, g_2$  with respect to  $\| \cdot \|$ , where  $g_1$  is a Lipschitz function with constant  $\lambda_1$  with respect to  $\| \cdot \|$  and  $\| g_2(x) \| \leq \lambda_2 x$ , then it holds that,  $f_1 \circ f_2$  is an  $\epsilon'$ -approximation of  $g_1 \circ g_2$ , with  $\epsilon' = (\lambda_2 + \epsilon_1)(\lambda_1 + \epsilon_2) - \lambda_1 \lambda_2$
Proof. For any  $x \in \mathbb{R}^{d_1}$ , it holds that,
$$
\left\| f _ {1} (x) - g _ {1} (x) \right\| \leq \epsilon_ {1} \| x \|.
$$
This then suggests that,
$$
\begin{array}{l} \left\| f _ {2} \left(f _ {1} (x)\right) - g _ {2} \left(g _ {1} (x)\right) \right\| \\ \leq \left\| f _ {2} \left(f _ {1} (x)\right) - g _ {2} \left(f _ {1} (x)\right) \right\| + \left\| g _ {2} \left(f _ {1} (x)\right) - g _ {2} \left(g _ {1} (x)\right) \right\| \\ \leq \epsilon_ {2} \| f _ {1} (x) \| + \lambda_ {2} \| f _ {1} (x) - g _ {1} (x) \| \\ \leq \epsilon_ {2} \| g _ {1} (x) \| + (\lambda_ {2} + \epsilon_ {2}) \| f _ {1} (x) - g _ {1} (x) \| \\ \leq \left(\epsilon_ {2} \lambda_ {1} + \epsilon_ {1} \lambda_ {2} + \epsilon_ {1} \epsilon_ {2}\right) \| x \| \\ \end{array}
$$
Approximating ReLU MLP We will first show an extension of Lemma 2, illustrating that a pruned wide 4-layer ReLU MLP can approximate any 2-layer ReLU MLP.
Lemma 6. Consider any 2-layer ReLU MLP  $g: \mathbb{R}^{4m} \to \mathbb{R}^{4m}$  parameterized by  $W_{1} \in \mathbb{R}^{4m \times w}$ ,  $W_{2} \in \mathbb{R}^{w \times 4m}$ ,  $\|W_{1}\|_{2}, \|W_{2}\|_{2} \leq 2\sqrt{2}$ , for any  $\delta, \epsilon \in (0,1)$ , consider a random 4-layer ReLU MLP  $f$  with input and output dimension  $4m$  and width  $w' = O(w\log(\frac{wm}{\min\{\epsilon,\delta\}}))$  parameterized by  $W_{\text{large},i}$ , with probability  $1 - \delta$  over the randomness of weight of  $f$ , there exists a nonstructural pruning of  $f$  named  $\tilde{f}$ , such that  $\tilde{f}$  is an  $\epsilon$ -approximation of  $f$  with respect to 2-norm.
Proof. Choose  $\epsilon_0 = \epsilon /8$ . We only need to show there exists boolean matrices  $M_{1},M_{2},M_{3},M_{4}$  such that,
$$
\begin{array}{l} \left\| \left(M _ {4} \odot W _ {\text {l a r g e}, 4} \operatorname {R e L U} \left(\left(M _ {3} \odot W _ {\text {l a r g e}, 3}\right) \operatorname {R e L U} \left(\left(M _ {2} \odot W _ {\text {l a r g e}, 2}\right) \operatorname {R e L U} \left(\left(M _ {1} \odot W _ {\text {l a r g e}, 1}\right) x\right)\right)\right)\right) \right. \\ - \left. W _ {2} \operatorname {R e L U} \left(W _ {1} X\right) \right\rVert_ {2} \leq \epsilon . \\ \end{array}
$$
By Lemma 2, there exists boolean matrices  $M_1 \in \mathbb{R}^{w' \times 4m}$  and  $M_2' \in \mathbb{R}^{w \times w'}$ , such that for any  $x \in \mathbb{R}^{4m}$ ,
$$
\| \left(\left[ \begin{array}{c} M _ {2} ^ {\prime} \\ 0 ^ {(w ^ {\prime} - w) \times w ^ {\prime}} \end{array} \right] \odot W _ {\text {l a r g e}, 2}\right) \operatorname {R e L U} \big ((M _ {1} \odot W _ {\text {l a r g e}, 1}) x \big) - \left[ \begin{array}{c} W _ {1} x \\ 0 ^ {w ^ {\prime} - w} \end{array} \right] \| _ {2} \leq \epsilon_ {0} \| x \| _ {2}.
$$
Hence we can choose  $M_2 = \begin{bmatrix} M_2' \\ 0^{(w' - w) \times w'} \end{bmatrix}$  and have  $f_1(x) = \mathrm{ReLU}\big((M_2 \odot W_{\mathrm{large},2}) \mathrm{ReLU}\big((M_1 \odot W_{,1})x\big)\big)$  is  $\epsilon_0$ -approximation of  $g_1(x) = \begin{bmatrix} \mathrm{ReLU}(W_1x) \\ 0^{w' - w} \end{bmatrix}$ .
Again by Lemma 2, there exists boolean matrices  $M_3' \in \mathbb{R}^{w' \times w}$  and  $M_4 \in \mathbb{R}^{4m \times w'}$ , such that for any  $y \in \mathbb{R}^w$ ,
$$
\left\| \left(M _ {4} \odot W _ {\text {l a r g e}, 4}\right) \operatorname {R e L U} \left(\left[ M _ {3} ^ {\prime}, 0 ^ {w ^ {\prime} \times \left(w ^ {\prime} - w\right)} \right] \left[ \begin{array}{c} y \\ 0 ^ {w ^ {\prime} - w} \end{array} \right]\right) \leq \epsilon_ {0} \| y \| _ {2} \right.
$$
Hence we can choose  $M_3 = \left[M_3', 0^{w' \times (w' - w)}\right]$ , and have  $f_2(x) = \operatorname{ReLU}\big((M_4 \odot W_{\text{large},4}) \operatorname{ReLU}\big((M_3 \odot W_{\text{large},3})x\big)\big)$  is  $\epsilon_0$ -approximation of  $g_2(x) = W_2x$ .
It is also easy to check  $g_{1}$  and  $g_{2}$  are both  $2\sqrt{2}$ -lipschitz and  $g_{1}(0) = 0$ . By Lemma 5, we conclude that  $\tilde{f} = f_{1} \odot f_{2}$  is  $\epsilon'$ -approximation of  $g = g_{1} \odot g_{2}$ , with  $\epsilon' = 4\sqrt{2}\epsilon_{0} + \epsilon_{0}^{2} \leq \epsilon$ .
This lemma then yields the following corollaries.
Corollary 1. Under the setting of Theorem 2, with probability  $1 - \delta /4$ , for any  $l\in [L],l^{\prime}\in [4L]$  there exists a pruning of the projection function  $\mathsf{g}_{\mathrm{large}}^{(l^{\prime})}$ , named  $\mathbf{g}_{\mathrm{large}}^{(\tilde{l} ')}$ , such that
1.  $\mathrm{g}_{\mathrm{large}}^{(\tilde{\iota})}$  is independent of the last  $m_{\mathrm{large}} - m$  dimension of the input.
2.  $a(x) = \mathrm{g}_{\mathrm{large}}^{(\tilde{l} ')}\left(\left[ \begin{array}{c}x\\ 0^{m_{\mathrm{large}} - m} \end{array} \right]\right)$  is an  $\left(\frac{C}{1000L^2}\right)^{4L}\epsilon$  approximation of  $\hat{g} (x) = \left[\begin{array}{c}\mathbf{g}^{(l)}(x)\\ 0^{m_{\mathrm{large}} - m} \end{array} \right]$  with respect to 2-norm.
Proof. One can construct such pruning by pruning the last  $m_{\mathrm{large}} - m$  rows of the weight of the last layer and the last  $m_{\mathrm{large}} - m$  columns of the weight of the first layer of  $\mathsf{g}_{\mathrm{large}}^{(l')}$  to zero and then apply Lemma 6.
Approximating Attention Patterns We will now show that the attention pattern can be approximated by pruning random Transformer layers.
Lemma 7. For any  $\delta, \epsilon \in (0,1)$ , for any  $W \in \mathbb{R}^m$ ,  $\|W\|_2 \leq 1$ , for two random matrix  $W_1, W_2 \in \mathbb{R}^{m' \times m}$  where  $m' = O(m \log \left( \frac{m}{\min\{\epsilon, \delta\}} \right))$ , suppose  $\mathbf{X} \in \mathbb{R}^{m \times N}$ , then there exists nonstructural pruning of  $W_1, W_2$ , named  $\tilde{W}_1, \tilde{W}_2$ , such that
$$
\left\| \boldsymbol {X} ^ {\top} \tilde {\boldsymbol {W}} _ {1} ^ {\top} \tilde {\boldsymbol {W}} _ {2} \boldsymbol {X} - \boldsymbol {X} ^ {\top} W \boldsymbol {X} \right\| _ {\infty} \leq \epsilon \| \boldsymbol {X} \| _ {1, 2} ^ {2}
$$
Here we adopt  $\| \cdot \|_{\infty}$  in vector sense, meaning the entry with largest absolute value.
Proof. Suppose without loss of generality,  $\| \mathbf{X} \|_{:,i} \leq 1$ . According to Lemma 2, there exists nonstructural pruning of  $W_1, W_2$ , named  $\tilde{W}_1, \tilde{W}_2$ , such that for any  $x \in \mathbb{R}^m$ ,  $\| x \|_2 \leq 1$
$$
\| \tilde {W} _ {1} ^ {\top} \tilde {W} _ {2} x - W x \| _ {2} \leq \epsilon .
$$
$$
\| y ^ {\top} \left(\tilde {W} _ {1} ^ {\top} \tilde {W} _ {2} x - W x\right) \| _ {2} \leq \epsilon \| y \| _ {2} \leq \epsilon .
$$
The next lemma shows how error propagates through the softmax operators.
Lemma 8. For any dimension  $d$ , suppose  $x, y \in \mathbb{R}^d$  satisfies  $\| x - y \|_{\infty} \leq \epsilon$ , then it holds that,
$$
\sum_ {i = 1} ^ {d} \left| \frac {\exp (x _ {i})}{\sum_ {i = 1} ^ {n} \exp (x _ {i})} - \frac {\exp (y _ {i})}{\sum_ {i = 1} ^ {n} \exp (y _ {i})} \right| \leq \exp (2 \epsilon) - 1.
$$
Proof. One can observe that,
$$
\exp (- \epsilon) \exp (x _ {i}) \leq \exp (y _ {i}) \leq \exp (\epsilon) \exp (x _ {i})
$$
This then suggests,
$$
\frac {\exp (x _ {i})}{\sum_ {i = 1} ^ {n} \exp (x _ {i})} \exp (- 2 \epsilon) \leq \frac {\exp (y _ {i})}{\sum_ {i = 1} ^ {n} \exp (y _ {i})} \leq \exp (2 \epsilon) \frac {\exp (x _ {i})}{\sum_ {i = 1} ^ {n} \exp (x _ {i})}.
$$
$$
\sum_ {i = 1} ^ {d} \left| \frac {\exp (x _ {i})}{\sum_ {i = 1} ^ {n} \exp (x _ {i})} - \frac {\exp (y _ {i})}{\sum_ {i = 1} ^ {n} \exp (y _ {i})} \right| \leq \max \{\exp (2 \epsilon) - 1, 1 - \exp (- 2 \epsilon) \} = \exp (2 \epsilon) - 1.
$$
Approximating Attention Module We will need the following lemma showing there exists a pruning of the value matrix in  $\mathcal{T}_{\mathrm{large}}$  such that it has eigenvalues with magnitude  $\Theta(1)$ .
Lemma 9. For a matrix  $W \in \mathbb{R}^{m_{\text{large}} \times m_{\text{large}}}$ , with probability at least  $1 - \frac{\delta}{10L}$ , there exists a pruning of  $W$ , named  $W'$ , such that all the nonzero entries is contained in a  $d \times d$  submatrix of  $W'$  that satisfies that (1) all its eigenvalues are within  $(\frac{1}{2}, 1)$ , (2) the index of row specifying the submatrix and the index of column specifying the submatrix are disjoint.
Proof. As  $w_{\mathrm{large}} = \Omega(m \log(\frac{dL}{\delta}))$ , hence we can split  $W_{1: \lceil m_{\mathrm{large}} / 2 \rceil, \lceil m_{\mathrm{large}} / 2 \rceil + 1: m_{\mathrm{large}}}$  into  $(m \times (m \times m)$  blocks, each with width at least  $O(\log(\frac{m}{\delta}))^{21}$ . Within each block, with probability  $1 - \frac{\delta}{10Lm_{\mathrm{large}}}$ , there exists at least one entry that has value at least  $\frac{1}{2}$ . We can then choose  $d$  disjoint entries in  $W$  that are all at least  $\frac{1}{2}$ , indexed with  $\{(a_i, b_i)\}_{i \in [d]}$  where  $a_i < a_j$  and  $b_i < b_j$  for  $i < j$ . We can then prune all other entries to zero. Consider the submatrix defined by entries  $(a, b)$  for  $a \in \{a_i\}_{i \in [d]}$  and  $b \in \{b_i\}_{i \in [d]}$ . Then, this submatrix will be diagonal and contains eigenvalues within  $(\frac{1}{2}, 1)$ . Further  $\{a_i\}_{i \in [d]}$  and  $\{b_i\}_{i \in [d]}$  must be disjoint because  $a_i \leq \lceil m_{\mathrm{large}} / 2 \rceil < b_i$ . The proof is then completed.
We will also prove that LayerNorm with nonzero normalization constant is Lipschitz.
Lemma 10. For LayerNorm function defined as  $\mathrm{LN}(x) = \frac{\mathcal{P}_{\perp}x}{\max\{\| \mathcal{P}_{\perp}x \|_2, C\}}$ ,  $x \in \mathbb{R}^m$ , for any  $x, y \in \mathbb{R}^m$ , it holds that,
$$
\left\| \mathrm {L N} (x) - \mathrm {L N} (y) \right\| _ {2} \leq 2 \| x - y \| _ {2} / C.
$$
Proof. We will proceed by a case analysis:
1. If  $\| \mathcal{P}_{\perp}x\| _2,\| \mathcal{P}_{\perp}y\| _2\leq C$  , then  $\left\| \mathrm{LN}(x) - \mathrm{LN}(y)\right\| _2 = \frac{\|\mathcal{P}_{\perp}x - \mathcal{P}_{\perp}y\|_2}{C}\leq \frac{1}{C}\| x - y\| _2.$
2. If  $\| \mathcal{P}_{\perp}x\| _2,\| \mathcal{P}_{\perp}y\| _2 > C$  , then  $\left\| \mathrm{LN}(x) - \mathrm{LN}(y)\right\| _2 = \frac{\|\mathcal{P}_{\perp}x - \mathcal{P}_{\perp}y\|_2}{\|\mathcal{P}_{\perp}y\|_2} +\bigl |1 - \frac{\|\mathcal{P}_{\perp}x\|_2}{\|\mathcal{P}_{\perp}y\|_2}\bigr |\leq \frac{2}{C}\| x - y\| _2.$
$^{21}O(\cdot)$  hides absolute constants arising from the change of basis in the logarithm.
3. If  $\| \mathcal{P}_{\perp}x\| _2 < C$  and  $\| \mathcal{P}_{\perp}y\| _2 > C$ , then  $\left\| \mathrm{LN}(x) - \mathrm{LN}(y)\right\| _2 = \frac{\|\mathcal{P}_{\perp}x - \mathcal{P}_{\perp}y\|_2}{\|\mathcal{P}_{\perp}y\|_2} +\big|\frac{\|\mathcal{P}_{\perp}x\|_2}{C} -$ $\frac{\|\mathcal{P}_{\perp}x\|_2}{\|\mathcal{P}_{\perp}y\|_2}\big|\leq \frac{2}{C}\| x - y\| _2.$
The cases exhaust all possibilities, thus the proof is completed.
Finally, we will need a lemma showing how error accumulates when we consider both attention patterns and the value matrices.
Lemma 11. For any dimension  $d$  and positive number  $N$ , for  $P, Q \in \mathbb{R}^{d \times d}$  satisfying that  $\| P \|_2, \| Q \|_2 \leq 1$ , for any  $x \in \mathbb{R}^{d \times N}$ , if matrix  $A \in \mathbb{R}^{N \times N}$ ,  $B \in \mathbb{R}^{d \times N}$  satisfy that,
$$
\left\| A - \sigma \left(x ^ {\top} Q x\right) \right\| _ {1, 1} \leq \epsilon_ {1}.
$$
$$
\| B - P x \| _ {1, 2} \leq \epsilon_ {2}.
$$
$$
\forall i, k \in [ N ] \sum_ {j \in [ N ]} A _ {j, i} = 1, A _ {k, i} \geq 0.
$$
Then it holds that,
$$
\| B A - P x \sigma (x ^ {\top} Q x) \| _ {1, 2} \leq \left(\epsilon_ {1} \| P X \| _ {1, 2} + \epsilon_ {2}\right).
$$
$$
\left\| \mathrm {L N} _ {C} (B A) - \mathrm {L N} _ {C} \left(P x \sigma \left(x ^ {\top} Q x\right)\right) \right\| _ {1, 2} \leq 2 \left(\epsilon_ {1} \| P X \| _ {1, 2} + \epsilon_ {2}\right) / C.
$$
Proof. For any  $i \in N$ , we will have
$$
\begin{array}{l} \left\| (B A) _ {:, i} - \left(P x \sigma \left(x ^ {\top} Q x\right)\right) _ {:, i} \right\| _ {2} \\ = \left\| \sum_ {j \in [ N ]} A _ {j, i} B _ {:, j} - \left(\sigma \left(x ^ {\top} Q x\right)\right) _ {j, i} (P X) _ {:, j} \right\| _ {2} \\ \leq \left\| \sum_ {j \in [ N ]} A _ {j, i} (P X) _ {:, j} - \left(\sigma \left(x ^ {\top} Q x\right)\right) _ {j, i} (P X) _ {:, j} \right\| _ {2} + \left\| \sum_ {j \in [ N ]} A _ {j, i} (P X - B) _ {:, j} \right\| _ {2} \\ \leq \| P X \| _ {1, 2} \sum_ {j \in [ N ]} \left| A _ {j, i} - \left(\sigma \left(x ^ {\top} Q x\right)\right) _ {j, i} + \| P X - B \| _ {1, 2} \right. \\ \leq \| P X \| _ {1, 2} \| A - \sigma (x ^ {\top} Q x) \| _ {1, 1} + \| P X - B \| _ {1, 2} \leq \epsilon_ {1} \| P X \| _ {1, 2} + \epsilon_ {2}. \\ \end{array}
$$
The rest follows from Lemma 10
A LayerNorm of larger dimension can be made to be functionally equivalent to a LayerNorm of a smaller dimension. Precisely:
Lemma 12. Given any dimension  $d < d'$ , it holds that for any  $x \in \mathbb{R}^d$ ,
$$
\operatorname {L N} _ {C} (\left[ \begin{array}{c} \mathcal {P} _ {\perp} x \\ 0 ^ {d ^ {\prime} - d} \end{array} \right]) = \left[ \begin{array}{c} \operatorname {L N} _ {C} (x) \\ 0 \end{array} \right].
$$
Proof. The proof follows directly from definition.
We will now formally define attention module.
Definition 7 (Attention Module). We will define attention module  $a(\boldsymbol{X} \mid W_V, W_K, W_Q)$  as
$$
a (\boldsymbol {X}) = \operatorname {L N} _ {C} \left(W _ {V} \boldsymbol {X} \sigma \left(\boldsymbol {X} ^ {\top} W _ {K} ^ {\top} W _ {Q} \boldsymbol {X}\right)\right).
$$