A Formal Comparison Between Chain of Thought and Latent Thought β part 5/9
Cleaned-text code points [62116, 77818). Bibliography omitted here; source.md includes it.
Set the first layer as πΎ 1 ( 1 ) = [ π πΎ 1 ( f ) π w f Γ 1 π π° L π L Γ 1 ] , π ( 1 ) = [ π ( f ) π L ] , πΎ 2 ( 1 ) = [ πΎ 2 ( f ) 0 π L Γ w f 0 π 1 Γ w f π ] , {\bm{W}}^{(1)}_{1}=\begin{bmatrix}{\bm{0}}&{\bm{W}}^{(f)}_{1}&\mathbf{0}_{\,w_{f}\times 1}\\ {\bm{0}}&{\bm{I}}_{L}&\mathbf{0}_{\,L\times 1}\end{bmatrix},\quad{\bm{b}}^{(1)}=\begin{bmatrix}{\bm{b}}^{(f)}\\ {\bm{0}}_{L}\end{bmatrix},\quad{\bm{W}}^{(1)}_{2}=\begin{bmatrix}{\bm{W}}^{(f)}_{2}&\,{\bm{0}}\\ \mathbf{0}_{\,L\times w_{f}}&\,{\bm{0}}\\ \mathbf{0}_{\,1\times w_{f}}&{\bm{0}}\end{bmatrix}, (26) and define FF 1 β ( π , π , t ) β πΎ 2 ( 1 ) β ReLU β ( πΎ 1 ( 1 ) β ( π , π , t ) + π ( 1 ) ) \mathrm{FF}_{1}({\bm{0}},{\bm{u}},t)\coloneqq{\bm{W}}^{(1)}_{2}\,\mathrm{ReLU}\big({\bm{W}}^{(1)}_{1}({\bm{0}},{\bm{u}},t)+{\bm{b}}^{(1)}\big) . Then, it holds that FF 1 β ( π , π , t ) \displaystyle\mathrm{FF}_{1}({\bm{0}},{\bm{u}},t) = πΎ 2 ( 1 ) β ReLU β ( [ πΎ 1 ( f ) β π + π ( f ) π ] ) \displaystyle={\bm{W}}^{(1)}_{2}\,\mathrm{ReLU}\left(\begin{bmatrix}{\bm{W}}^{(f)}_{1}{\bm{u}}+{\bm{b}}^{(f)}\\ {\bm{u}}\end{bmatrix}\right) (27) = [ πΎ 2 ( f ) β ReLU β ( πΎ 1 ( f ) β π + π ( f ) ) π ] \displaystyle=\begin{bmatrix}{\bm{W}}^{(f)}_{2}\mathrm{ReLU}({\bm{W}}^{(f)}_{1}{\bm{u}}+{\bm{b}}^{(f)})\\ {\bm{0}}\end{bmatrix} (28) = [ FF f β ( π ) π ] . \displaystyle=\begin{bmatrix}\mathrm{FF}_{f}({\bm{u}})\\ {\bm{0}}\end{bmatrix}. (29) Thus we have ( id + FF 1 ) β ( π , π , t ) = ( FF f β ( π ) , π , t ) . (\id+\mathrm{FF}_{1})({\bm{0}},{\bm{u}},t)=\bigl(\mathrm{FF}_{f}({\bm{u}}),\,{\bm{u}},\,t\bigr).
For the second layer, choose Ξ΄ β€ 1 3 \delta\leq\tfrac{1}{3} and M β₯ 1 M\geq 1 and set πΎ 1 ( 2 ) = [ 2 β π° n π n Γ L M β π n 2 β π° n π n Γ L M β π n π° n π n Γ L π n Γ 1 β π° n π n Γ L π n Γ 1 ] , π ( 2 ) = [ β M β π n ( 1 β M ) β π n π n π n ] , πΎ 2 ( 2 ) = [ π° n β π° n β π° n π° n 0 L Γ n π L Γ n π L Γ n π L Γ n 0 1 Γ n π 1 Γ n π 1 Γ n π 1 Γ n ] . {\bm{W}}^{(2)}_{1}=\begin{bmatrix}2{\bm{I}}_{n}&\mathbf{0}_{n\times L}&M{\bm{1}}_{n}\\ 2{\bm{I}}_{n}&\mathbf{0}_{n\times L}&M{\bm{1}}_{n}\\ {\bm{I}}_{n}&\mathbf{0}_{n\times L}&\mathbf{0}_{n\times 1}\\ -{\bm{I}}_{n}&\mathbf{0}_{n\times L}&\mathbf{0}_{n\times 1}\end{bmatrix},\ {\bm{b}}^{(2)}=\begin{bmatrix}-M{\bm{1}}_{n}\\ (1-M){\bm{1}}_{n}\\ {\bm{0}}_{n}\\ {\bm{0}}_{n}\end{bmatrix},\ {\bm{W}}^{(2)}_{2}=\begin{bmatrix}\ {\bm{I}}_{n}&-{\bm{I}}_{n}&-{\bm{I}}_{n}&\ {\bm{I}}_{n}\ \\ \ \mathbf{0}_{\,L\times n}&\mathbf{0}_{\,L\times n}&\mathbf{0}_{\,L\times n}&\mathbf{0}_{\,L\times n}\\ \ \mathbf{0}_{\,1\times n}&\mathbf{0}_{\,1\times n}&\mathbf{0}_{\,1\times n}&\mathbf{0}_{\,1\times n}\end{bmatrix}. (30) and define FF 2 β ( π ) β πΎ 2 ( 2 ) β ReLU β ( πΎ 1 ( 2 ) β π + π ( 2 ) ) \mathrm{FF}_{2}({\bm{y}})\coloneqq{\bm{W}}^{(2)}_{2}\,\mathrm{ReLU}\big({\bm{W}}^{(2)}_{1}{\bm{y}}+{\bm{b}}^{(2)}\big) . Then it holds that, for π β FF f β ( π ) {\bm{z}}\coloneqq\mathrm{FF}_{f}({\bm{u}}) , FF 2 β ( π , π , t ) \displaystyle\mathrm{FF}_{2}({\bm{z}},{\bm{u}},t) = πΎ 2 ( 2 ) β [ ReLU β‘ ( 2 β π + M β t β π n β M β π n ) ReLU β‘ ( 2 β π + M β t β π n + ( 1 β M ) β π n ) ReLU β‘ ( π ) ReLU β‘ ( β π ) ] \displaystyle={\bm{W}}^{(2)}_{2}\,\begin{bmatrix}\mathrm{ReLU}\bigl(2{\bm{z}}+Mt{\bm{1}}_{n}-M{\bm{1}}_{n}\bigr)\\ \mathrm{ReLU}\bigl(2{\bm{z}}+Mt{\bm{1}}_{n}+(1-M){\bm{1}}_{n}\bigr)\\ \mathrm{ReLU}({\bm{z}})\\ \mathrm{ReLU}(-{\bm{z}})\end{bmatrix} (31) = πΎ 2 ( 2 ) β [ ReLU β‘ ( 2 β π + M β‘ ( t β 1 ) β π n ) ReLU β‘ ( 2 β π + 1 + M β‘ ( t β 1 ) β π n ) π π ] \displaystyle={\bm{W}}^{(2)}_{2}\,\begin{bmatrix}\mathrm{ReLU}\bigl(2{\bm{z}}+M(t-1){\bm{1}}_{n}\bigr)\\ \mathrm{ReLU}\bigl(2{\bm{z}}+1+M(t-1){\bm{1}}_{n}\bigr)\\ {\bm{z}}\\ {\bm{0}}\end{bmatrix} (32) = [ ReLU β‘ ( π β Ξ΄ + M β‘ ( t β 1 ) ) β ReLU β‘ ( π β 1 + M β‘ ( t β 1 ) ) β π π 0 ] , \displaystyle=\begin{bmatrix}\mathrm{ReLU}\bigl({\bm{z}}-\delta+M(t-1)\bigr)-\mathrm{ReLU}\bigl({\bm{z}}-1+M(t-1)\bigr)-{\bm{z}}\\ \mathbf{0}\\ 0\end{bmatrix}, (33) where it satisfies that ReLU β‘ ( π β Ξ΄ + M β‘ ( t β 1 ) ) β ReLU β‘ ( π β Ξ΄ β 1 + M β‘ ( t β 1 ) ) = { π β‘ ( f β‘ ( π ) ) if t = 1 , 0 if t = 0 . \mathrm{ReLU}\bigl({\bm{z}}-\delta+M(t-1)\bigr)-\mathrm{ReLU}\bigl({\bm{z}}-\delta-1+M(t-1)\bigr)\;=\;\begin{cases}\;\bm{e}(f({\bm{x}}))&\text{if}\quad t=1,\\ \;{\bm{0}}&\text{if}\quad t=0.\end{cases} (34)
Therefore, the composition satisfies ( id + FF 2 ) β ( id + FF 1 ) β ( π , π , t ) = ( t β
π β‘ ( f β‘ ( π ) ) , π , t ) . (\id+\mathrm{FF}_{2})\circ(\id+\mathrm{FF}_{1})\bigl({\bm{0}},{\bm{u}},t\bigr)=(t\cdot\bm{e}(f({\bm{x}})),\ {\bm{u}},\ t). β
### B.4 Proof for Theorem 3.5
###### Proof.
Let G n = ( V n , E n ) G_{n}=(V_{n},E_{n}) be a computation graph, where β± = { f 1 , f 2 , β¦ , f | β± | } \mathcal{F}=\{f_{1},f_{2},\dots,f_{|\mathcal{F}|}\} . Each node v β V n v\in V_{n} is labeled by a one-hot vector π β‘ ( v ) β { 0 , 1 } | β± | \bm{e}(v)\in\{0,1\}^{|\mathcal{F}|} indicating the function assigned to v v from the finite set β± \mathcal{F} . Let v 1 , v 2 , β¦ , v | V n | v_{1},v_{2},\dots,v_{|V_{n}|} denote a fixed topological ordering of V n V_{n} , with inputs appearing first and outputs last. For each function f i β β± f_{i}\in\mathcal{F} , let C f i ( n ) β max { | pred ( v ) | : v β V n , π ( v ) = π i } . C_{f_{i}}(n)\coloneqq\max\{\,|\mathrm{pred}(v)|:v\in V_{n},\;\bm{e}(v)={\bm{e}}_{i}\,\}. and define C sum β ( n ) β β f β β± C f β ( n ) , C max β ( n ) β max f β β± β‘ C f β ( n ) . C_{\mathrm{sum}}(n)\coloneqq\sum_{f\in\mathcal{F}}C_{f}(n),\ C_{\mathrm{max}}(n)\coloneqq\max_{f\in\mathcal{F}}C_{f}(n).
Let the precision be s β‘ ( n ) = C β
β log 2 β‘ n β s(n)=C\cdot\lceil\log_{2}n\rceil where C β β C\in\mathbb{N} is a sufficiently large integer such that 2 s β‘ ( n ) β₯ n C 2^{s(n)}\;\geq\;n^{C} exceeds the maximum polynomial step bound under consideration. We denote by pred β‘ ( v i ) β π½ s β‘ ( n ) C max β ( n ) \mathrm{pred}(v_{i})\in\mathbb{F}_{s(n)}^{C_{\max}(n)} the vector of predecessor indices of node v i v_{i} ; that is, if v i v_{i} has d β€ C max β ( n ) d\leq C_{\max}(n) incoming edges from nodes v j 1 , β¦ , v j d v_{j_{1}},\dots,v_{j_{d}} , then pred β‘ ( v i ) = ( j 1 , β¦ , j d , π ) \mathrm{pred}(v_{i})=(j_{1},\dots,j_{d},{\bm{0}}) , where zeros are used for padding so that the length is exactly C max β ( n ) C_{\max}(n) .
Let the vocabulary be π± = Ξ£ {\mathcal{V}}=\Sigma . At decoding step k k , the model has access to the concatenated sequence ( x 1 , x 2 , β¦ , x n , y 1 , y 2 , β¦ , y k ) β Ξ£ n + k , (x_{1},x_{2},\ldots,x_{n},\,y_{1},y_{2},\ldots,y_{k})\in\Sigma^{n+k}, (35) where x = ( x 1 , β¦ , x n ) β Ξ£ n x=(x_{1},\ldots,x_{n})\in\Sigma^{n} denotes the input, and y i y_{i} is the token generated at the i i -th CoT step. For each node v j v_{j} , let v j β ( x ) v_{j}(x) denote its value on input x x . We assume that every intermediate output satisfies y i = v n + i β ( x ) . y_{i}=v_{n+i}(x). Under this assumption, we prove by induction that the model generates the next token correctly, i.e., y k + 1 = v n + k + 1 β ( x ) . y_{k+1}=v_{n+k+1}(x).
##### Embedding
The embedding at position i β [ n + k ] i\in[n+k] , denoted by π i ( 0 ) β π½ s β‘ ( n ) m {\bm{h}}^{(0)}_{i}\in\mathbb{F}_{s(n)}^{m} , where m β | Ξ£ | + | β± | + ( 1 + C max β ( n ) ) β s β ( n ) + | Ξ£ | β C sum β ( n ) m\coloneq|\Sigma|+|\mathcal{F}|+(1+C_{\mathrm{max}}(n))s(n)+|\Sigma|C_{\mathrm{sum}}(n) is defined as π i ( 0 ) = ( π β‘ ( v i β ( x ) ) , π β‘ ( v i + 1 ) , ππ»ππ s β‘ ( n ) β ( i ) , π¬ππ’π§π©π«ππ s β‘ ( n ) β ( v i + 1 ) , 0 | Ξ£ | β C sum β ( n ) ) , {\bm{h}}^{(0)}_{i}=\left(\bm{e}(v_{i}(x)),\,\bm{e}(v_{i+1}),\,\mathsf{sbin}_{s(n)}(i),\,\bm{\mathrm{sbinpred}}_{s(n)}(v_{i+1}),\,{\bm{0}}_{|\Sigma|C_{\mathrm{sum}}(n)}\right), (36) where π : Ξ£ β { 0 , 1 } | Ξ£ | \bm{e}\colon\Sigma\to\{0,1\}^{|\Sigma|} denote the one-hot encoding of the symbol and, π¬ππ’π§π©π«ππ s β‘ ( n ) β ( v ) β π½ s β‘ ( n ) C max β ( n ) β
s β ( n ) \bm{\mathrm{sbinpred}}_{s(n)}(v)\in\mathbb{F}^{C_{\mathrm{max}}(n)\cdot s(n)}_{s(n)} encodes the binary representations of the predecessor indices: π¬ππ’π§π©π«ππ s β‘ ( n ) β ( v i ) β ( ππ»ππ s β‘ ( n ) β ( pred β ( v i ) 0 ) , β¦ , ππ»ππ s β‘ ( n ) β ( pred β ( v i ) C max β ( n ) ) ) . \bm{\mathrm{sbinpred}}_{s(n)}(v_{i})\coloneq\left(\mathsf{sbin}_{s(n)}(\mathrm{pred}(v_{i})_{0}),\,\ldots,\,\mathsf{sbin}_{s(n)}(\mathrm{pred}(v_{i})_{C_{\mathrm{max}}(n)})\right). (37)
This embedding is constructed, for z β Ξ£ z\in\Sigma , as ππ β‘ ( z ) = ( π β‘ ( z ) , 0 ) , ππ β‘ ( i ) = ( π , π β‘ ( v i + 1 ) , ππ»ππ s β‘ ( n ) β ( i ) , π¬ππ’π§π©π«ππ s β‘ ( n ) β ( v i + 1 ) , 0 ) . \mathbf{WE}(z)=\left(\bm{e}(z),\,{\bm{0}}\right),\quad\mathbf{PE}(i)=\left({\bm{0}},\,\bm{e}(v_{i+1}),\,\mathsf{sbin}_{s(n)}(i),\,\bm{\mathrm{sbinpred}}_{s(n)}(v_{i+1}),\,\mathbf{0}\right). (38)
##### Attention layer
The first attention layer consists of C max β‘ ( n ) C_{\mathrm{max}(n)} heads. The h h -th head is configured to attend to the position corresponding to the h h -th predecessor. Specifically, for each position i i and head h β [ C max β‘ ( n ) ] h\in[C_{\mathrm{max}(n)}] , the attention vectors are defined as: π i , h \displaystyle{\bm{q}}_{i,h} = ππ»ππ s β‘ ( n ) β ( pred β ( v i + 1 ) h ) β’ β 1 s β‘ ( n ) , \displaystyle={\mathsf{sbin}_{s(n)}(\mathrm{pred}(v_{i+1})_{h})}^{\frown}{1_{s(n)}}, (39) π i , h \displaystyle{\bm{k}}_{i,h} = 2 s β‘ ( n ) + 1 β
ππ»ππ s β‘ ( n ) β ( i ) β’ β ( β 1 s β‘ ( n ) ) , \displaystyle=2^{s(n)+1}\cdot{\mathsf{sbin}_{s(n)}(i)}^{\frown}{(-1_{s(n)})}, (40) π― i , h \displaystyle\mathbf{v}_{i,h} = π β ( v i β ( x ) ) , \displaystyle=\bm{e}(v_{i}(x)), (41) where vectors of different lengths are zero-padded to match the dimension. By Lemma B.5 , each attention head of the last position i = n + k i=n+k retrieves the predecessorβs value of v n + k v_{n+k} π n + k , h = π β‘ ( v pred β ( v n + k + 1 ) h β ( x ) ) {\bm{a}}_{n+k,h}=\bm{e}\bigl(v_{\mathrm{pred}(v_{n+k+1})_{h}}(x)\bigr) (42) With an appropriate output projection πΆ {\bm{O}} such that πΆ β‘ ( π i , 1 , β¦ , π i , H ) = ( π , π β‘ ( v pred β ( v n + k + 1 ) 0 β ( x ) ) , β¦ , π β‘ ( v pred β ( v n + k + 1 ) C max β‘ ( n ) β ( x ) ) , 0 ) , {\bm{O}}({\bm{a}}_{i,1},\ldots,{\bm{a}}_{i,H})=({\bm{0}},\,\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{0}}(x)),\,\ldots,\,\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{C_{\mathrm{max}(n)}}}(x)),\,{\bm{0}}), (43) the hidden state at position n + k n+k after the attention layer is given by π n + k ( 0.5 ) = ( π β‘ ( v n + k β ( x ) ) , π β‘ ( v n + k + 1 ) , ππ»ππ s β‘ ( n ) β ( n + k ) , π¬ππ’π§π©π«ππ s β‘ ( n ) β ( v n + k + 1 ) CLOSE , \displaystyle{\bm{h}}^{(0.5)}_{n+k}=\Big(\bm{e}(v_{n+k}(x)),\,\bm{e}(v_{n+k+1}),\,\mathsf{sbin}_{s(n)}(n+k),\,\bm{\mathrm{sbinpred}}_{s(n)}(v_{n+k+1}),\, (44) OPEN π β‘ ( v pred β ( v n + k + 1 ) 0 β ( x ) ) , β¦ , π β‘ ( v pred β ( v n + k + 1 ) C max β‘ ( n ) β ( x ) ) β updated , π C sum β ( n ) β | Ξ£ | ) . \displaystyle\underbrace{\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{0}}(x)),\,\ldots,\,\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{C_{\mathrm{max}(n)}}}(x))}_{\text{updated}}\,,{\bm{0}}_{C_{\mathrm{sum}}(n)|\Sigma|}\Big). (45) The second and third attention layers are disabled (i.e., all attention weights are set to zero).
##### Feed-forward layer
By Lemma B.7 , a single feed-forward layer can approximate multiple functions by partitioning the input into blocks. The first feed-forward layer then places the arguments, gathered by attention, into the correct positions. By Lemma B.6 , where the vector π i {\bm{e}}_{i} therein corresponds to π | Ξ£ | {\bm{1}}_{|\Sigma|} here, the hidden state at the last position, denoted by π n + k ( 1 ) {\bm{h}}^{(1)}_{n+k} , becomes ( ( π n + k ( 0.5 ) ) 1 : r , β₯ j = 1 | β± | ( π ( v pred β ( v n + k + 1 ) 1 ( x ) ) β
1 , β¦ , π ( v pred β ( v n + k + 1 ) C j β ( n ) ( x ) ) β
1 ) , \displaystyle\Big(({\bm{h}}^{(0.5)}_{n+k})_{1:r},\big\|_{j=1}^{|\mathcal{F}|}\,\big(\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{1}}(x))\cdot 1,\ldots,\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{C_{j}(n)}}(x))\cdot 1\Big), (46) where r = | Ξ£ | + | β± | + ( 1 + C max ) β ( n ) β s β ( n ) r=|\Sigma|+|\mathcal{F}|+(1+C_{\mathrm{max}})(n)s(n) .
By Assumption 3.4 and Lemmas B.8 and B.7 , there exist feed-forward layers FF 2 , FF 3 : π½ s β‘ ( n ) m β π½ s β‘ ( n ) m \mathrm{FF}_{2},\mathrm{FF}_{3}:\mathbb{F}_{s(n)}^{m}\to\mathbb{F}_{s(n)}^{m} such that, for every input tuple π j β ( x 1 ( j ) , β¦ , x C j β ( n ) ( j ) ) β Ξ£ C j β ( n ) {\bm{x}}_{j}\coloneq(x^{(j)}_{1},\ldots,x^{(j)}_{C_{j}(n)})\in\Sigma^{C_{j}(n)} for j β [ | β± | ] j\in[|\mathcal{F}|] and every π β { 0 , 1 } | β± | {\bm{t}}\in\{0,1\}^{|\mathcal{F}|} , the composition β± β β± β ( id + FF 3 ) β ( id + FF 2 ) \mathcal{FF}\coloneq(\id+\mathrm{FF}_{3})\circ(\id+\mathrm{FF}_{2}) satisfies β± β± ( β , π , β , β₯ j = 1 | β± | ( π ( x 1 ( j ) ) , β¦ , π ( x C j β ( n ) ( j ) ) ) ) = ( β j | β± | π j β
π ( f j ( π j ) ) , β ) , \mathcal{FF}\left(*,\,{\bm{t}},\,*,\,\big\|_{j=1}^{|\mathcal{F}|}\,(\bm{e}(x^{(j)}_{1}),\ldots,\bm{e}(x^{(j)}_{C_{j}(n)}))\right)\;=\;\left(\sum^{|\mathcal{F}|}_{j}{\bm{t}}_{j}\cdot\bm{e}(f_{j}({\bm{x}}_{j})),*\right), (47) zwhere β * denotes an unspecified vector. Since the second and third attention layers are disabled, after the third layer, applying the second and third feed-forward layers FF 2 , FF 3 \mathrm{FF}_{2},\mathrm{FF}_{3} , the hidden state becomes π n + k ( 3 ) \displaystyle{\bm{h}}^{(3)}_{n+k} = β± β β± β ( π n + k ( 1 ) ) \displaystyle=\mathcal{FF}\left({\bm{h}}^{(1)}_{n+k}\right) (48) = β± β± ( β , π ( v n + k + 1 ) , β , β₯ j = 1 | β± | ( π ( v pred β ( v n + k + 1 ) 1 ( x ) ) , β¦ , π ( v pred β ( v n + k + 1 ) C j β ( n ) ( x ) ) ) ) \displaystyle=\mathcal{FF}\left(*,\,\bm{e}(v_{n+k+1}),\,*,\,\bigg\|_{j=1}^{|\mathcal{F}|}\,\big(\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{1}}(x)),\ldots,\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{C_{j}(n)}}(x))\big)\right) (49) = ( β j = 1 | β± | π β ( v n + k + 1 ) j β
π β‘ ( f j β ( π β‘ ( v pred β ( v n + k + 1 ) 1 β ( x ) ) , β¦ , π β‘ ( v pred β ( v n + k + 1 ) C j β ( n ) β ( x ) ) ) ) , β ) \displaystyle=\Biggl(\sum_{j=1}^{|\mathcal{F}|}\bm{e}(v_{n+k+1})_{j}\cdot\bm{e}\Big(f_{j}\big(\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{1}}(x)),\ldots,\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{C_{j}(n)}}(x))\big)\Big),\;*\Biggr) (50) = ( π β‘ ( f l β ( π β‘ ( v pred β ( v n + k + 1 ) 1 β ( x ) ) , β¦ , π β‘ ( v pred β ( v n + k + 1 ) C l β ( n ) β ( x ) ) ) ) , β ) , where π β‘ ( v n + k + 1 ) = π l \displaystyle=\Biggl(\bm{e}\Big(f_{l}\big(\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{1}}(x)),\ldots,\bm{e}(v_{\mathrm{pred}(v_{n+k+1})_{C_{l}(n)}}(x))\big)\Big),\;*\Biggr),\,\text{where}\quad\bm{e}(v_{n+k+1})={\bm{e}}_{l} (51) = ( π β‘ ( v n + k + 1 β ( x ) ) , β ) . \displaystyle=\Big(\bm{e}\big(v_{n+k+1}(x)\big),\;*\Big). (52)
##### Output layer
The final output is given by π n + k = πππ β‘ ( π n + k ( 3 ) ) = [ π° | Ξ£ | π ] β π n + k ( 3 ) = π β‘ ( v n + k + 1 β ( x ) ) . {\bm{h}}_{n+k}=\mathbf{OUT}({\bm{h}}^{(3)}_{n+k})=\begin{bmatrix}{\bm{I}}_{|\Sigma|}&\mathbf{0}\end{bmatrix}{\bm{h}}^{(3)}_{n+k}=\bm{e}\!\left(v_{n+k+1}(x)\right). (53) The decoding function then outputs the symbol corresponding to the maximum score, y n + k + 1 = Dec β‘ ( π n + k ) = arg β‘ max j β [ | Ξ£ | ] β‘ π β‘ ( v n + k + 1 β ( x ) ) = v n + k + 1 β ( x ) . y_{n+k+1}=\mathrm{Dec}({\bm{h}}_{n+k})=\arg\max_{j\in[|\Sigma|]}\bm{e}(v_{n+k+1}(x))=v_{n+k+1}(x). (54) By induction on k k , the model computes the values at all nodes in topological order. The parameter size of the model is determined by the requirements of the feedforward layers, O β‘ ( ff β _ β param β ( G n ) ) . O(\mathrm{ff\_param}(G_{n}))\,. While the dimensions and heads of the attention layers depend on C max β ( n ) C_{\max}(n) , which is precisely what is already required for the feedforward layers to approximate the target functions. β
### B.5 Proof of Theorem 3.6 for Looped Transformer
###### Proof.