A Formal Comparison Between Chain of Thought and Latent Thought β part 4/9
Cleaned-text code points [47035, 62116). Bibliography omitted here; source.md includes it.
Let the Transformer block be defined as the composition: TF dec β ( id + π
π
L ) β ( id + ππ L ) β β― β ( id + π
π
1 ) β ( id + ππ 1 ) , \mathrm{TF}_{\mathrm{dec}}\coloneq(\id+\mathbf{FF}_{L})\circ(\id+\mathbf{SA}_{L})\circ\cdots\circ(\id+\mathbf{FF}_{1})\circ(\id+\mathbf{SA}_{1}), (5) where ππ β \mathbf{SA}_{\ell} and π
π
β \mathbf{FF}_{\ell} denote the causal attention and the feedforward layers at depth β β [ L ] \ell\in[L] , respectively, and id \id denotes the identity function. Given an input sequence x = ( x 1 , β¦ , x n ) β π± n x=(x_{1},\dots,x_{n})\in{\mathcal{V}}^{n} , we define the initial sequence as: f cot 0 β ( x ) β ππ β‘ ( x ) + ππ β‘ ( [ n ] ) , f_{\mathrm{cot}}^{0}(x)\coloneq\mathbf{WE}(x)+\mathbf{PE}([n]), where the input tokens are first embedded via the word embedding function ππ \mathbf{WE} and the positional encoding ππ \mathbf{PE} Then, the continuous thought (Coconut) computes recursively as: f ct k + 1 β ( x ) β f ct k β ( x ) β
( TF dec β ( f cot k β ( x ) + ππ β‘ ( k ) ) ) , f_{\mathrm{ct}}^{k+1}(x)\coloneq f_{\mathrm{ct}}^{k}(x)\cdot(\mathrm{TF}_{\mathrm{dec}}(f_{\mathrm{cot}}^{k}(x)+\mathbf{PE}(k))), (6) where β
\cdot denotes concatenation. The final output of the model after T β‘ ( n ) T(n) steps is defined as the last output length m m tokens of OPEN Dec β‘ ( πππ β‘ ( f ct T β‘ ( n ) β ( x ) ) ) ) , \mathrm{Dec}\,\left(\mathbf{OUT}\,\left(f_{\mathrm{ct}}^{T(n)}(x))\right)\right), where the final output is produced by a linear projection πππ \mathbf{OUT} and Dec β‘ ( β
) \mathrm{Dec}(\cdot) is a decoding function that maps the output logits to a token in π± {\mathcal{V}} : in the deterministic model, Dec β‘ ( z ) β arg β‘ max i β [ | π± | ] β‘ z i \mathrm{Dec}(z)\coloneq\arg\max_{i\in[|{\mathcal{V}}|]}z_{i} ; in the stochastic model, Dec β‘ ( z ) βΌ Multinomial β‘ ( z i / β j z j ) \mathrm{Dec}(z)\sim\mathrm{Multinomial}({z_{i}}/{\sum_{j}z_{j}}) , assuming z i > 0 z_{i}>0 for all i i .
### A.5 Looped Transformer
###### Definition A.4 (Looped TF) .
Let the Transformer block be defined as the composition: TF β ( id + π
π
L ) β ( id + ππ L ) β β― β ( id + π
π
1 ) β ( id + ππ 1 ) , \mathrm{TF}\coloneq(\id+\mathbf{FF}_{L})\circ(\id+\mathbf{SA}_{L})\circ\cdots\circ(\id+\mathbf{FF}_{1})\circ(\id+\mathbf{SA}_{1}), (7) where ππ β \mathbf{SA}_{\ell} and π
π
β \mathbf{FF}_{\ell} denote the (non-causal) self-attention and feedforward layers at depth β β [ L ] \ell\in[L] .
Given an input token sequence x = ( x 1 , β¦ , x n ) β π± n x=(x_{1},\dots,x_{n})\in{\mathcal{V}}^{n} , the initial hidden state is: f loop 0 β ( x ) β ππ β‘ ( x ) . f_{\mathrm{loop}}^{0}(x)\coloneq\mathbf{WE}(x). At each loop iteration k k , the hidden state is updated by: f loop k + 1 β ( x ) β TF β‘ ( f loop k β ( x ) ) . f_{\mathrm{loop}}^{k+1}(x)\coloneq\mathrm{TF}\left(f_{\mathrm{loop}}^{k}(x)\right). (8) The final outputs after T β‘ ( n ) T(n) loop iterations are decoded as Dec β πππ β f loop T β‘ ( n ) β ( x ) , \mathrm{Dec}\circ\mathbf{OUT}\circ f_{\mathrm{loop}}^{T(n)}(x), and the modelβs prediction is defined as the last output length m β€ n m\leq n tokens of this projected sequence.
## Appendix B Deferred Proofs for Section 3
### B.1 Precision Modeling
We focus on signed floating-point numbers, following ( Li et al., 2024 ) , but omit exponents for simplicity.
###### Definition B.1 (Floating-point Representation, cf. ( Li et al., 2024 ) ) .
Consider floating-point numbers with a mantissa part of s s bits and a sign bit of 1, totaling ( s + 1 ) (s+1) bits. We denote the set of such floating-point numbers by π½ s \mathbb{F}_{s} , and define B s β max β‘ π½ s . B_{s}\triangleq\max\mathbb{F}_{s}.
###### Definition B.2 (Correct Rounding, cf. ( Li et al., 2024 ) ) .
For any x β β x\in\mathbb{R} and any closed subset π½ β β \mathbb{F}\subset\mathbb{R} containing 0 0 , we define the correct rounding round β‘ ( x , π½ ) \operatorname{round}(x,\mathbb{F}) as the number in π½ \mathbb{F} closest to x x . In particular, rounding to a floating-point number with mantissa part s s bits is denoted by [ β
] s [\cdot]_{s} . Rounding applied to vectors is to be operated coordinate-wise.
They also define primitive arithmetic under finite precision by applying rounding after each basic operation. In particular, for multi-operand operations, rounding is applied after each binary operation. Finite-precision summation over more than two numbers is thus defined as follows.
###### Definition B.3 (Summation with Iterative Rounding ( Li et al., 2024 ) ) .
For any s , n β β + s,n\in\mathbb{N}^{+} and vector π β β n {\bm{x}}\in\mathbb{R}^{n} , define the summation with iterative rounding to s s -bit precision sum s : β n β β + ( π½ s ) n β π½ s , \mathrm{sum}_{s}:\ \bigcup_{n\in\mathbb{N}^{+}}(\mathbb{F}_{s})^{n}\to\mathbb{F}_{s}, (9) where, for any n β β + n\in\mathbb{N}^{+} and π = ( x 1 , β¦ , x n ) β β n {\bm{x}}=(x_{1},\dots,x_{n})\in\mathbb{R}^{n} , sum s ( x ) β [ [ β― [ [ x 1 + x 2 ] s + x 3 ] s + β― + x n β 1 ] s + x n ] s . \mathrm{sum}_{s}(x)\coloneqq\Bigl[\;\Bigl[\;\cdots\Bigl[\,[x_{1}+x_{2}]_{s}+x_{3}\Bigr]_{s}+\cdots+x_{n-1}\Bigr]_{s}+x_{n}\;\Bigr]_{s}. (10)
Based on this definition, all computations in the Transformer block of Definition A.1 can be represented in finite precision. The inner product and the matrix product are defined as π β€ π β sum s ( π β π ) , ( π¨ π© ) i , j β π¨ i , : β€ π© : , j . {\bm{x}}^{\top}{\bm{y}}\coloneqq\operatorname{sum}_{s}({\bm{x}}\odot{\bm{y}}),\qquad({\bm{A}}{\bm{B}})_{i,j}\coloneqq{\bm{A}}_{i,:}^{\top}{\bm{B}}_{:,j}. (11) Throughout this section, we interpret all operations as finite-precision computations as defined above.
### B.2 Definition of Assumption 3.4
Our definition of polynomially efficient approximation follows that of Feng et al. (2023) , but differs in scope: while their framework targets real-valued functions, ours applies to symbolic functions.
###### Definition B.4 (Polynomially-efficient approximation) .
We say that a function f n : Ξ£ β β‘ ( n ) β Ξ£ f_{n}:\Sigma^{\ell(n)}\to\Sigma admits a polynomially efficient approximation if, for a sufficiently small error tolerance 0 < Ξ΄ β€ 1 3 0<\delta\leq\tfrac{1}{3} , there exists a feedforward network FF : π½ s β‘ ( n ) β β‘ ( n ) β
| Ξ£ | β π½ s β‘ ( n ) | Ξ£ | , s β‘ ( n ) = O β‘ ( log β‘ n ) , \mathrm{FF}:\mathbb{F}_{s(n)}^{\ell(n)\cdot|\Sigma|}\to\mathbb{F}_{s(n)}^{|\Sigma|},\ s(n)=O(\log n), such that the following holds: for every input π = ( x 1 , β¦ , x β β‘ ( n ) ) β Ξ£ β β‘ ( n ) {\bm{x}}=(x_{1},\ldots,x_{\ell(n)})\in\Sigma^{\ell(n)} , FF β ( π β‘ ( x 1 ) , β¦ , π β‘ ( x β β‘ ( n ) ) ) i = { β₯ 1 β Ξ΄ if π β‘ ( f n β ( π ) ) = π i , β€ Ξ΄ else , \mathrm{FF}(\bm{e}(x_{1}),\ldots,\bm{e}(x_{\ell(n)}))_{i}\;=\;\begin{cases}\;\geq 1-\delta&\text{if}\quad\bm{e}(f_{n}({\bm{x}}))={\bm{e}}_{i},\\ \;\leq\delta&\text{else },\end{cases} (12) where π : Ξ£ β { 0 , 1 } | Ξ£ | \bm{e}:\Sigma\to\{0,1\}^{|\Sigma|} denote the one-hot encoding. Moreover, the number of parameters of the feedforward network is bounded by a polynomial in β β‘ ( n ) \ell(n) and 1 / Ξ΄ 1/\delta .
### B.3 Technical lemmas
In this section, we provide the key components for our constructive proofs.
#### B.3.1 Orthogonal Vectors
We follow the notation of ( Li et al., 2024 ) . For any positive integer s β β + s\in\mathbb{N}^{+} and x β { 0 , 1 , β¦ , 2 s β 1 } x\in\{0,1,\dots,2^{s}-1\} , we denote by π»ππ s β ( x ) β { 0 , 1 } s \mathsf{bin}_{s}(x)\in\{0,1\}^{s} the standard binary representation of x x using s s bits, defined such that x = β i = 1 s 2 i β
( π»ππ s β ( x ) ) i . x=\sum_{i=1}^{s}2^{i}\cdot(\mathsf{bin}_{s}(x))_{i}. We further define the signed binary encoding of x x , denoted by ππ»ππ s β ( x ) β { β 1 , 1 } s \mathsf{sbin}_{s}(x)\in\{-1,1\}^{s} , as ππ»ππ s β ( x ) = 2 β
π»ππ s β ( x ) β ( 1 , β¦ , 1 ) . \mathsf{sbin}_{s}(x)=2\cdot\mathsf{bin}_{s}(x)-(1,\ldots,1). Let π , π β β s {\bm{x}},{\bm{y}}\in\mathbb{R}^{s} be two vectors of the same length. We define their interleaving, denoted by π β’ β π β β 2 β s {{\bm{x}}}^{\frown}{{\bm{y}}}\in\mathbb{R}^{2s} , as follows: ( π β’ β π ) 2 β i β 1 = x i , ( π β’ β π ) 2 β i = π i ({{\bm{x}}}^{\frown}{{\bm{y}}})_{2i-1}=x_{i},({{\bm{x}}}^{\frown}{{\bm{y}}})_{2i}={\bm{y}}_{i} for all i β [ s ] . i\in[s]. The orthogonal vectors under finite-precision arithmetic can be:
###### Lemma B.5 ( Li et al., 2024 ) .
For any s β β + s\in\mathbb{N}^{+} , let πͺ i = ππ»ππ s β ( i ) β’ β 1 s {\bm{q}}_{i}={\mathsf{sbin}_{s}(i)}^{\frown}{1_{s}} and π€ i = 2 s + 1 β
( ππ»ππ s β ( i ) β’ β ( β 1 s ) ) {\bm{k}}_{i}=2^{s+1}\cdot({\mathsf{sbin}_{s}(i)}^{\frown}{(-1_{s})}) for all i β [ 2 s β 1 ] i\in[2^{s}-1] , it holds that β¨ πͺ i , π€ j β© s = β B s \left\langle{\bm{q}}_{i},{\bm{k}}_{j}\right\rangle_{s}=-B_{s} if i β j i\neq j and β¨ πͺ i , π€ j β© s = 0 \left\langle{\bm{q}}_{i},{\bm{k}}_{j}\right\rangle_{s}=0 if i = j i=j . Since [ exp β‘ ( β B s ) ] s β€ [ 2 β s β 1 ] s = 0 \bigl[\exp(-B_{s})\bigr]_{s}\leq\bigl[2^{-s-1}]_{s}=0 , it follows that [ exp ( β¨ πͺ i , π€ j β© s ) ] s = π [ i = j ] \left[\exp(\left\langle{\bm{q}}_{i},{\bm{k}}_{j}\right\rangle_{s})\right]_{s}=\mathbf{1}[i=j] for all i , j β [ 2 s β 1 ] i,j\in[2^{s}-1] .
#### B.3.2 Position Selector
###### Lemma B.6 .
For any m β β + m\in\mathbb{N}^{+} and π± β π½ s m {\bm{x}}\in\mathbb{F}_{s}^{m} with x i > 0 x_{i}>0 for all i β [ m ] i\in[m] , there exists a feedforward layer FF : π½ s 2 β m β π½ s 2 β m \mathrm{FF}:\mathbb{F}_{s}^{2m}\to\mathbb{F}_{s}^{2m} , for any i β [ m ] i\in[m] , such that ( id + FF ) β ( ( π , π i ) ) = ( π β π i , π i ) . (\id+\mathrm{FF})(({\bm{x}},{\bm{e}}_{i}))=({\bm{x}}\odot{\bm{e}}_{i},{\bm{e}}_{i})\,. (13)
###### Proof.
Let the input be π = ( π , π i ) β π½ s 2 β m {\bm{z}}=({\bm{x}},{\bm{e}}_{i})\in\mathbb{F}_{s}^{2m} . Set the weight πΎ 1 β π½ s m Γ 2 β m {\bm{W}}_{1}\in\mathbb{F}_{s}^{m\times 2m} and bias π β m β a β t β h β b β b β F s m {\bm{b}}\in\\ mathbb{F}_{s}^{m} by πΎ 1 = [ π° m β B s β π° m ] , π = π , {\bm{W}}_{1}=\bigl[\,{\bm{I}}_{m}\;\;\;-B_{s}{\bm{I}}_{m}\,\bigr],\qquad{\bm{b}}={\bm{0}}, (14) to have πΎ 1 β π + π = π β B s β π i . {\bm{W}}_{1}{\bm{z}}+{\bm{b}}={\bm{x}}-B_{s}{\bm{e}}_{i}. Applying the ReLU activation coordinate-wise gives ReLU β ( π β B s β π i ) j = { 0 , j = i , x j , j β i . \mathrm{ReLU}({\bm{x}}-B_{s}{\bm{e}}_{i})_{j}=\begin{cases}0,&j=i,\\ x_{j},&j\neq i.\end{cases} (15) Hence, π β ReLU β‘ ( πΎ 1 β π + π ) = π β ( π β π i ) . {\bm{h}}\coloneqq\mathrm{ReLU}({\bm{W}}_{1}{\bm{z}}+{\bm{b}})={\bm{x}}\odot({\bm{1}}-{\bm{e}}_{i}). (16)
Next, set the second linear layer πΎ 2 β π½ s 2 β m Γ m {\bm{W}}_{2}\in\mathbb{F}_{s}^{2m\times m} by πΎ 2 = [ β π° m π m Γ m ] . {\bm{W}}_{2}=\begin{bmatrix}-{\bm{I}}_{m}\\ \mathbf{0}_{m\times m}\end{bmatrix}. (17) Thus we have π + πΎ 2 β π = [ π π i ] + [ β π π ] = [ π π i ] + [ β π β ( π β π i ) π ] = [ π β π i π i ] . {\bm{z}}+{\bm{W}}_{2}{\bm{h}}=\begin{bmatrix}{\bm{x}}\\ {\bm{e}}_{i}\end{bmatrix}+\begin{bmatrix}-{\bm{h}}\\ {\bm{0}}\end{bmatrix}=\begin{bmatrix}{\bm{x}}\\ {\bm{e}}_{i}\end{bmatrix}+\begin{bmatrix}-{\bm{x}}\odot({\bm{1}}-{\bm{e}}_{i})\\ {\bm{0}}\end{bmatrix}=\begin{bmatrix}{\bm{x}}\odot{\bm{e}}_{i}\\ {\bm{e}}_{i}\end{bmatrix}. (18) β
#### B.3.3 Feedforward layers
###### Lemma B.7 .
Let N β β + N\in\mathbb{N}^{+} . For each i β [ N ] i\in[N] , let f i : Ξ£ β i β Ξ£ f_{i}:\Sigma^{\ell_{i}}\to\Sigma admit polynomially-efficient approximation by FF i \mathrm{FF}_{i} . Then there exists a feedforward layer FF : π½ s β i = 1 N β i β | Ξ£ | β π½ s N β | Ξ£ | \mathrm{FF}:\ \mathbb{F}_{s}^{\sum_{i=1}^{N}\ell_{i}|\Sigma|}\to\mathbb{F}_{s}^{N|\Sigma|} such that for every input tuple π± i = ( x 1 ( i ) , β¦ , x β i ( i ) ) β Ξ£ β i {\bm{x}}_{i}=(x^{(i)}_{1},\ldots,x^{(i)}_{\ell_{i}})\in\Sigma^{\ell_{i}} , FF ( β₯ i = 1 N ( π ( x 1 ( i ) ) , β¦ , π ( x β i ( i ) ) ) ) = β₯ i = 1 N FF i ( π i ) , \mathrm{FF}\!\left(\big\|_{i=1}^{N}\,(\bm{e}(x^{(i)}_{1}),\ldots,\bm{e}(x^{(i)}_{\ell_{i}}))\right)\;=\;\big\|_{i=1}^{N}\,\mathrm{FF}_{i}({\bm{x}}_{i}), (19) where β₯ \| denotes concatenation.
###### Proof.
For each i β [ N ] i\in[N] , by Definition B.4 , there exist width w i β β w_{i}\in\mathbb{N} and parameters πΎ 1 ( i ) β π½ s w i Γ β i β | Ξ£ | , πΎ 2 ( i ) β π½ s | Ξ£ | Γ w i , π ( i ) β π½ s w i {\bm{W}}^{(i)}_{1}\in\mathbb{F}_{s}^{w_{i}\times\ell_{i}|\Sigma|},\quad{\bm{W}}^{(i)}_{2}\in\mathbb{F}_{s}^{|\Sigma|\times w_{i}},\quad{\bm{b}}^{(i)}\in\mathbb{F}_{s}^{w_{i}} (20) such that FF i β ( π i ) = πΎ 2 ( i ) β ReLU β ( πΎ 1 ( i ) β π β ( π i ) + π ( i ) ) . \mathrm{FF}_{i}({\bm{x}}_{i})={\bm{W}}^{(i)}_{2}\mathrm{ReLU}({\bm{W}}^{(i)}_{1}\,\bm{e}({\bm{x}}_{i})+{\bm{b}}^{(i)}).
Now, define block-diagonal matrices πΎ 1 β β¨ i = 1 N πΎ 1 ( i ) , πΎ 2 β β¨ i = 1 N πΎ 2 ( i ) , π β β¨ i = 1 N π ( i ) . {\bm{W}}_{1}\coloneqq\bigoplus_{i=1}^{N}{\bm{W}}^{(i)}_{1},\qquad{\bm{W}}_{2}\coloneqq\bigoplus_{i=1}^{N}{\bm{W}}^{(i)}_{2},\qquad{\bm{b}}\coloneqq\bigoplus_{i=1}^{N}{\bm{b}}^{(i)}. (21) Then the single feedforward layer FF β‘ ( π ) β πΎ 2 β ReLU β ( πΎ 1 β π + π ) \mathrm{FF}({\bm{x}})\coloneqq{\bm{W}}_{2}\mathrm{ReLU}({\bm{W}}_{1}{\bm{x}}+{\bm{b}}) (22) applies each block independently to its corresponding input, yielding exactly FF ( π ) = β₯ i = 1 N FF i ( π i ) . \mathrm{FF}({\bm{x}})=\big\|_{i=1}^{N}\mathrm{FF}_{i}({\bm{x}}_{i}). β
###### Lemma B.8 .
Let f : Ξ£ β β Ξ£ f:\Sigma^{\ell}\to\Sigma be a function that admits polynomially-efficient approximation ( Definition B.4 ). Then, there exist two feedforward layers FF 1 : π½ s ( 1 + β ) β | Ξ£ | + 1 β π½ s ( 1 + β ) β | Ξ£ | + 1 , FF 2 : π½ s ( 1 + β ) β | Ξ£ | + 1 β π½ s ( 1 + β ) β | Ξ£ | + 1 , \mathrm{FF}_{1}:\mathbb{F}_{s}^{(1+\ell)|\Sigma|+1}\to\mathbb{F}_{s}^{(1+\ell)|\Sigma|+1},\quad\mathrm{FF}_{2}:\mathbb{F}_{s}^{(1+\ell)|\Sigma|+1}\to\mathbb{F}_{s}^{(1+\ell)|\Sigma|+1}, (23) such that, for every π± = ( x 1 , β¦ , x β ) β Ξ£ β {\bm{x}}=(x_{1},\ldots,x_{\ell})\in\Sigma^{\ell} and t β { 0 , 1 } t\in\{0,1\} , ( id + FF 2 ) β ( id + FF 1 ) β ( π , π β‘ ( x 1 ) , β¦ , π β‘ ( x β ) , t ) = ( t β
π β‘ ( f β‘ ( π ) ) , π β‘ ( x 1 ) , β¦ , π β‘ ( x β ) , t ) . (\id+\mathrm{FF}_{2})\circ(\id+\mathrm{FF}_{1})\big({\bm{0}},\ \bm{e}(x_{1}),\ldots,\bm{e}(x_{\ell}),\ t\big)\;=\;(t\cdot\bm{e}(f({\bm{x}})),\ \bm{e}(x_{1}),\ldots,\bm{e}(x_{\ell}),\ t). (24)
###### Proof.
Let n β | Ξ£ | n\coloneqq|\Sigma| and L β β β n L\coloneqq\ell n . Write π = ( π β‘ ( x 1 ) , β¦ , π β‘ ( x β ) ) β { 0 , 1 } L {\bm{u}}=(\bm{e}(x_{1}),\ldots,\bm{e}(x_{\ell}))\in\{0,1\}^{L} . By Definition B.4 , there exist w f β β w_{f}\in\mathbb{N} , matrices πΎ 1 ( f ) β π½ s w f Γ L {\bm{W}}^{(f)}_{1}\in\mathbb{F}_{s}^{w_{f}\times L} , πΎ 2 ( f ) β π½ s n Γ w f {\bm{W}}^{(f)}_{2}\in\mathbb{F}_{s}^{n\times w_{f}} , and bias π ( f ) β π½ s w f {\bm{b}}^{(f)}\in\mathbb{F}_{s}^{w_{f}} such that FF f β ( π ) β πΎ 2 ( f ) β ReLU β ( πΎ 1 ( f ) β π + π ( f ) ) , FF f β ( π ) i = { β₯ 1 β Ξ΄ if β π β ( f β‘ ( π ) ) = π i , β€ Ξ΄ otherwise . \mathrm{FF}_{f}({\bm{u}})\coloneqq{\bm{W}}^{(f)}_{2}\,\mathrm{ReLU}({\bm{W}}^{(f)}_{1}{\bm{u}}+{\bm{b}}^{(f)}),\quad\mathrm{FF}_{f}({\bm{u}})_{i}=\begin{cases}\geq 1-\delta&\text{if }\ \bm{e}(f({\bm{x}}))={\bm{e}}_{i},\\ \leq\delta&\text{otherwise}.\end{cases} (25)