Introduction
Auto-Regressive (AR) models have recently emerged as a promising paradigm for unifying text and image generation ([68 , 39 , 10 ] ), offering a competitive alternative to diffusion models ([56 , 17 ] ). Analogous to text generation, they discretize images into visual tokens and cast image generation as next-token prediction. Recent advances have pushed the performance frontier of them through high-quality data curation ([74 ] ), improved discrete latent representations ([63 ] ), and flexible inference frameworks ([13 ] ). During inference, most AR models adopt Classifier-Free Guidance (CFG), which improves visual-token prediction by extrapolating the conditional logits away from the unconditional logits. Empirically, CFG substantially improves generation quality and roughly doubles inference computation.
Despite the wide adoption of CFG, its mechanism in AR models remains poorly understood. Most existing studies analyze CFG in diffusion models, where the explanations rely heavily on properties of the reverse diffusion process. However, this process has no direct analogue in AR models, making existing understandings
Correspondence to: <fengzhuo.zhang@yale.edu>, <zhuoran.yang@yale.edu> of CFG not directly applicable. This paper takes a first step toward understanding the mechanism underlying CFG for AR models. Specifically, we ask:
Why is classifier-free guidance effective for AR image generation?
Given that AR models succeed in text generation without CFG, does the necessity of CFG in image generation rely on a limitation or failure of AR pretraining?
Is doubled inference computation necessary for the effectiveness of CFG in AR models?
To answer the first question, we first conduct empirical studies to reveal the roles of different components in CFG. Through both qualitative and quantitative analyses, we find that image texture information is primarily captured by the difference between the conditional and unconditional logits, whereas the top-ranked decoded semantics of the conditional logits alone correspond to nearly pure-color images. To understand why this occurs, we compare the conditional and unconditional logits in both logit space and pixel space. The results show that their top-ranked decoded semantics are highly similar. Through causal interventions during image generation, we further show that these shared top-ranked semantics mainly correspond to repeating previous tokens, explaining why decoding from the conditional logits alone tends to produce pure-color images. Overall, our experiments suggest that CFG amplifies the texture information encoded in the logit difference, thereby correcting the repetition bias present in the conditional logits.
To answer the second question, we theoretically study a shallow transformer with a single attention layer to explain why conditional and unconditional logits share repetition as their top-ranked semantics. Through training-dynamics analysis, we prove that this shared repetition semantics is not caused by insufficient or failed pretraining. Instead, it can arise from the sparsity of image textures, namely the prevalence of nearly pure-color blocks in training images. This sparsity makes the conditional and unconditional logits of well-pretrained models provably favor previous-token repetition, while CFG effectively rectifies this bias to generate the desired images.
To answer the third question, we reduce the computational burden of CFG by reusing intermediate states from the conditional-logit computation. Motivated by the shared semantics of conditional and unconditional logits, we propose Attention Weight Reuse (AttnReuse). The algorithm decomposes the attention output of conditional logits into weighted text-token values and weighted image-token values, and directly reuses the weighted image-token values as the attention output for unconditional-logit computation. It reduces about 25% of attention computation with little performance degradation across different models. In addition, the efficiency of AttnReuse generalizes to diffusion models.
Summarizing these results, we identify a clear mechanism underlying the effectiveness of CFG: CFG rectifies the repetition bias in the conditional logits by amplifying texture information in the conditional–unconditional logit difference. This bias arises from the texture sparsity of images, and can be reused to reduce the computation of CFG.
Related Work
Auto-Regressive Image Generation has recently re-emerged as a promising paradigm for unifying text and image generation, alongside diffusion-based models [56 ] and flow-matching methods [17 ] . Early work on autoregressive image generation dates back to PixelCNN [64 ] , followed by a series of improvements in architecture design and training methodology [54 , 59 , 53 , 50 , 9 ] . However, these methods generate images directly in pixel space. With the development of latent representations and visual tokenizers, such as VQ-VAE [65 ] and VQGAN [18 ] , subsequent work moved autoregressive modeling to the latent space [51 , 15 ] (Yu et al. 2022), substantially easing learning and improving generation quality. Building on these advances, recent works since 2024 have further scaled AR models to achieve performance competitive with diffusion models [61 , 63 , 62 ] (Ma et al. 2024). Beyond competitive image-generation performance, AR models also provide an effective framework for unified multimodal generation, including text [10 ] , video [68 ] , and depth [39 ] . See Xiong et al. [75 ] ; Jiang and Huang [31 ] for comprehensive surveys of AR models. Recent efforts extend AR modeling to jointly handle text and vision, such as Janus-Pro [10 ] , which unify understanding and generation within a single transformer. Similarly, Lumina-GPT [39 , 74 ] explores AR modeling for multi-modal signals including depth and geometry, while the Emu3 [68 ] series and its successor Emu3.5 [13 ] scale AR frameworks to support high-quality image and video generation with strong cross-modal alignment. These works highlight the flexibility of AR modeling in handling diverse modalities within a unified token space.
Classifier-Free Guidance is a simple test-time algorithm for diffusion models that substantially improves generation quality (Ho and Salimans, 2022). A large body of work has subsequently sought to further enhance CFG. For example, prior studies improve CFG by designing low-quality score estimates [34 ] , imposing manifold constraints [12 , 6 ] , incorporating frequency-domain information [58 ] , and designing adaptive guidance strategies [49 , 43 , 20 ] . Beyond these algorithmic improvements, another line of work aims to understand why the original CFG is effective. Chidambaram et al. [11 ] ; Fu et al. (2024); Zhao and Schwing [79 ] ; Wu et al. (2024); Ye et al. (2025) study simplified learning settings for diffusion models, deriving theoretical insights into guidance in large pretrained models. In contrast, Bradley and Nakkiran [5 ] ; Xia et al. [72 ] ; Li and Jiao (2025); Jiao et al. (2025) directly assume bounded pretraining error and analyze the sampling process itself. These works interpret CFG through the lens of sampling algorithms and establish convergence guarantees from different perspectives. Most of the above works treat the role of CFG as fixed throughout sampling. By contrast, Gao et al. [21 ] ; Lehmann Pavlovic et al. (2025); Li et al. (2025); Jin et al. [33 ] ; Riojas et al. (2026); Wang et al. [69 ] ; Kynkäänniemi et al. [35 ] examine how the effect of CFG varies across different sampling stages, propose non-stationary views of guidance, and develop adaptive algorithms accordingly. From a different perspective, Wang et al. [67 ] studies CFG through the lens of control theory. However, all of these works focus on understanding CFG in diffusion models. In contrast, our work provides an understanding of CFG in AR models.
Theoretical studies of training dynamics have provided important insights into neural networks for computer vision. Existing works cover a broad range of architectures, including MLPs (Du et al., 2019), CNNs [7 ] , and Vision Transformers [30 ] , as well as different learning regimes, including lazy learning [29 ] and feature learning (Lu et al., 2020). Following the seminal work of Jacot et al. [29 ] , a line of research uses the Neural Tangent Kernel (NTK) to study the optimization and generalization behavior of neural networks. For CNNs, Arora et al. [4 ] develops the convolutional NTK, while Arora et al. [3 ] derives explicit kernel expressions and shows how the kernel spectrum determines the convergence rate. Mei et al. [46 ] further relates the kernel regime to invariance properties of neural networks; see Golikov et al. [23 ] for a survey of NTK analyses. Beyond the kernel regime, Lu et al. (2020) and Xiao et al. [73 ] study mean-field limits of CNNs and establish convergence results. Another line of work builds problem-specific feature models to characterize training dynamics. For example, Allen-Zhu and Li [1 ] shows the importance of multi-view data structures for ensemble learning, and Cao et al. [7 ] derives phase-transition results for benign overfitting. More recently, several works have studied the learning dynamics of transformers. Jelassi et al. [30 ] and Huang et al. [28 ] analyze how transformers learn spatial relationships among visual features. Our work also falls into this category: we study how the attention module contributes to CFG in AR image generation.
Preliminaries
Auto-regressive models provide a promising paradigm for jointly modeling images and text within a unified architecture ([39 , 10 ] ). These AR models represent images as visual tokens in X v i s \mathcal{X}_{\mathrm{vis}} X vis and text as textual tokens in X t x t \mathcal{X}_{\mathrm{txt}} X txt ([68 ] ). Let X = X v i s ∪ X t x t \mathcal{X} = \mathcal{X}_{\mathrm{vis}} \cup\mathcal{X}_{\mathrm{txt}} X = X vis ∪ X txt denote the token vocabulary, Δ ( X ) \Delta(\mathcal{X}) Δ ( X ) the set of distributions over X \mathcal{X} X , and X ∗ \mathcal{X}^{*} X ∗ the set of all finite token sequences over X \mathcal{X} X . A model P θ : X ∗ → Δ ( X ) P_{\theta} : \mathcal{X}^{*} \to\Delta(\mathcal{X}) P θ : X ∗ → Δ ( X ) with parameters θ ∈ Θ \theta\in\Theta θ ∈ Θ maps each token sequence to a distribution over the next token. It is trained by next-token prediction, where the total cross-entropy loss decomposes into a textual loss and a visual loss ([68 , 10 ] ). The textual loss is the same as in standard LLM training. For the visual loss, to enable Text-to-Image (T2I) generation, the model predicts the next visual token x t + 1 ∈ X v i s x_{t+1} \in\mathcal{X}_{\mathrm{vis}} x t + 1 ∈ X vis conditioned on the text prompt z 1 , … , z T t x t ∈ X t x t z_1,\ldots,z_{T_{\mathrm{txt}}} \in\mathcal{X}_{\mathrm{txt}} z 1 , … , z T txt ∈ X txt and the preceding visual tokens x 1 , … , x t ∈ X v i s x_1,\ldots,x_t \in\mathcal{X}_{\mathrm{vis}} x 1 , … , x t ∈ X vis , for 1 ≤ t < T v i s 1 \leq t < T_{\mathrm{vis}} 1 ≤ t < T vis . Formally,
L v i s ( θ ) = E t , x 1 : t + 1 [ − log P θ ( x t + 1 ∣ z 1 , … , z T t x t , x 1 , … , x t ) ] . (1) \mathcal{L}_{\mathrm{vis}}(\theta) = \mathbb{E}_{t,x_{1:t+1}}\left[-\log P_{\theta}(x_{t+1}\mid z_1,\ldots,z_{T_{\mathrm{txt}}},x_1,\ldots,x_t)\right]. \tag*{(1)} L vis ( θ ) = E t , x 1 : t + 1 [ − log P θ ( x t + 1 ∣ z 1 , … , z T txt , x 1 , … , x t ) ] . (1)
where T t x t , T v i s > 0 T_{\mathrm{txt}}, T_{\mathrm{vis}} > 0 T txt , T vis > 0 denote the numbers of textual and visual tokens, x 1 : t ∈ X t x_{1:t} \in\mathcal{X}^{t} x 1 : t ∈ X t denotes the prefix, and the expectation is taken over t t t sampled uniformly from the visual-token positions 1 ≤ t < T v i s 1 \leq t < T_{\mathrm{vis}} 1 ≤ t < T vis , and over the corresponding prefix x 1 : t + 1 x_{1:t+1} x 1 : t + 1 drawn from the training-data distribution.
Classifier-Free Guidance is a decoding algorithm originally designed for diffusion models ((Ho and Salimans, 2022)), which is found to be also effective in the AR models. During the decoding, CFG enhances the logits log P θ \log P_{\theta} log P θ learned in the pretraining by adding the difference between the conditional logit and the unconditional logit. Concretely, CFG samples the visual token at temperature τ ≥ 0 \tau\geq0 τ ≥ 0 as follows
x t + 1 ∼ sm τ − 1 ( logit λ ( ⋅ ∣ z 1 : T t x t , x 1 , … , x t ) ) , logit λ = logit c o n d + λ ( logit c o n d − logit u n c o n d ) . (2) x_{t+1} \sim\operatorname{sm}_{\tau^{-1}}\left(\operatorname{logit}^{\lambda}(\cdot\mid z_{1:T_{\mathrm{txt}}},x_1,\ldots,x_t)\right),\quad\operatorname{logit}^{\lambda}=\operatorname{logit}^{\mathrm{cond}}+\lambda\left(\operatorname{logit}^{\mathrm{cond}}-\operatorname{logit}^{\mathrm{uncond}}\right). \tag*{(2)} x t + 1 ∼ sm τ − 1 ( logit λ ( ⋅ ∣ z 1 : T txt , x 1 , … , x t ) ) , logit λ = logit cond + λ ( logit cond − logit uncond ) . (2)
The conditional logit is the logit learned in the pretraining, i.e., logit c o n d ( ⋅ ∣ z 1 : T t x t , x 1 , … , x t ) = log P θ ( ⋅ ∣ z 1 : T t x t , x 1 , … , x t ) ∈ R ∣ X ∣ \operatorname{logit}^{\mathrm{cond}}(\cdot\mid z_{1:T_{\mathrm{txt}}},x_1,\ldots,x_t)=\log P_{\theta}(\cdot\mid z_{1:T_{\mathrm{txt}}},x_1,\ldots,x_t)\in\mathbb{R}^{|\mathcal{X}|} logit cond ( ⋅ ∣ z 1 : T txt , x 1 , … , x t ) = log P θ ( ⋅ ∣ z 1 : T txt , x 1 , … , x t ) ∈ R ∣ X ∣ . The unconditional logit is the logit with empty or negative prompts, i.e., logit u n c o n d ( ⋅ ∣ z ~ 1 : T t x t , x 1 , … , x t ) = log P θ ( ⋅ ∣ z ~ 1 : T t x t , x 1 , … , x t ) \operatorname{logit}^{\mathrm{uncond}}(\cdot\mid\tilde{z}_{1:T_{\mathrm{txt}}},x_1,\ldots,x_t)=\log P_{\theta}(\cdot\mid\tilde{z}_{1:T_{\mathrm{txt}}},x_1,\ldots,x_t) logit uncond ( ⋅ ∣ z ~ 1 : T txt , x 1 , … , x t ) = log P θ ( ⋅ ∣ z ~ 1 : T txt , x 1 , … , x t ) , where z ~ 1 : T t x t \tilde{z}_{1:T_{\mathrm{txt}}} z ~ 1 : T txt is an empty prompt, i.e., z ~ i = ∅ \tilde{z}_i=\varnothing z ~ i = ∅ , or a negative prompt, e.g., “Generate an image with low quality”. For diffusion models, existing works explain the effectiveness of CFG from a sampling perspective by exploiting the reverse-time dynamics of the diffusion process ([5 ] (Wu et al. 2024)). However, these explanations do not directly apply to AR models, where no analogous reverse-time diffusion equation is available. We refer readers to Appendix § 2 for further related work.
Transformer is the backbone of modern AR sequence modeling ([66 ] ). Its attention modules play a central role in capturing token dependencies by aggregating hidden states through data-dependent weights. Specifically, given the hidden states H = [ h 1 , … , h T ] ⊤ ∈ R T × D H=[h_1,\ldots,h_T]^\top\in\mathbb{R}^{T\times D} H = [ h 1 , … , h T ] ⊤ ∈ R T × D for T T T tokens, the attention module is defined as attn ( H ; W Q , W K , W V ) = sm ( MASK ( H W Q ⊤ W K H ⊤ ) ) H W V ∈ R T × D \operatorname{attn}(H;W_Q,W_K,W_V)=\operatorname{sm}(\operatorname{MASK}(HW_Q^\top W_KH^\top))HW_V\in\mathbb{R}^{T\times D} attn ( H ; W Q , W K , W V ) = sm ( MASK ( H W Q ⊤ W K H ⊤ )) H W V ∈ R T × D , where W Q , W K , W V ∈ R D × D W_Q,W_K,W_V\in\mathbb{R}^{D\times D} W Q , W K , W V ∈ R D × D are the query, key, and value weight matrices, sm ( ⋅ ) \operatorname{sm}(\cdot) sm ( ⋅ ) denotes the row-wise softmax, and MASK ( ⋅ ) \operatorname{MASK}(\cdot) MASK ( ⋅ ) denotes the causal mask operator, i.e., MASK ( M ) t , l = M t , l \operatorname{MASK}(M)_{t,l}=M_{t,l} MASK ( M ) t , l = M t , l if l ≤ t l\leq t l ≤ t and MASK ( M ) t , l = − ∞ \operatorname{MASK}(M)_{t,l}=-\infty MASK ( M ) t , l = − ∞ otherwise. Thus, each token can attend only to itself and previous tokens.
Empirical Understandings of CFG in AR Models
In this section, we empirically investigate why and how CFG contributes to the high-quality image generation in AR models. We conduct experiments on three representative models of different scales: LlamaGen (0.7B) ([61 ] ), Lumina-mGPT 2.0 (7B) ([74 ] ), and Emu3 (8B) ([68 ] ). Experimental details are provided in Appendix § 9 .
Top-ranked Semantics of Components in Classifier-Free Guidance
We first conduct experiments to understand the top-ranked semantics of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond in Eqn. (2) , i.e., the semantics induced by their highest-logit visual tokens. Given a text prompt z 1 : T t x t z_{1:T_{\mathrm{txt}}} z 1 : T txt , we generate images by greedy decoding from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and from logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond , respectively, using temperature τ = 0 \tau= 0 τ = 0 . The former corresponds to CFG with λ = 0 \lambda= 0 λ = 0 , while the latter captures the limiting guidance direction as λ → ∞ \lambda\to\infty λ → ∞ . Since zero-temperature decoding always selects the highest-logit token, these experiments reveal the dominant semantics encoded by each logit. As a baseline, we also generate images using a standard finite guidance scale λ \lambda λ . Experimental details are provided in Appendix § 9 , and representative examples are shown in Figure 1 . The results show that the dominant behavior of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond is to generate images with nearly pure colors. In contrast, compared with images generated from logit λ \operatorname{logit}^{\lambda} logit λ , images generated from logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond exhibit richer color variation, more complex foreground and background structures, and more detailed main objects. In summary, logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond emphasizes visual details and textures, but can also induce excessively complex appearances compared with standard CFG-generated images. To quantify this observation, we measure the texture complexity of an image token sequence x 1 : T v i s x_{1:T_{\mathrm{vis}}} x 1 : T vis as follows.
Figure 1. Generated images from conditional logits logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond , CFG-guided logits logit λ \operatorname{logit}^{\lambda} logit λ , and logit d i f f = logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{diff}} = \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit diff = logit cond − logit uncond , shown from left to right in each grid. All images are generated by greedy decoding (τ = 0 \tau= 0 τ = 0 ). Prompts: Left: A glass bowl filled with oranges on a table. Right: An orange-reddish rose in a vase filled with water on top of a table. Images generated from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond collapse to nearly pure-color outputs, whereas images generated from logit d i f f \operatorname{logit}^{\mathrm{diff}} logit diff exhibit excessively complex textures.
We first decode the visual token sequence x 1 : T v i s x_{1:T_{\mathrm{vis}}} x 1 : T vis into a pixel-space image, denoted by I ∈ { 0 , … , 255 } C × H × W I \in\{0, \ldots, 255\}^{C \times H \times W} I ∈ { 0 , … , 255 } C × H × W , where C = 3 C = 3 C = 3 in our experiments. We then quantify the texture complexity using three metrics: Pixel Entropy Entropy ( I ) \operatorname{Entropy}(I) Entropy ( I ) (Shannon [60 ] ), Total Variation TV ( I ) \operatorname{TV}(I) TV ( I ) (Rudin et al. [57 ] ), and Orientation Entropy OriEntropy ( I ) \operatorname{OriEntropy}(I) OriEntropy ( I ) (Redies et al. [52 ] ). They are defined as follows
Entropy ( I ) = 1 C ∑ c = 1 C H ( p c ) , TV ( I ) = 1 C ∑ c = 1 C E i , j ∥ ∇ i , j I c , i , j ∥ 1 , OriEntropy ( I ) = 1 C ∑ c = 1 C H ( q c ) , \operatorname{Entropy}(I) = \frac{1}{C}\sum_{c=1}^{C} H(p_c), \quad\operatorname{TV}(I) = \frac{1}{C}\sum_{c=1}^{C} \mathbb{E}_{i,j}\lVert\nabla_{i,j}I_{c,i,j}\rVert_1, \quad\operatorname{OriEntropy}(I) = \frac{1}{C}\sum_{c=1}^{C} H(q_c), Entropy ( I ) = C 1 c = 1 ∑ C H ( p c ) , TV ( I ) = C 1 c = 1 ∑ C E i , j ∥ ∇ i , j I c , i , j ∥ 1 , OriEntropy ( I ) = C 1 c = 1 ∑ C H ( q c ) ,
where ∇ i , j I c , i , j = [ I c , i + 1 , j − I c , i , j , I c , i , j + 1 − I c , i , j ] \nabla_{i,j}I_{c,i,j} = [I_{c,i+1,j} - I_{c,i,j}, I_{c,i,j+1} - I_{c,i,j}] ∇ i , j I c , i , j = [ I c , i + 1 , j − I c , i , j , I c , i , j + 1 − I c , i , j ] denotes the spatial gradient of channel c c c at pixel ( i , j ) (i,j) ( i , j ) ; p c ( v ) = ( H W ) − 1 ∑ h = 1 H ∑ w = 1 W 1 [ I c , h , w = v ] p_c(v) = (HW)^{-1}\sum_{h=1}^{H}\sum_{w=1}^{W}\mathbb{1}[I_{c,h,w} = v] p c ( v ) = ( H W ) − 1 ∑ h = 1 H ∑ w = 1 W 1 [ I c , h , w = v ] , for 0 ≤ v ≤ 255 0 \leq v \leq255 0 ≤ v ≤ 255 , is the empirical intensity distribution of channel c c c ; and q c ( θ ) ∝ ∑ i , j ∥ ∇ i , j I c , i , j ∥ 2 ⋅ 1 [ angle ( ∇ i , j I c , i , j ) ∈ θ ] q_c(\theta) \propto\sum_{i,j}\lVert\nabla_{i,j}I_{c,i,j}\rVert_2 \cdot\mathbb{1}[\operatorname{angle}(\nabla_{i,j}I_{c,i,j}) \in\theta] q c ( θ ) ∝ ∑ i , j ∥ ∇ i , j I c , i , j ∥ 2 ⋅ 1 [ angle ( ∇ i , j I c , i , j ) ∈ θ ] is the magnitude-weighted orientation distribution over orientation bins, which captures structural regularity. Pixel entropy has been used to quantify the diversity of intensity distributions (Haralick et al. [25 ] ; Yuan et al. [78 ] ); Total Variation has been used to capture the overall magnitude of local spatial variations ([57 , 8 ] ); and edge-orientation entropy has been used to describe the diversity of edge directions ([52 , 24 , 45 ] ). Figure 2 reports the average values of these metrics over 500 images generated from different logits. The results show that images generated from logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond exhibit the highest texture complexity for most models. In contrast, images generated from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond exhibit the lowest texture complexity, consistent with the qualitative results in Figure 1 . Thus, we reach the following conclusion.
Figure 2. Texture complexity of images generated from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond , logit λ \operatorname{logit}^{\lambda} logit λ , and logit d i f f = logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{diff}} = \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit diff = logit cond − logit uncond across multiple metrics. Pixel Entropy, Total Variation, and Orientation Entropy measure pixel-intensity diversity, local intensity variation, and edge-orientation diversity, respectively. Images generated from logit d i f f \operatorname{logit}^{\mathrm{diff}} logit diff consistently exhibit the highest texture complexity, whereas those generated from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond exhibit the lowest.
Finding 1: The top-ranked semantics of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond correspond to pure-color images, whereas those of logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond emphasize overly complex textures.
The Dominant Role of Unconditional Logits in Conditional Logits
Using the decomposition
logit c o n d = logit u n c o n d + ( logit c o n d − logit u n c o n d ) , \operatorname{logit}^{\mathrm{cond}} = \operatorname{logit}^{\mathrm{uncond}} + \left(\operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}}\right), logit cond = logit uncond + ( logit cond − logit uncond ) ,
Finding 1 suggests that the semantics encoded in logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond can be approximately interpreted as
logit c o n d ≈ logit u n c o n d + Complex Textures Info . (3) \operatorname{logit}^{\mathrm{cond}} \approx\operatorname{logit}^{\mathrm{uncond}} + \text{Complex Textures Info}. \tag*{(3)} logit cond ≈ logit uncond + Complex Textures Info . (3)
However, zero-temperature decoding from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond produces images with nearly pure colors, as shown in Figure 1 . This indicates that the top-ranked semantics of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond are dominated by logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond rather than by the complex texture information. In this section, we verify this interpretation by showing that, when the model is prefilled with images generated under a proper guidance scale λ \lambda λ , logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond are aligned among high-logit entries. In other words, the top-ranked semantics of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond are largely shared with those of logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond , so the unconditional logits explain the dominant semantics in conditional generation. We measure the similarity between logit t c o n d \operatorname{logit}^{\mathrm{cond}}_t logit t cond and logit t u n c o n d \operatorname{logit}^{\mathrm{uncond}}_t logit t uncond for t ∈ [ T v i s ] t \in[T_{\mathrm{vis}}] t ∈ [ T vis ] in logit and pixel spaces. For the logit-space comparison, let
K t c o n d = TopK ( logit t c o n d , k ) , K t u n c o n d = TopK ( logit t u n c o n d , k ) \mathcal{K}^{\mathrm{cond}}_t = \operatorname{TopK}(\operatorname{logit}^{\mathrm{cond}}_t, k), \quad\mathcal{K}^{\mathrm{uncond}}_t = \operatorname{TopK}(\operatorname{logit}^{\mathrm{uncond}}_t, k) K t cond = TopK ( logit t cond , k ) , K t uncond = TopK ( logit t uncond , k )
denote the top-k k k token indices of the conditional and unconditional logits at position t t t , respectively, and define their union as U t = K t c o n d ∪ K t u n c o n d \mathcal{U}_t = \mathcal{K}^{\mathrm{cond}}_t \cup\mathcal{K}^{\mathrm{uncond}}_t U t = K t cond ∪ K t uncond . We measure their normalized ℓ 1 \ell_1 ℓ 1 discrepancy on these high-logit coordinates by
α d i f f ( ( logit t c o n d ) t = 1 T v i s , ( logit t u n c o n d ) t = 1 T v i s ) = 1 T v i s ∑ t = 1 T v i s 1 ∣ U t ∣ ∥ logit t , U t c o n d − logit t , U t u n c o n d ∥ 1 . \alpha^{\mathrm{diff}}\left((\operatorname{logit}^{\mathrm{cond}}_t)_{t=1}^{T_{\mathrm{vis}}},(\operatorname{logit}^{\mathrm{uncond}}_t)_{t=1}^{T_{\mathrm{vis}}}\right)=\frac{1}{T_{\mathrm{vis}}}\sum_{t=1}^{T_{\mathrm{vis}}}\frac{1}{|\mathcal{U}_t|}\left\|\operatorname{logit}^{\mathrm{cond}}_{t,\mathcal{U}_t}-\operatorname{logit}^{\mathrm{uncond}}_{t,\mathcal{U}_t}\right\|_1. α diff ( ( logit t cond ) t = 1 T vis , ( logit t uncond ) t = 1 T vis ) = T vis 1 t = 1 ∑ T vis ∣ U t ∣ 1 logit t , U t cond − logit t , U t uncond 1 .
where logit t , U t \operatorname{logit}_{t,\mathcal{U}_t} logit t , U t denotes the restriction of logit t \operatorname{logit}_t logit t to coordinates in U t \mathcal{U}_t U t . As a scale baseline, for any logit sequence ( logit t ) t = 1 T v i s (\operatorname{logit}_t)_{t=1}^{T_{\mathrm{vis}}} ( logit t ) t = 1 T vis with top-k k k set K t \mathcal{K}_t K t , we define
α ( ( logit t ) t = 1 T v i s ) = 1 k T v i s ∑ t = 1 T v i s ∥ logit t , K t ∥ 1 . \alpha\left((\operatorname{logit}_t)_{t=1}^{T_{\mathrm{vis}}}\right)=\frac{1}{kT_{\mathrm{vis}}}\sum_{t=1}^{T_{\mathrm{vis}}}\left\|\operatorname{logit}_{t,\mathcal{K}_t}\right\|_1. α ( ( logit t ) t = 1 T vis ) = k T vis 1 t = 1 ∑ T vis logit t , K t 1 .
We denote the corresponding values for logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond by α c o n d \alpha^{\mathrm{cond}} α cond and α u n c o n d \alpha^{\mathrm{uncond}} α uncond , respectively.
Second, to measure the similarity between ( logit t c o n d ) t = 1 T v i s (\operatorname{logit}^{\mathrm{cond}}_t)_{t=1}^{T_{\mathrm{vis}}} ( logit t cond ) t = 1 T vis and ( logit t u n c o n d ) t = 1 T v i s (\operatorname{logit}^{\mathrm{uncond}}_t)_{t=1}^{T_{\mathrm{vis}}} ( logit t uncond ) t = 1 T vis in pixel space, we first obtain token sequences ( x t c o n d ) t = 1 T v i s (x^{\mathrm{cond}}_t)_{t=1}^{T_{\mathrm{vis}}} ( x t cond ) t = 1 T vis and ( x t u n c o n d ) t = 1 T v i s (x^{\mathrm{uncond}}_t)_{t=1}^{T_{\mathrm{vis}}} ( x t uncond ) t = 1 T vis by greedy decoding at each position. We then decode these sequences with the VQ decoder into normalized images I c o n d , I u n c o n d ∈ [ 0 , 1 ] C × H × W I^{\mathrm{cond}}, I^{\mathrm{uncond}} \in[0,1]^{C\times H\times W} I cond , I uncond ∈ [ 0 , 1 ] C × H × W , and define their normalized ℓ 2 \ell_2 ℓ 2 discrepancy as
β d i f f ( I c o n d , I u n c o n d ) = 1 C H W ∥ I c o n d − I u n c o n d ∥ 2 , \beta^{\mathrm{diff}}(I^{\mathrm{cond}},I^{\mathrm{uncond}})=\frac{1}{\sqrt{CHW}}\left\|I^{\mathrm{cond}}-I^{\mathrm{uncond}}\right\|_2, β diff ( I cond , I uncond ) = C H W 1 I cond − I uncond 2 ,
where ∥ ⋅ ∥ 2 \|\cdot\|_2 ∥ ⋅ ∥ 2 treats each image as a vector. As scale baselines, we define
β c o n d = 1 C H W ∥ I c o n d ∥ 2 and β u n c o n d = 1 C H W ∥ I u n c o n d ∥ 2 . \beta^{\mathrm{cond}}=\frac{1}{\sqrt{CHW}}\left\|I^{\mathrm{cond}}\right\|_2
\quad\text{and}\quad
\beta^{\mathrm{uncond}}=\frac{1}{\sqrt{CHW}}\left\|I^{\mathrm{uncond}}\right\|_2. β cond = C H W 1 I cond 2 and β uncond = C H W 1 I uncond 2 .
Figure 3 plots the average values of these metrics across all samples for different models. In both logit and pixel spaces, α d i f f \alpha^{\mathrm{diff}} α diff and β d i f f \beta^{\mathrm{diff}} β diff are substantially smaller than the corresponding scale baselines, namely α c o n d \alpha^{\mathrm{cond}} α cond and α u n c o n d \alpha^{\mathrm{uncond}} α uncond in logit space, and β c o n d \beta^{\mathrm{cond}} β cond and β u n c o n d \beta^{\mathrm{uncond}} β uncond in pixel space. This indicates that the difference between logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond is small relative to the magnitude of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond itself. In other words, most high-logit coordinates of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond are largely dominated by their unconditional counterparts in logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond . This is consistent with our previous observation that zero-temperature decoding from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond produces images with nearly pure colors and few texture details.
Finding 2: The high-logit coordinates of the conditional logits are largely driven by the unconditional logits, indicating that texture-related information is weakly represented in the conditional logits.
Conditional and Unconditional Logits Both Tend to Repeat Previous Tokens
Findings 1 and 2 indicate that CFG is crucial for high-quality generation: texture-related information has limited influence on the top-ranked conditional predictions, while the unconditional logits dominate their high-logit coordinates. However, the training objective in Eqn. (1) suggests that the conditional logits should capture text-conditioned image content. This raises a natural question: why does the component shared by the conditional and unconditional logits give rise to pure-color images?
There are two possible explanations for why logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond produce pure-color images under zero-temperature decoding. One is that the model assigns consistently high logits to a small set of special tokens, causing the same token to be selected at nearly all image-token positions. The other is that the model tends to repeat previously generated tokens, which would also yield nearly uniform images. We show that the second explanation is correct via causal intervention: conditioned on a prefix sequence, both logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond favor tokens that repeat the prefix.
To verify the second explanation, we generate images from prescribed visual prefixes. Specifically, we fix a text condition z 1 : T t x t z_{1:T_{\mathrm{txt}}} z 1 : T txt and a visual prefix x ^ 1 : L \hat{x}_{1:L} x ^ 1 : L , where x ^ 1 : L \hat{x}_{1:L} x ^ 1 : L is a repeated sequence of a chosen visual token and L L L is the prefix length. We then continue generation from the conditional logits using greedy decoding:
x t + 1 c o n d = arg max x ∈ X v i s P θ ( x ∣ z 1 : T t x t , x ^ 1 : L , x L + 1 : t c o n d ) , for t = L , … , T v i s − 1. x_{t+1}^{\mathrm{cond}}=\underset{x\in\mathcal{X}_{\mathrm{vis}}}{\operatorname{arg\,max}}\;P_\theta\left(x\mid z_{1:T_{\mathrm{txt}}},\hat{x}_{1:L},x_{L+1:t}^{\mathrm{cond}}\right),\quad\text{for }t=L,\ldots,T_{\mathrm{vis}}-1. x t + 1 cond = x ∈ X vis arg max P θ ( x ∣ z 1 : T txt , x ^ 1 : L , x L + 1 : t cond ) , for t = L , … , T vis − 1.
The unconditional generation is performed analogously, with the text condition replaced by an empty prompt ∅ 1 : T t x t \varnothing_{1:T_{\mathrm{txt}}} ∅ 1 : T txt . This yields two image-token sequences: ( x ^ 1 : L , x L + 1 : T v i s c o n d ) (\hat{x}_{1:L},x_{L+1:T_{\mathrm{vis}}}^{\mathrm{cond}}) ( x ^ 1 : L , x L + 1 : T vis cond ) and ( x ^ 1 : L , x L + 1 : T v i s u n c o n d ) (\hat{x}_{1:L},x_{L+1:T_{\mathrm{vis}}}^{\mathrm{uncond}}) ( x ^ 1 : L , x L + 1 : T vis uncond ) .
To quantify repetition behavior, we measure how often the generated tokens x L + 1 : T v i s x_{L+1:T_{\mathrm{vis}}} x L + 1 : T vis repeat the pre-assigned prefix token. Specifically, let x ^ 1 : L = ( s , … , s ) \hat{x}_{1:L}=(s,\ldots,s) x ^ 1 : L = ( s , … , s ) be a visual prefix consisting of a single token s ∈ X v i s s\in\mathcal{X}_{\mathrm{vis}} s ∈ X vis repeated for the first L L L positions. For each generated position L < t ≤ T v i s L<t\leq T_{\mathrm{vis}} L < t ≤ T vis , we define
r t r e p ( ( x ^ 1 : L , x L + 1 : T v i s ) ) = I { x t = s } . r_t^{\mathrm{rep}}\left((\hat{x}_{1:L},x_{L+1:T_{\mathrm{vis}}})\right)=\mathbb{I}\{x_t=s\}. r t rep ( ( x ^ 1 : L , x L + 1 : T vis ) ) = I { x t = s } .
where I { ⋅ } \mathbb{I}\{\cdot\} I { ⋅ } is the indicator function. The repetition rate of the whole generated sequence is then
r r e p ( ( x ^ 1 : L , x L + 1 : T v i s ) ) = 1 T v i s − L ∑ t = L + 1 T v i s r t r e p ( ( x ^ 1 : L , x L + 1 : T v i s ) ) . r^{\mathrm{rep}}\left((\hat{x}_{1:L},x_{L+1:T_{\mathrm{vis}}})\right)=\frac{1}{T_{\mathrm{vis}}-L}\sum_{t=L+1}^{T_{\mathrm{vis}}}r_t^{\mathrm{rep}}\left((\hat{x}_{1:L},x_{L+1:T_{\mathrm{vis}}})\right). r rep ( ( x ^ 1 : L , x L + 1 : T vis ) ) = T vis − L 1 t = L + 1 ∑ T vis r t rep ( ( x ^ 1 : L , x L + 1 : T vis ) ) .
In our experiments, we set the prefix length L L L to the first 20% of visual-token positions and sample s s s uniformly from the set of common visual tokens. Experimental details are provided in Appendix § 9 .§ 4 . Figure 4 reports the average r t r e p r_t^{\mathrm{rep}} r t rep for Luminа-mGPT across images. The results show that tokens generated from both logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond largely repeat the prescribed token s s s . Specifically, among the first generated 10% of visual tokens, the repetition rate r t r e p r_t^{\mathrm{rep}} r t rep is around 0.8, indicating strong repetition behavior. Results for LlamaGen and Emu3 are deferred to Appendix § 9 .§ 4 and show the same trend. We also report the sequence-average repetition rate r r e p r^{\mathrm{rep}} r rep in Table 1 , which shows that at least 50% of generated tokens repeat the assigned token on average. This empirical evidence supports that both logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond strongly favor tokens that repeat the existing prefix, validating the hypothesis that local repetition is the primary driver of uniform, pure-color images.
Table 1. Average repetition ratio r r e p r^{\mathrm{rep}} r rep : the fraction of generated tokens that match the prescribed prefix token.
Figure 4. Position-wise repetition ratio r t r e p r_t^{\mathrm{rep}} r t rep of Lumina-mGPT, averaged over samples. The ratio measures how often a generated token matches the prescribed prefix token; numbers beside the heatmaps are averages over horizontal bands. Both logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond exhibit strong repetition of the prescribed prefix token across generated visual-token positions.
Finding 3: The top-ranked semantics of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond are dominated by the repetition of previous tokens, causing zero-temperature decoding from these logits to generate pure-color images.
Theoretical Understanding of CFG in Shallow Transformers
Section 4 empirically shows that CFG is important for high-quality generation: texture-related information has limited influence on the top-ranked predictions of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond , while the top-ranked semantics of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond are dominated by token repetition. However, these observations do not explain why the training objective in Eqn. (1) leads to conditional logits with these properties. In this section, we demystify this phenomenon by studying the training dynamics of shallow transformers on simplified data models.
We simplify the data model by partitioning visual tokens into visual feature tokens and visual background tokens: X v i s = X v i s f ∪ X v i s b \mathcal{X}_{\mathrm{vis}} = \mathcal{X}_{\mathrm{vis}}^{f} \cup\mathcal{X}_{\mathrm{vis}}^{b} X vis = X vis f ∪ X vis b .
The feature-token set is X v i s f = { 1 , … , K } \mathcal{X}_{\mathrm{vis}}^{f} = \{1,\ldots,K\} X vis f = { 1 , … , K } , where each k ∈ [ K ] k \in[K] k ∈ [ K ] corresponds to a unique texture and semantic concept. Each image contains a single feature-token type, with token k k k selected with probability p k p_k p k and ∑ k = 1 K p k = 1 \sum_{k=1}^{K} p_k = 1 ∑ k = 1 K p k = 1 . The background-token set is X v i s b = { K + 1 , … , K + J } \mathcal{X}_{\mathrm{vis}}^{b} = \{K+1,\ldots,K+J\} X vis b = { K + 1 , … , K + J } , where each K + j K+j K + j represents one background type. Each image contains a single background-token type, with token K + j K+j K + j selected with probability q j q_j q j and ∑ j = 1 J q j = 1 \sum_{j=1}^{J} q_j = 1 ∑ j = 1 J q j = 1 . Finally, the text-token set X t x t = { K + J + 1 , … , 2 K + J } \mathcal{X}_{\mathrm{txt}} = \{K+J+1,\ldots,2K+J\} X txt = { K + J + 1 , … , 2 K + J } represents the semantics of feature tokens, and we assume without loss of generality that feature token k k k is paired with text token K + J + k K+J+k K + J + k .
An image corresponding to text token K + J + k K+J+k K + J + k and background token K + j K+j K + j , for k ∈ [ K ] k \in[K] k ∈ [ K ] and j ∈ [ J ] j \in[J] j ∈ [ J ] , is represented as a visual-token sequence I k , j = ( x 1 , … , x T v i s ) ∈ X v i s T v i s I_{k,j}=(x_1,\ldots,x_{T_{\mathrm{vis}}}) \in\mathcal{X}_{\mathrm{vis}}^{T_{\mathrm{vis}}} I k , j = ( x 1 , … , x T vis ) ∈ X vis T vis of length T v i s T_{\mathrm{vis}} T vis . In I k , j I_{k,j} I k , j , the tokens in the feature block T k = { τ k , … , τ k + L − 1 } T_k=\{\tau_k,\ldots,\tau_k+L-1\} T k = { τ k , … , τ k + L − 1 } are all equal to the feature token k k k , while all other tokens are equal to the background token K + j K+j K + j . Here, τ k ≥ 3 \tau_k \ge3 τ k ≥ 3 denotes the starting position of the feature block for the feature k k k , and all features share the same feature-block length L L L . See Figure 5 for an example.
Figure 5. Left: Image I k , j I_{k,j} I k , j for k = Orange k=\text{Orange} k = Orange , j = Blue j=\text{Blue} j = Blue with τ k = 8 \tau_k=8 τ k = 8 , L = 10 L=10 L = 10 , and T v i s = 25 T_{\mathrm{vis}}=25 T vis = 25 . Right: The invalid image generated by only a conditional model, which will simply repeat the background.
We assume that the length of text token sequence is 1 1 1 , i.e., T t x t = 1 T_{\mathrm{txt}}=1 T txt = 1 . Then we define the pretraining data distribution P d a t a P_{\mathrm{data}} P data over ( z 1 , x 1 : T v i s ) (z_1,x_{1:T_{\mathrm{vis}}}) ( z 1 , x 1 : T vis ) as follows. A feature class k ∈ [ K ] k \in[K] k ∈ [ K ] and a background class j ∈ [ J ] j \in[J] j ∈ [ J ] are drawn independently according to distributions ( p k ) k = 1 K (p_k)_{k=1}^{K} ( p k ) k = 1 K and ( q j ) j = 1 J (q_j)_{j=1}^{J} ( q j ) j = 1 J , respectively. Given ( k , j ) (k,j) ( k , j ) , we set z 1 = K + J + k ∈ X t x t z_1=K+J+k \in\mathcal{X}_{\mathrm{txt}} z 1 = K + J + k ∈ X txt , and x 1 : T v i s x_{1:T_{\mathrm{vis}}} x 1 : T vis are the tokens of I k , j I_{k,j} I k , j . Further, we assume the feature tokens are sparse in the whole image.
Assumption 5.1 (Texture Sparsity). The feature block satisfies L = Θ ( log T v i s ) L = \Theta(\log T_{vis}) L = Θ ( log T v i s ) as T v i s T_{vis} T v i s increases .
This assumption states that texture occupies only a small portion of the image. This is intuitive, since texture often appears as localized high-frequency patches. To verify this empirically, we extract texture and flat regions from the ImageNet validation set ([14 ] ) using a single-level 2D wavelet decomposition ([44 ] ). The approximation coefficients capture smooth structures, while the horizontal, vertical, and diagonal detail coefficients encode high-frequency texture and edges ([2 ] (Lu et al. 1997)). We aggregate the detail components into a high-frequency response map, compute its magnitude, and apply Otsu thresholding ([48 ] ) to identify texture pixels. The texture-area ratio is the fraction of pixels above the threshold, and the flat-area ratio is its complement. As shown in Figure 6 , non-texture regions occupy most of the image area on average, supporting our assumption.
Figure 6. Visualization of texture regions in natural images. Left: Texture regions are highlighted in white. Right: Texture and non-texture area ratios averaged over the ImageNet validation set. The results show that texture regions occupy only a small fraction of the whole image.
We then introduce the shallow transformer used to learn the image distribution. The token x t x_t x t at position t t t is encoded as h t = [ f x t , e t ] ⊤ ∈ R D h_t = [f_{x_t}, e_t]^{\top} \in\mathbb{R}^{D} h t = [ f x t , e t ] ⊤ ∈ R D , where f x t ∈ R d f_{x_t} \in\mathbb{R}^{d} f x t ∈ R d is the token embedding, e t ∈ R d e e_t \in\mathbb{R}^{d_e} e t ∈ R d e is the positional embedding, and D = d + d e D = d + d_e D = d + d e . The input to the transformer is the concatenation of these embeddings, H = [ h 0 , h 1 , … , h t ] ⊤ ∈ R ( t + 1 ) × D H = [h_0, h_1, \ldots, h_t]^{\top} \in\mathbb{R}^{(t+1)\times D} H = [ h 0 , h 1 , … , h t ] ⊤ ∈ R ( t + 1 ) × D , where h 0 h_0 h 0 denotes the embedding of the text token. For ease of analysis, we adopt the standard orthonormality assumption on embeddings ([1 , 28 , 47 ] ).
Assumption 5.2 (Orthonormality of Embeddings). The token embeddings and positional embeddings are orthonormal, i.e., f i ⊤ f i ′ = I { i = i ′ } f_i^{\top} f_{i'} = \mathbb{I}\{i = i'\} f i ⊤ f i ′ = I { i = i ′ } , and e t ⊤ e t ′ = I { t = t ′ } e_t^{\top} e_{t'} = \mathbb{I}\{t = t'\} e t ⊤ e t ′ = I { t = t ′ } .
We consider a single-layer transformer. Given input H ∈ R ( t + 1 ) × D H \in\mathbb{R}^{(t+1)\times D} H ∈ R ( t + 1 ) × D , the parameter-merged attention operator is defined as attn ( H ; W ~ Q K , W ~ V ) = sm ( MASK ( H W ~ Q K H ⊤ ) ) H W ~ V ⊤ ∈ R ( t + 1 ) × D \operatorname{attn}(H;\widetilde{W}_{QK},\widetilde{W}_{V}) = \operatorname{sm}(\operatorname{MASK}(H\widetilde{W}_{QK}H^{\top}))H\widetilde{W}_{V}^{\top} \in\mathbb{R}^{(t+1)\times D} attn ( H ; W Q K , W V ) = sm ( MASK ( H W Q K H ⊤ )) H W V ⊤ ∈ R ( t + 1 ) × D , where W ~ Q K , W ~ V ∈ R D × D \widetilde{W}_{QK},\widetilde{W}_{V} \in\mathbb{R}^{D\times D} W Q K , W V ∈ R D × D are the merged query-key parameter and value parameter, respectively. They are specified as
W ~ Q K = [ 0 0 W Q K 0 ] , W ~ V = [ W V 0 0 0 ] , \widetilde{W}_{QK} =
\begin{bmatrix}
0 & 0 \\
W_{QK} & 0
\end{bmatrix},
\qquad
\widetilde{W}_{V} =
\begin{bmatrix}
W_{V} & 0 \\
0 & 0
\end{bmatrix}, W Q K = [ 0 W Q K 0 0 ] , W V = [ W V 0 0 0 ] ,
where W Q K ∈ R d e × d W_{QK} \in\mathbb{R}^{d_e \times d} W Q K ∈ R d e × d captures the correlation between token embedding and positions, while W V ∈ R d × d W_V \in\mathbb{R}^{d \times d} W V ∈ R d × d captures the correlation among token embeddings. The attention output is then mapped to logits by the Language-Model (LM) head: logit = attn ( H ; W ~ Q K , W ~ V ) W ~ l m ∈ R ( t + 1 ) × ( K + J ) \operatorname{logit} = \operatorname{attn}(H;\widetilde{W}_{QK},\widetilde{W}_{V})\widetilde{W}_{lm} \in\mathbb{R}^{(t+1)\times(K+J)} logit = attn ( H ; W Q K , W V ) W l m ∈ R ( t + 1 ) × ( K + J ) . Here the parameter of the LM head W ~ l m ∈ R D × ( K + J ) \widetilde{W}_{lm} \in\mathbb{R}^{D\times(K+J)} W l m ∈ R D × ( K + J ) is fixed to W ~ l m = [ W l m , 0 ] ⊤ \widetilde{W}_{lm} = [W_{lm}, 0]^{\top} W l m = [ W l m , 0 ] ⊤ , where W l m = [ f 1 , … , f K , f K + J ] ∈ R d × ( K + J ) W_{lm} = [f_1,\ldots,f_K,f_{K+J}] \in\mathbb{R}^{d\times(K+J)} W l m = [ f 1 , … , f K , f K + J ] ∈ R d × ( K + J ) ties the visual token embeddings to the LM head. Let logit t \operatorname{logit}_t logit t denote the logit of the t t t -th visual token, i.e., the ( t + 1 ) (t+1) ( t + 1 ) -th row of logit. The next-token distribution is P θ ( x t + 1 ∣ z 1 , x 1 , … , x t ) = sm ( logit t ) P_{\theta}(x_{t+1} \mid z_1,x_1,\ldots,x_t) = \operatorname{sm}(\operatorname{logit}_t) P θ ( x t + 1 ∣ z 1 , x 1 , … , x t ) = sm ( logit t ) . We train θ = ( W Q K , W V ) \theta= (W_{QK}, W_V) θ = ( W Q K , W V ) using the cross-entropy loss L v i s ( ⋅ ) \mathcal{L}_{vis}(\cdot) L v i s ( ⋅ ) in Eqn. (1) , under the population distribution P d a t a P_{data} P d a t a over ( z 1 , x 1 : T v i s ) (z_1,x_{1:T_{vis}}) ( z 1 , x 1 : T v i s ) . Following prior theoretical analyses of transformer training dynamics ([47 , 70 ] ), we initialize W Q K W_{QK} W Q K and W V W_V W V at zero and use a two-stage protocol: first updating W V W_V W V with W Q K W_{QK} W Q K fixed, and then updating W Q K W_{QK} W Q K with W V W_V W V fixed. Details are deferred to Appendix § 10 . We denote the resulting pretrained parameter by θ ^ \hat{\theta} θ ^ .
Given the pretrained model θ ^ \hat{\theta} θ ^ , we generate the image-token sequence I ^ k , j λ ( θ ^ ) = ( x ^ 1 , … , x ^ T ) ∈ X v i s T v i s \hat{I}_{k,j}^{\lambda}(\hat{\theta}) = (\hat{x}_1,\ldots,\hat{x}_{T}) \in\mathcal{X}_{\mathrm{vis}}^{T_{\mathrm{vis}}} I ^ k , j λ ( θ ^ ) = ( x ^ 1 , … , x ^ T ) ∈ X vis T vis corresponding to text token K + J + k K+J+k K + J + k and background token K + j K+j K + j , for k ∈ [ K ] k \in[K] k ∈ [ K ] and j ∈ [ J ] j \in[J] j ∈ [ J ] , as follows. We first fix the text token and the first visual token as z 1 = K + J + k z_1 = K+J+k z 1 = K + J + k and x ^ 1 = K + j \hat{x}_1 = K+j x ^ 1 = K + j , respectively. We then generate the remaining visual tokens by greedy decoding: x ^ t + 1 = arg max x ∈ X v i s logit t λ ( x ∣ z 1 , x ^ 1 : t ) \hat{x}_{t+1} = \mathop{\arg\max}_{x\in\mathcal{X}_{\mathrm{vis}}} \operatorname{logit}^{\lambda}_t(x \mid z_1,\hat{x}_{1:t}) x ^ t + 1 = arg max x ∈ X vis logit t λ ( x ∣ z 1 , x ^ 1 : t ) , for t = 1 , … , T v i s − 1 t=1,\ldots,T_{\mathrm{vis}}-1 t = 1 , … , T vis − 1 , where logit t λ \operatorname{logit}^{\lambda}_t logit t λ is induced by θ ^ \hat{\theta} θ ^ through Eqn. (2) . We next show that CFG is essential for shallow transformers to recover the desired image-token sequence, i.e., I ^ k , j λ ( θ ^ ) = I k , j \hat{I}_{k,j}^{\lambda}(\hat{\theta}) = I_{k,j} I ^ k , j λ ( θ ^ ) = I k , j . To highlight the main intuition, we first present an informal version of the result and defer the formal statement to Appendix § 12 . Throughout this section, we write a = poly ( b ) a=\operatorname{poly}(b) a = poly ( b ) to indicate that a a a is asymptotically upper bounded by a polynomial in b b b .
Theorem 5.3 (Informal Statement). Consider the asymptotic regime T v i s → ∞ T_{\mathrm{vis}}\to\infty T vis → ∞ where τ k = τ = poly ( T v i s ) \tau_k=\tau=\operatorname{poly}(T_{\mathrm{vis}}) τ k = τ = poly ( T vis ) for all k ∈ [ K ] k\in[K] k ∈ [ K ] , J = poly ( T v i s ) J=\operatorname{poly}(T_{\mathrm{vis}}) J = poly ( T vis ) , K = Θ ( 1 ) K=\Theta(1) K = Θ ( 1 ) , and p k = Θ ( 1 ) p_k=\Theta(1) p k = Θ ( 1 ) , q j = 1 / J q_j=1/J q j = 1/ J . With Assumptions 5.1 and 5.2 and suitable learning rates, the pretrained model θ ^ \hat{\theta} θ ^ satisfies the following properties.
(Minimal Training loss.) The population loss is small, i.e., L v i s ( θ ^ ) = O ( T v i s − 1 ( log T v i s ) 2 ) \mathcal{L}_{\mathrm{vis}}(\hat{\theta})=O(T_{\mathrm{vis}}^{-1}(\log T_{\mathrm{vis}})^2) L vis ( θ ^ ) = O ( T vis − 1 ( log T vis ) 2 ) .
(Alignment of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond .) When prefilled with any target image I k , j I_{k,j} I k , j , the conditional and unconditional models make identical predictions at every visual position, i.e., arg max x ∈ X v i s logit t , x c o n d = arg max x ∈ X v i s logit t , x u n c o n d \mathop{\arg\max}_{x\in\mathcal{X}_{\mathrm{vis}}}\operatorname{logit}^{\mathrm{cond}}_{t,x}=\mathop{\arg\max}_{x\in\mathcal{X}_{\mathrm{vis}}}\operatorname{logit}^{\mathrm{uncond}}_{t,x} arg max x ∈ X vis logit t , x cond = arg max x ∈ X vis logit t , x uncond , for all t ∈ [ T v i s ] t\in[T_{\mathrm{vis}}] t ∈ [ T vis ] , k ∈ [ K ] k\in[K] k ∈ [ K ] , j ∈ [ J ] j\in[J] j ∈ [ J ] .
(Conditional generation collapses to repeated background tokens.) With guidance scale λ = 0 \lambda=0 λ = 0 (pure conditional generation), the model does not generate a valid image: for every k ∈ [ K ] k\in[K] k ∈ [ K ] and j ∈ [ J ] j\in[J] j ∈ [ J ] , I ^ k , j 0 ( θ ^ ) = ( K + j , … , K + j ) ≠ I k , j \hat{I}_{k,j}^{0}(\hat{\theta})=(K+j,\ldots,K+j)\ne I_{k,j} I ^ k , j 0 ( θ ^ ) = ( K + j , … , K + j ) = I k , j .
(CFG recovers valid images.) There exists a guidance scale λ ∗ = Θ ( 1 ) \lambda^*=\Theta(1) λ ∗ = Θ ( 1 ) such that generation with logits logit λ ∗ \operatorname{logit}^{\lambda^*} logit λ ∗ is exact: I ^ k , j λ ∗ ( θ ^ ) = I k , j \hat{I}_{k,j}^{\lambda^*}(\hat{\theta})=I_{k,j} I ^ k , j λ ∗ ( θ ^ ) = I k , j , for all k ∈ [ K ] k\in[K] k ∈ [ K ] , j ∈ [ J ] j\in[J] j ∈ [ J ] .
The small population loss shows that the transformer is well trained, so the phenomena below are not artifacts of failed optimization. The alignment between logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond theoretically justifies Finding 2: the top-ranked semantics of the conditional and unconditional logits coincide. Consequently, generation with logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond collapses to repeated background tokens, producing a pure-color image, which is consistent with Findings 1 and 3. Finally, CFG with a constant guidance scale λ ∗ \lambda^* λ ∗ extracts the correct signal from the logit difference logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}}-\operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond and recovers the target image. Therefore, all the empirical findings in § 4 provably arise in shallow transformers.
Proof Sketch
The proof is divided into two stages, following the two-step training protocol (see Figure 7 for an overview). We first analyze the learning of W V W_V W V . Since both W V W_V W V and W Q K W_{QK} W Q K are initialized at zero, the attention weights are initially uniform, and the resulting next-token distribution is also uniform. Under this symmetric initialization, the gradient of W V W_V W V is determined by correlations between input embeddings and target embeddings. Consequently, the learned W V ( 1 ) W_V^{(1)} W V ( 1 ) takes the form of a sum of outer products of embeddings, enabling it to map an input embedding to a linear combination of target embeddings. Concretely, this transformation can be written as follows:
Figure 7. Overview of the proof. (1) Training W V W_V W V makes text and background tokens favor background repetition, while feature tokens favor feature repetition. (2) Training W Q K W_{QK} W Q K makes the conditional branch attend to text when predicting the first feature token. Inside the block, both branches attend to earlier feature tokens. (3) CFG uses the logit difference to generate the first feature token. Repetition then completes the feature block; without CFG, generation repeats the background.
W V ( 1 ) f K + j = − q j A K + j f ˉ ⏟ background → average + q j B K + j f K + j ⏟ background → background + q j C K + j ∑ k p k f k ⏟ background → feature W_V^{(1)}f_{K+j}
=
\underbrace{-q_j A_{K+j}\bar{f}}_{\text{background}\to\text{average}}
+
\underbrace{q_j B_{K+j}f_{K+j}}_{\text{background}\to\text{background}}
+
\underbrace{q_j C_{K+j}\sum_k p_k f_k}_{\text{background}\to\text{feature}} W V ( 1 ) f K + j = background → average − q j A K + j f ˉ + background → background q j B K + j f K + j + background → feature q j C K + j k ∑ p k f k
ends_mid=1
W V ( 1 ) f k = − p k A k f ˉ + p k ∑ j q j B k f K + j + p k C k f k W_V^{(1)} f_k = -p_k A_k \bar{f} + p_k \sum_j q_j B_k f_{K+j} + p_k C_k f_k W V ( 1 ) f k = − p k A k f ˉ + p k j ∑ q j B k f K + j + p k C k f k
W V ( 1 ) f K + J + k = − p k A K + J + k f ˉ + p k ∑ j q j B K + J + k f K + j + p k C K + J + k f k W_V^{(1)} f_{K+J+k} = -p_k A_{K+J+k}\bar{f} + p_k \sum_j q_j B_{K+J+k} f_{K+j} + p_k C_{K+J+k}f_k W V ( 1 ) f K + J + k = − p k A K + J + k f ˉ + p k j ∑ q j B K + J + k f K + j + p k C K + J + k f k
where f ˉ = ( K + J ) − 1 ∑ i = 1 K + J f i \bar{f} = (K + J)^{-1} \sum_{i=1}^{K+J} f_i f ˉ = ( K + J ) − 1 ∑ i = 1 K + J f i denotes the average visual-token embedding. For each source token a ∈ { k , K + j , K + J + k } a \in\{k, K+j, K+J+k\} a ∈ { k , K + j , K + J + k } , the coefficients A a , B a , C a A_a, B_a, C_a A a , B a , C a quantify the strengths of the average-embedding, background-token, and feature-token components in W V ( 1 ) f a W_V^{(1)} f_a W V ( 1 ) f a , respectively. For example, W V ( 1 ) f K + j W_V^{(1)} f_{K+j} W V ( 1 ) f K + j decomposes into three types of components: a − q j A K + j -q_j A_{K+j} − q j A K + j contribution along f ˉ \bar{f} f ˉ , a q j B K + j q_j B_{K+j} q j B K + j contribution along the background embedding f K + j f_{K+j} f K + j , and a q j C K + j q_j C_{K+j} q j C K + j contribution along each feature embedding f k f_k f k for k ∈ [ K ] k \in[K] k ∈ [ K ] . The decompositions of W V ( 1 ) f k W_V^{(1)} f_k W V ( 1 ) f k and W V ( 1 ) f K + J + k W_V^{(1)} f_{K+J+k} W V ( 1 ) f K + J + k take analogous forms. In each case, the component strengths are scaled by the probability of the corresponding source token, such as q j q_j q j for background tokens f K + j f_{K+j} f K + j and p k p_k p k for feature tokens f k f_k f k and corresponding text token f K + J + k f_{K+J+k} f K + J + k . Their exact forms are given in Lemma D.2. Proposition D.3 further characterizes their asymptotic orders, and Proposition D.4 combines these orders with texture sparsity to yield
q j B K + J + k > C K + J + k , q j B K + j > C K + j , q j B k < C k , q_j B_{K+J+k} > C_{K+J+k}, \qquad q_j B_{K+j} > C_{K+j}, \qquad q_j B_k < C_k, q j B K + J + k > C K + J + k , q j B K + j > C K + j , q j B k < C k ,
for sufficiently large T v i s T_{\mathrm{vis}} T vis . These inequalities determine the dominant logit components induced by W V ( 1 ) W_V^{(1)} W V ( 1 ) . When comparing logits across visual tokens, the average-embedding component is shared by all visual tokens and therefore cancels out. After removing this common component, W V ( 1 ) f K + J + k W_V^{(1)} f_{K+J+k} W V ( 1 ) f K + J + k and W V ( 1 ) f K + j W_V^{(1)} f_{K+j} W V ( 1 ) f K + j assign larger logits to the background token f K + j f_{K+j} f K + j than to the feature token f k f_k f k , yielding a bias toward background repetition. In contrast, W V ( 1 ) f k W_V^{(1)} f_k W V ( 1 ) f k assigns a larger logit to the feature token k k k , yielding a bias toward feature repetition once the feature has already appeared.
We next analyze the second update, where W V = W V ( 1 ) W_V = W_V^{(1)} W V = W V ( 1 ) is fixed and only W Q K W_{QK} W Q K is updated. Since W Q K W_{QK} W Q K remains zero before this update, the attention weights are still uniform. Under this uniform attention pattern, the model continues to favor background repetition before the feature appears because of W V ( 1 ) W_V^{(1)} W V ( 1 ) , and therefore incurs its largest prediction errors at positions whose next token is the feature token k k k . These errors make the gradient of W Q K W_{QK} W Q K concentrate on the corresponding feature-prediction positions. As a result, the update learns to correlate these positions with tokens that are informative of the feature embedding f k f_k f k . More precisely, the updated W Q K ( 1 ) W_{QK}^{(1)} W Q K ( 1 ) induces the following position–feature correlation:
e t ⊤ W Q K ( 1 ) f a ≈ 1 { t ∈ F k } ⋅ Corr t ( a ) , F k = { τ k − 1 , … , τ k + L − 2 } , e_t^\top W_{QK}^{(1)} f_a \approx\mathbb{1}\{t \in\mathcal{F}_k\} \cdot\operatorname{Corr}_t(a), \qquad\mathcal{F}_k = \{\tau_k - 1, \ldots, \tau_k + L - 2\}, e t ⊤ W Q K ( 1 ) f a ≈ 1 { t ∈ F k } ⋅ Corr t ( a ) , F k = { τ k − 1 , … , τ k + L − 2 } ,
where F k \mathcal{F}_k F k is the set of positions whose next token is feature token k k k , and Corr t ( a ) \operatorname{Corr}_t(a) Corr t ( a ) denotes the corresponding position-token correlation for token a ∈ { K + J + k , K + j , k } a \in\{K+J+k, K+j, k\} a ∈ { K + J + k , K + j , k } . Its closed form is given in Proposition D.9 . Consequently, the updated W Q K ( 1 ) W_{QK}^{(1)} W Q K ( 1 ) induces a structured attention pattern. In the conditional branch, positions before the feature block attend almost uniformly to the background positions. At the transition point t = τ k − 1 t = \tau_k - 1 t = τ k − 1 , the attention shifts to the text token, which provides information about the upcoming feature. Once the first feature token has been generated, the model attends to the observed feature block; after the feature block ends, the attention returns to an almost uniform pattern. The unconditional branch follows the same structure except that it has no text token to attend to: it remains almost uniform before and after the feature block, and concentrates on the observed feature block once the first feature token appears.
This attention pattern makes the role of CFG explicit at the transition point. Fix a feature class k k k and write τ = τ k \tau= \tau_k τ = τ k . In the conditional branch, the position t = τ − 1 t = \tau- 1 t = τ − 1 attends to the text token. However, without guidance, the value carried by this text token still favors background repetition, assigning a larger logit to the background token K + j K+j K + j than to the feature token k k k :
logit t c o n d [ K + j ] − logit t c o n d [ k ] ≈ p k q j B K + j + k − p k C K + j + k > 0. \operatorname{logit}^{\mathrm{cond}}_t[K+j]-\operatorname{logit}^{\mathrm{cond}}_t[k]\approx p_kq_jB_{K+j+k}-p_kC_{K+j+k}>0. logit t cond [ K + j ] − logit t cond [ k ] ≈ p k q j B K + j + k − p k C K + j + k > 0.
With guidance, this background-repetition bias is canceled by subtracting the component shared with the unconditional branch. As a result, the guided logit reverses the preference and favors the feature token:
logit t λ [ K + j ] − logit t λ [ k ] ≈ − λ p k ( q j B K + j − q j C K + j ) < 0. \operatorname{logit}^{\lambda}_t[K+j]-\operatorname{logit}^{\lambda}_t[k]\approx-\lambda p_k(q_jB_{K+j}-q_jC_{K+j})<0. logit t λ [ K + j ] − logit t λ [ k ] ≈ − λ p k ( q j B K + j − q j C K + j ) < 0.
for any fixed λ ∈ ( 0 , 1 ) \lambda\in(0,1) λ ∈ ( 0 , 1 ) and sufficiently large T v i s T_{\mathrm{vis}} T vis . Thus, CFG flips only the transition token from K + j K+j K + j to k k k . After that, feature repetition keeps the whole feature block correct, and the background dominates again after the block. Hence, CFG only needs to flip the transition token from K + j K+j K + j to k k k . Once this first feature token is generated, the feature-repetition bias takes over and keeps the entire feature block correct. After the feature block ends, the background-repetition bias again dominates, so the model returns to generating the background token.
Tracing the generation process through the four regimes—before the feature block, at the transition point, inside the feature block, and after the feature block—yields
I ^ k , j λ ( θ ^ ) = I k , j , I ^ k , j 0 ( θ ^ ) = ( K + j , … , K + j ) . \widehat{I}^{\lambda}_{k,j}(\widehat{\theta})=I_{k,j},\qquad\widehat{I}^{0}_{k,j}(\widehat{\theta})=(K+j,\ldots,K+j). I k , j λ ( θ ) = I k , j , I k , j 0 ( θ ) = ( K + j , … , K + j ) .
In other words, CFG recovers the target image, whereas the purely conditional model collapses to repeated background tokens. Finally, the same margin estimates also imply minimal training loss L v i s ( θ ^ ) = O ( T v i s − 1 ( log T v i s ) 2 ) \mathcal{L}_{\mathrm{vis}}(\widehat{\theta})=O(T_{\mathrm{vis}}^{-1}(\log T_{\mathrm{vis}})^2) L vis ( θ ) = O ( T vis − 1 ( log T vis ) 2 ) and alignment of logits arg max logit t c o n d = arg max logit t u n c o n d \arg\max\operatorname{logit}^{\mathrm{cond}}_t=\arg\max\operatorname{logit}^{\mathrm{uncond}}_t arg max logit t cond = arg max logit t uncond along the successful path. Therefore, CFG succeeds by extracting the sparse feature signal from the logit difference, rather than by changing the top token of either branch alone.
Efficiency Improvement Via Attention Reuse
Building on the insights from § 4 and § 5 , we optimize AR inference efficiency by analyzing attention decomposition. Since § 5 shows that a single-layer Transformer can recover CFG dynamics, we decompose the attention output for a query q t q_t q t into visual and textual contributions. Let k 1 : t k_{1:t} k 1 : t and v 1 : t v_{1:t} v 1 : t be the keys and values for text tokens ( 1 … T t x t ) (1 \ldots T_{\mathrm{txt}}) ( 1 … T txt ) and visual tokens ( T t x t + 1 … t ) (T_{\mathrm{txt}} + 1 \ldots t) ( T txt + 1 … t ) . The attention output is:
∑ l = 1 t exp ( q t T k l ) v l ∑ l = 1 t exp ( q t T k l ) = γ t ⋅ ∑ l = T t x t + 1 t exp ( q t T k l ) v l ∑ l = T t x t + 1 t exp ( q t T k l ) + ( 1 − γ t ) ⋅ ∑ l = 1 T t x t exp ( q t T k l ) v l ∑ l = 1 T t x t exp ( q t T k l ) , \frac{\sum_{l=1}^{t} \exp(q_t^\mathsf{T} k_l)v_l}{\sum_{l=1}^{t} \exp(q_t^\mathsf{T} k_l)}
= \gamma_t \cdot\frac{\sum_{l=T_{\mathrm{txt}}+1}^{t} \exp(q_t^\mathsf{T} k_l)v_l}{\sum_{l=T_{\mathrm{txt}}+1}^{t} \exp(q_t^\mathsf{T} k_l)}
+ (1-\gamma_t) \cdot\frac{\sum_{l=1}^{T_{\mathrm{txt}}} \exp(q_t^\mathsf{T} k_l)v_l}{\sum_{l=1}^{T_{\mathrm{txt}}} \exp(q_t^\mathsf{T} k_l)}, ∑ l = 1 t exp ( q t T k l ) ∑ l = 1 t exp ( q t T k l ) v l = γ t ⋅ ∑ l = T txt + 1 t exp ( q t T k l ) ∑ l = T txt + 1 t exp ( q t T k l ) v l + ( 1 − γ t ) ⋅ ∑ l = 1 T txt exp ( q t T k l ) ∑ l = 1 T txt exp ( q t T k l ) v l ,
where γ t = ∑ l = T t x t + 1 t exp ( q t T k l ) / ∑ l = 1 t exp ( q t T k l ) \gamma_t = \sum_{l=T_{\mathrm{txt}}+1}^{t} \exp(q_t^\mathsf{T} k_l) / \sum_{l=1}^{t} \exp(q_t^\mathsf{T} k_l) γ t = ∑ l = T txt + 1 t exp ( q t T k l ) / ∑ l = 1 t exp ( q t T k l ) denotes the fraction of attention mass assigned to visual tokens. This separation clarifies the CFG mechanism: the first visual term captures the trajectory shared by both conditional and unconditional branches—consistent with our § 4 observation that both branches tend to repeat previous tokens. In contrast, the second textual term drives the deviation from the unconditional prediction, effectively forming the guidance direction logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond .
Motivated by this observation, we propose Attention Weight Reuse (AttnReuse), with the full procedure given in Algorithm 1 in Appendix § 9 .§ 5 and illustrated in Figure 8 . Instead of performing a separate unconditional forward pass, AttnReuse reuses the pre-computed conditional attention weights by masking out text-token entries and renormalizing each row over visual-token keys. The resulting distribution efficiently approximates the unconditional attention weights. In practice, we apply AttnReuse to about half of the layers for AR models, with implementation details deferred to Appendix § 9 .§ 5 .
Figure 8. Illustration of the proposed AttnReuse method. In selected layers, we reuse conditional attention weights by masking out text-token entries and renormalizing over image tokens. We then apply these weights to the conditional value vectors to approximate the unconditional attention output.
We evaluate AttnReuse on three representative AR image generation models: Emu3 ([68 ] ), Lumina-GPT 2.0 ([74 ] ), and Janus-Pro ([10 ] ). To test its generality beyond AR models, we also apply it to the diffusion-based Stable Diffusion 3 (SD3) ([17 ] ). We use DPG-Bench ((Hu et al., 2024)), which contains over 1,000 dense and structurally complex prompts for evaluating fine-grained semantic alignment. Results are reported under τ = 0 \tau= 0 τ = 0 and τ = 1 \tau= 1 τ = 1 , corresponding to greedy decoding and stochastic sampling, respectively. The τ = 0 \tau= 0 τ = 0 setting isolates the model’s top-ranked semantics, while τ = 1 \tau= 1 τ = 1 better reflects practical generation with sampling diversity. Detailed evaluation settings are shown in Appendix Table 3.
Quantitative results are summarized in Table 2 , with qualitative examples shown in Appendix Fig. 14. Across different AR models, AttnReuse provides a high-fidelity proxy for the standard unconditional pass: it preserves structural faithfulness with only marginal performance degradation, while reducing attention-related FLOPs by approximately 25%. Consistent with these findings, qualitative results show no observable degradation across all evaluated models.
Table 2. DPG-Bench results. Comparison of model backbones with and without AttnReuse (gray rows). Attention FLOPs are normalized to the standard CFG baseline (100%), encompassing both conditional and unconditional computations. To balance efficiency and fidelity, AttnReuse is applied to middle layers (e.g., 16/32 for AR models), preserving early layers for low-level representations and late layers for final predictions. For SD3-Medium, reuse is further restricted to the final 90% of denoising timesteps to maintain global layout. This strategy reduces relative attention FLOPs to 75% for AR models and 87% for SD3-Medium while maintaining competitive performance.
Conclusion
Our work demystifies the mechanism underlying CFG in AR image generation. We show that texture information is primarily encoded in the difference between the conditional and unconditional logits, whereas both logits share previous-token repetition as their top-ranked semantics. We prove that this repetition semantics arises from texture sparsity rather than training failure, and that CFG improves generation quality by rectifying this bias during inference. Motivated by this shared semantics, we propose AttnReuse, which reduces about 25% of attention computation with little performance degradation. A limitation of our work is its focus on image generation; we leave extensions to audio and video generation for future work.
Acknowledgments
Dirk Bergemann gratefully acknowledges financial support from UK DSIT (AP-S2-100058), NSF (SES 2519400), and ONR MURI (N00014-24-1-2742). Zhuoran Yang gratefully acknowledges financial support from UK DSIT (AP-S2-100058) and NSF (DMS 2413243).
Experimental Details
Experimental Details and Additional Results of Image Generation in Section 4.1
In this section, we describe the image generation setup used in our § 4.1 and provide more results.
We generate images using LlamaGen (0.7B) ([61 ] ), Lumina-mGPT 2.0 (7B) ([74 ] ), and Emu3 (8B) ([68 ] ). We employ the GenEval benchmark ([22 ] ), which consists of 553 prompts of varying lengths. Generations are performed via greedy decoding (τ = 0 \tau= 0 τ = 0 ) using three logit configurations: logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond , logit λ \operatorname{logit}^{\lambda} logit λ , and the difference logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond . For logit λ \operatorname{logit}^{\lambda} logit λ , we set λ = 10 \lambda= 10 λ = 10 across all models to ensure generation quality under greedy settings. Aside from the decoding strategy and guidance scale, all other hyperparameters follow the standard configurations of the respective models. Image resolutions are set to 512 × 512 512 \times512 512 × 512 for LlamaGen and Emu3, and 768 × 768 768 \times768 768 × 768 for Lumina-mGPT 2.0. During the image generation process, we also save the generated token sequences prior to decoding. By saving these token sequences, we can efficiently retrieve the corresponding logits via prefilling in any subsequent experiments. Our experiments are run on an A100 Nvidia GPU with 40G memory. The evaluation time used for DPG-Bench in § 6 follows the standard setting of this benchmark.
More generated examples are provided in Figure 9 , which exhibit similar phenomena to those observed in Figure 1 (§ 4.1 ).
Figure 9. Generated images from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond , logit λ \operatorname{logit}^{\lambda} logit λ , and logit d i f f = logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{diff}} = \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit diff = logit cond − logit uncond , shown from left to right in each grid. All images are generated by greedy decoding (τ = 0 \tau= 0 τ = 0 ). Prompts: Left: A street at night is lit up by streetlights. Right: An old man is wearing an odd hat. Images generated from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond are nearly pure-color, whereas those from logit d i f f \operatorname{logit}^{\mathrm{diff}} logit diff show richer textures.
Experimental Details of Texture Complexity Metrics in Section 4.1
In this section, we provide formal definitions and implementation details for the Texture Complexity metrics analyzed in § 4.1 . Let an image be denoted by I ∈ { 0 , … , 255 } C × H × W I \in\{0,\ldots,255\}^{C \times H \times W} I ∈ { 0 , … , 255 } C × H × W , where I c , i , j I_{c,i,j} I c , i , j represents the pixel value at location ( i , j ) (i,j) ( i , j ) in channel c ∈ { 1 , … , C } c \in\{1,\ldots,C\} c ∈ { 1 , … , C } . In our experiments, we use standard RGB images (C = 3 C=3 C = 3 ). We evaluate these metrics across images generated by logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond , logit λ \operatorname{logit}^{\lambda} logit λ and logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}}-\operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond . We report metrics as averages across images within each of the generation groups established in Section A.1.
Total Variation (TV). To measure the spatial smoothness of an image, we define the Total Variation as the average of normalized ℓ 1 \ell_1 ℓ 1 -norm of discrete gradients:
TV ( I ) = 1 C ∑ c = 1 C ( 1 ( H − 1 ) W ∑ i = 1 H − 1 ∑ j = 1 W ∣ ∇ i I c , i , j ∣ + 1 H ( W − 1 ) ∑ i = 1 H ∑ j = 1 W − 1 ∣ ∇ j I c , i , j ∣ ) , \operatorname{TV}(I)=\frac{1}{C}\sum_{c=1}^{C}\left(\frac{1}{(H-1)W}\sum_{i=1}^{H-1}\sum_{j=1}^{W}\lvert\nabla_i I_{c,i,j}\rvert+\frac{1}{H(W-1)}\sum_{i=1}^{H}\sum_{j=1}^{W-1}\lvert\nabla_j I_{c,i,j}\rvert\right), TV ( I ) = C 1 c = 1 ∑ C ( ( H − 1 ) W 1 i = 1 ∑ H − 1 j = 1 ∑ W ∣ ∇ i I c , i , j ∣ + H ( W − 1 ) 1 i = 1 ∑ H j = 1 ∑ W − 1 ∣ ∇ j I c , i , j ∣ ) ,
where ∇ i I c , i , j = I c , i + 1 , j − I c , i , j \nabla_i I_{c,i,j}=I_{c,i+1,j}-I_{c,i,j} ∇ i I c , i , j = I c , i + 1 , j − I c , i , j and ∇ j I c , i , j = I c , i , j + 1 − I c , i , j \nabla_j I_{c,i,j}=I_{c,i,j+1}-I_{c,i,j} ∇ j I c , i , j = I c , i , j + 1 − I c , i , j represent horizontal and vertical forward differences, respectively.
Pixel Entropy (Entropy). This metric captures the global richness of the intensity distribution. For each channel c c c , let p c ( v ) = ( H W ) − 1 ∑ i , j I { I c , i , j = v } p_c(v)=(HW)^{-1}\sum_{i,j}\mathbb{I}\{I_{c,i,j}=v\} p c ( v ) = ( H W ) − 1 ∑ i , j I { I c , i , j = v } be the empirical intensity distribution for v ∈ { 0 , … , 255 } v\in\{0,\ldots,255\} v ∈ { 0 , … , 255 } . The pixel entropy is computed as:
Entropy ( I ) = 1 C ∑ c = 1 C H ( p c ) = 1 C ∑ c = 1 C ( − ∑ v = 0 255 p c ( v ) log 2 p c ( v ) ) . \operatorname{Entropy}(I)=\frac{1}{C}\sum_{c=1}^{C}H(p_c)=\frac{1}{C}\sum_{c=1}^{C}\left(-\sum_{v=0}^{255}p_c(v)\log_2p_c(v)\right). Entropy ( I ) = C 1 c = 1 ∑ C H ( p c ) = C 1 c = 1 ∑ C ( − v = 0 ∑ 255 p c ( v ) log 2 p c ( v ) ) .
Orientation Entropy (OriEntropy). To characterize structural regularity, we measure the uncertainty of gradient orientations within the image. For each channel c c c , we compute the Sobel gradients ( G x , i , j ( c ) , G y , i , j ( c ) ) (G^{(c)}_{x,i,j},G^{(c)}_{y,i,j}) ( G x , i , j ( c ) , G y , i , j ( c ) ) at position ( i , j ) (i,j) ( i , j ) , which capture the local intensity variations along the horizontal and vertical axes, respectively, and the corresponding magnitude M i , j ( c ) = ( ( G x , i , j ( c ) ) 2 + ( G y , i , j ( c ) ) 2 ) 1 / 2 M^{(c)}_{i,j}=\left((G^{(c)}_{x,i,j})^2+(G^{(c)}_{y,i,j})^2\right)^{1/2} M i , j ( c ) = ( ( G x , i , j ( c ) ) 2 + ( G y , i , j ( c ) ) 2 ) 1/2 . The orientation is defined as θ i , j ( c ) = atan2 ( G y , i , j ( c ) , G x , i , j ( c ) ) \theta^{(c)}_{i,j}=\operatorname{atan2}(G^{(c)}_{y,i,j},G^{(c)}_{x,i,j}) θ i , j ( c ) = atan2 ( G y , i , j ( c ) , G x , i , j ( c ) ) , mapped to the undirected range [ 0 , π ) [0,\pi) [ 0 , π ) . To focus on salient structures, we only consider the set of pixels M c = { ( i , j ) ∣ M i , j ( c ) > M ˉ ( c ) } \mathcal{M}_c=\{(i,j)\mid M^{(c)}_{i,j}>\bar{M}^{(c)}\} M c = {( i , j ) ∣ M i , j ( c ) > M ˉ ( c ) } , where M ˉ ( c ) \bar{M}^{(c)} M ˉ ( c ) is the mean magnitude of the channel. We construct a magnitude-weighted orientation distribution q c q_c q c over K = 18 K=18 K = 18 discrete bins { Θ k } k = 1 K \{\Theta_k\}_{k=1}^{K} { Θ k } k = 1 K partitioning [ 0 , π ) [0,\pi) [ 0 , π ) :
q c ( k ) = 1 Z c ∑ ( i , j ) ∈ M c M i , j ( c ) I { θ i , j ( c ) ∈ Θ k } , Z c = ∑ ( i , j ) ∈ M c M i , j ( c ) . q_c(k)=\frac{1}{Z_c}\sum_{(i,j)\in\mathcal{M}_c}M^{(c)}_{i,j}\mathbb{I}\{\theta^{(c)}_{i,j}\in\Theta_k\},\qquad Z_c=\sum_{(i,j)\in\mathcal{M}_c}M^{(c)}_{i,j}. q c ( k ) = Z c 1 ( i , j ) ∈ M c ∑ M i , j ( c ) I { θ i , j ( c ) ∈ Θ k } , Z c = ( i , j ) ∈ M c ∑ M i , j ( c ) .
The OriEntropy of an image is defined as the average Shannon entropy across channels, which means OriEntropy ( I ) = C − 1 ∑ c = 1 C H ( q c ) \operatorname{OriEntropy}(I)=C^{-1}\sum_{c=1}^{C}H(q_c) OriEntropy ( I ) = C − 1 ∑ c = 1 C H ( q c ) .
Experimental Details of the Similarity Metrics in Section 4.2
In this section, we provide the experimental details in § 4.2 when we measure the similarity between logit t c o n d \operatorname{logit}^{\mathrm{cond}}_t logit t cond and logit t u n c o n d \operatorname{logit}^{\mathrm{uncond}}_t logit t uncond in logit and pixel spaces.
For all models, we collect these logits and their corresponding predicted tokens by prefilling the models with token sequences generated via logit λ \operatorname{logit}^{\lambda} logit λ (as described in Section A.1). We then compute the difference logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{cond}}-\operatorname{logit}^{\mathrm{uncond}} logit cond − logit uncond . The logit-space similarities (α d i f f , α c o n d , α u n c o n d \alpha^{\mathrm{diff}},\alpha^{\mathrm{cond}},\alpha^{\mathrm{uncond}} α diff , α cond , α uncond ) are calculated with k = 5 k=5 k = 5 for all three models. In the pixel space, we decode the predicted tokens to obtain β d i f f \beta^{\mathrm{diff}} β diff , β c o n d \beta^{\mathrm{cond}} β cond , and β u n c o n d \beta^{\mathrm{uncond}} β uncond . Finally, all metrics are averaged across images generated from the prompts defined in Section A.1.
To provide a qualitative comparison, we present sampled images decoded from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond in Figure 10 and Figure 11 . We observe that the images generated by logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond are highly similar across all cases, a finding that aligns with the results in Figure 3 and the theoretical analysis in § 4.2 .
Figure 3. Similarity measurements between ( logit t c o n d ) t = 1 T v i s (\operatorname{logit}^{\mathrm{cond}}_t)_{t=1}^{T_{\mathrm{vis}}} ( logit t cond ) t = 1 T vis and ( logit t u n c o n d ) t = 1 T v i s (\operatorname{logit}^{\mathrm{uncond}}_t)_{t=1}^{T_{\mathrm{vis}}} ( logit t uncond ) t = 1 T vis in logit space (Left ) and pixel space (Right ). Here, α d i f f \alpha^{\mathrm{diff}} α diff measures the mean absolute discrepancy between high-logit entries, and β d i f f \beta^{\mathrm{diff}} β diff measures the root-mean-square difference between images decoded from the two branches’ predictions; superscripts cond and uncond denote the corresponding magnitude baselines. Both measurements show small discrepancies relative to these baselines, indicating that the top-ranked entries of logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond are largely dominated by logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond .
Figure 10. Decoded images from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond , logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond , and logit d i f f = logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{diff}} = \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit diff = logit cond − logit uncond collected in Section A.3, shown from left to right in each grid. Prompts: Left: A glass bowl filled with oranges on a table. Right: An orange-reddish rose in a vase filled with water on top of a table. On the same visual prefixes, the two branches give nearly identical images, while their logit difference emphasizes textures.
Figure 11. Decoded images from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond , logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond , and logit d i f f = logit c o n d − logit u n c o n d \operatorname{logit}^{\mathrm{diff}} = \operatorname{logit}^{\mathrm{cond}} - \operatorname{logit}^{\mathrm{uncond}} logit diff = logit cond − logit uncond collected in Section A.3, shown from left to right in each grid. Prompts: Left: A street at night is lit up by streetlights. Right: An old man is wearing an odd hat. On the same visual prefixes, the two branches give nearly identical images, while their logit difference emphasizes textures.
Experimental Details and Additional Results of Section 4.3
In this section, we provide experimental details of quantifying repetition behavior in § 4.3 , and additional results of Emu3 and LlamaGen models.
In our experiments, we first identify high-frequency visual tokens and use them to construct prefixes. For each evaluated model, we pool the tokens generated across all images to compute their occurrence frequency. We define the set of common visual tokens as the top 1% most frequent tokens for each model, which comprises more than 100 tokens. Then, for each prompt in the GenEval benchmark Ghosh et al. [22 ] , we randomly sample one such token to construct a prefix covering 20% of the visual token positions, as described in § 4.3 . Specifically, the prefix occupies the first 20% of rows in the 2D latent space: 7 rows for LlamaGen (32 × 32 32 \times32 32 × 32 ), 13 for Emu3 (64 × 64 64 \times64 64 × 64 ), and 20 for Lumina-mGPT (96 × 96 96 \times96 96 × 96 ). Following generation conditioned on the prompts and prefixes, we compute r t r e p r_t^{\mathrm{rep}} r t rep at every position and average these values across all non-prefix positions to obtain r r e p r^{\mathrm{rep}} r rep . Finally, all results are averaged across the generated images.
Figure 12 and Figure 13 present the average r t r e p r_t^{\mathrm{rep}} r t rep across images for LlamaGen and Emu3. The results are consistent with the findings in § 4.3 , demonstrating that tokens generated from logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond tend to repeat the prefix tokens.
Figure 12. Position-wise repetition ratio r t r e p r_t^{\mathrm{rep}} r t rep of LlamaGen, averaged over samples. The ratio measures how often a generated token matches the prescribed prefix token; numbers beside the heatmaps are averages over horizontal bands. Both logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond show strong repetition of the prescribed prefix token.
Figure 13. Position-wise repetition ratio r t r e p r_t^{\mathrm{rep}} r t rep of Emu3, averaged over samples. The ratio measures how often a generated token matches the prescribed prefix token; numbers beside the heatmaps are averages over horizontal bands. Both logit c o n d \operatorname{logit}^{\mathrm{cond}} logit cond and logit u n c o n d \operatorname{logit}^{\mathrm{uncond}} logit uncond show strong repetition of the prescribed prefix token.
Experimental Details and Additional Results of Section 6
In this section, we provide additional details on AttnReuse. We first present the complete AttnReuse algorithm in Algorithm 1, which describes how attention weights are reused in selected layers while the remaining layers are computed normally. We then summarize the evaluation settings for each model in Table 3 . Finally, we present qualitative results in Figure 14 , showing that AttnReuse preserves the semantic content and overall visual structure of the generated images with no noticeable degradation compared to standard CFG.
Table 3. Evaluation settings across models. For AR models, AttnReuse is applied to a subset of attention layers (Layers 8–23). For diffusion models, it is applied to selected layers (Layers 9–17) and across the last 90% of timesteps.
Figure 14. Qualitative comparison between Base and AttnReuse across different models. AttnReuse preserves structural and semantic fidelity under both greedy (τ = 0 \tau= 0 τ = 0 ) and stochastic (τ = 1 \tau= 1 τ = 1 ) decoding, while reducing attention computation.
In Table 3 , we list the evaluation settings for each models. For both AR and diffusion models, AttnReuse is applied only to a selected subset of layers during generation to balance efficiency and fidelity. For diffusion models, where computation is additionally distributed across denoising timesteps, we further apply AttnReuse to selected timesteps.
For the three evaluated AR models, each backbone contains 32 Transformer layers. We apply AttnReuse to the middle 16 layers and keep the early and late layers unchanged. This design is motivated by the observation that early layers are more sensitive to low-level token representations, while late layers more directly affect the final prediction logits. Therefore, applying AttnReuse to the middle layers provides a better trade-off between computational efficiency and output fidelity.
For SD3-Medium, which contains 24 Transformer layers, we similarly apply AttnReuse to middle layers. In addition, since the early denoising timesteps largely determine the coarse semantics and global layout of the final image, we keep these timesteps unchanged and apply AttnReuse only to the last 90% of denoising timesteps. This timestep selection reduces computation while preserving the semantic structure established in the early generation stage.
For the stochastic setting τ = 1 \tau= 1 τ = 1 , we follow the officially released inference configuration of each model. For the greedy setting τ = 0 \tau= 0 τ = 0 , directly using the official CFG scale often produces semantically incomplete outputs. We therefore search the CFG scale under τ = 0 \tau= 0 τ = 0 for each model and report the selected setting used in our evaluation. Across all settings, AttnReuse introduces no additional learnable parameters and is fully compatible with pretrained checkpoints.
Detailed Training Algorithm in Section 5
We train the model by (two-step) population gradient descent on the data distribution defined above, as specified in Algorithm 2. The population cross-entropy loss is
L v i s ( θ ) = E ( z 1 , x 1 : T v i s ) ∼ P d a t a [ 1 T v i s − 1 ∑ t = 0 T v i s − 1 − log P θ ( x t + 1 ∣ z 1 , x 1 : t ) ] \mathcal{L}_{\mathrm{vis}}(\theta)=\mathbb{E}_{(z_1,x_{1:T_{\mathrm{vis}}})\sim P_{\mathrm{data}}}\left[\frac{1}{T_{\mathrm{vis}}-1}\sum_{t=0}^{T_{\mathrm{vis}}-1}-\log P_\theta(x_{t+1}\mid z_1,x_{1:t})\right] L vis ( θ ) = E ( z 1 , x 1 : T vis ) ∼ P data [ T vis − 1 1 t = 0 ∑ T vis − 1 − log P θ ( x t + 1 ∣ z 1 , x 1 : t ) ]
To train the parameters θ = ( W V , W Q K ) \theta=(W_V,W_{QK}) θ = ( W V , W Q K ) , we initialize them as θ ( 0 ) = ( 0 , 0 ) \theta^{(0)}=(0,0) θ ( 0 ) = ( 0 , 0 ) . We first update W V W_V W V by one gradient step, and then optimize W Q K W_{QK} W Q K for one step while keeping W V W_V W V fixed. This two-stage training protocol follows prior analyses of transformer training dynamics and is used for theoretical tractability [70 , 47 ] .
Algorithm 2 Two-step population gradient descent
Require: Transformer P θ P_\theta P θ ; learning rates η V , η Q K > 0 \eta_V,\eta_{QK}>0 η V , η Q K > 0 ; population loss L v i s ( ⋅ ) \mathcal{L}_{\mathrm{vis}}(\cdot) L vis ( ⋅ ) .
θ ( 0 ) ← ( 0 , 0 ) \theta^{(0)} \leftarrow(0,0) θ ( 0 ) ← ( 0 , 0 )
W V ( 1 ) ← − η V ∇ W V L v i s ( θ ( 0 ) ) W_V^{(1)} \leftarrow-\eta_V\nabla_{W_V}\mathcal{L}_{\mathrm{vis}}(\theta^{(0)}) W V ( 1 ) ← − η V ∇ W V L vis ( θ ( 0 ) ) ; θ ( 1 ) ← ( W V ( 1 ) , 0 ) \theta^{(1)} \leftarrow(W_V^{(1)},0) θ ( 1 ) ← ( W V ( 1 ) , 0 )
W Q K ( 1 ) ← − η Q K ∇ W Q K L v i s ( θ ( 1 ) ) W_{QK}^{(1)} \leftarrow-\eta_{QK}\nabla_{W_{QK}}\mathcal{L}_{\mathrm{vis}}(\theta^{(1)}) W Q K ( 1 ) ← − η Q K ∇ W Q K L vis ( θ ( 1 ) ) ; θ ( 2 ) ← ( W V ( 1 ) , W Q K ( 1 ) ) \theta^{(2)} \leftarrow(W_V^{(1)},W_{QK}^{(1)}) θ ( 2 ) ← ( W V ( 1 ) , W Q K ( 1 ) )
return θ ( 2 ) \theta^{(2)} θ ( 2 )
Technical Preliminaries for the Proof
In this section, we introduce the notation and technical results that will be used in the proof of the main theorem. We clarify the notation and make the intermediate outputs of the model explicit to facilitate the subsequent analysis. We then derive explicit expressions for the gradients with respect to the model parameters, which will play a central role in the analysis.
Transformer Computation Decomposition To analyze the computational flow of the Transformer defined in § 5 , we first decompose the attention mechanism under the given parameter constraints. For notational simplicity, we denote the initial text token z 1 z_1 z 1 as x 0 x_0 x 0 and fix its position at t = 0 t=0 t = 0 . Let s t l s_{tl} s tl and α t l \alpha_{tl} α tl denote the pre-softmax attention score and the corresponding weight from query position t t t to key position l l l . The attention output o ~ t \widetilde{o}_t o t and the resulting logit logit t \operatorname{logit}_t logit t at position t t t are computed as follows:
s t l = h t T W ~ Q K h l , α t l = exp ( s t l ) ∑ s = 0 t exp ( s t s ) , o ~ t = ∑ l = 0 t α t l W ~ V h l , logit t = W ~ l m T o ~ t s_{tl}=h_t^{\mathsf{T}}\widetilde{W}_{QK}h_l,\qquad\alpha_{tl}=\frac{\exp(s_{tl})}{\sum_{s=0}^{t}\exp(s_{ts})},\qquad\widetilde{o}_t=\sum_{l=0}^{t}\alpha_{tl}\widetilde{W}_Vh_l,\qquad\operatorname{logit}_t=\widetilde{W}_{\mathrm{lm}}^{\mathsf{T}}\widetilde{o}_t s tl = h t T W Q K h l , α tl = ∑ s = 0 t exp ( s t s ) exp ( s tl ) , o t = l = 0 ∑ t α tl W V h l , logit t = W lm T o t
where for simplicity, we denote logit t \operatorname{logit}_t logit t for logit t c o n d \operatorname{logit}_t^{\mathrm{cond}} logit t cond . Because the parameterization is restricted to
W ~ Q K = [ 0 0 W Q K 0 ] , W ~ V = [ W V 0 0 0 ] , W ~ l m = [ W l m 0 ] , \widetilde{W}_{QK}=
\begin{bmatrix}
0 & 0\\
W_{QK} & 0
\end{bmatrix},\qquad
\widetilde{W}_V=
\begin{bmatrix}
W_V & 0\\
0 & 0
\end{bmatrix},\qquad
\widetilde{W}_{\mathrm{lm}}=
\begin{bmatrix}
W_{\mathrm{lm}}\\
0
\end{bmatrix}, W Q K = [ 0 W Q K 0 0 ] , W V = [ W V 0 0 0 ] , W lm = [ W lm 0 ] ,
and input satisfies h t = [ f x t ⊤ , e t ⊤ ] ⊤ h_t = [f_{x_t}^{\top}, e_t^{\top}]^{\top} h t = [ f x t ⊤ , e t ⊤ ] ⊤ , we can simplify as
s t l = e t ⊤ W Q K f x l , o ~ t = [ o t 0 ] , o t = ∑ l = 0 t α t l W V f x l , logit t = W l m ⊤ o t . s_{tl} = e_t^{\top}W_{QK}f_{x_l},\quad\widetilde{o}_t = \begin{bmatrix} o_t \\ 0 \end{bmatrix},\quad o_t = \sum_{l=0}^{t}\alpha_{tl}W_Vf_{x_l},\quad\operatorname{logit}_t = W_{\mathrm{lm}}^{\top}o_t. s tl = e t ⊤ W Q K f x l , o t = [ o t 0 ] , o t = l = 0 ∑ t α tl W V f x l , logit t = W lm ⊤ o t .
For notational convenience, we use the superscript uc to denote variables associated with the unconditional case (uncond). Correspondingly, the attention weights α t l u c \alpha_{tl}^{\mathrm{uc}} α tl uc , attention outputs o ~ t u c \widetilde{o}_t^{\mathrm{uc}} o t uc , and logits logit t u c \operatorname{logit}_t^{\mathrm{uc}} logit t uc for the unconditional model (simplified version of logit t u n c o n d \operatorname{logit}_t^{\mathrm{uncond}} logit t uncond ) are defined as:
α t l u c = exp ( s t l ) ∑ s = 1 t exp ( s t s ) , o ~ t u c = ∑ l = 1 t α t l u c W ~ V h l , logit t u c = W ~ l m ⊤ o ~ t u c . \alpha_{tl}^{\mathrm{uc}} = \frac{\exp(s_{tl})}{\sum_{s=1}^{t}\exp(s_{ts})},\quad\widetilde{o}_t^{\mathrm{uc}} = \sum_{l=1}^{t}\alpha_{tl}^{\mathrm{uc}}\widetilde{W}_Vh_l,\quad\operatorname{logit}_t^{\mathrm{uc}} = \widetilde{W}_{\mathrm{lm}}^{\top}\widetilde{o}_t^{\mathrm{uc}}. α tl uc = ∑ s = 1 t exp ( s t s ) exp ( s tl ) , o t uc = l = 1 ∑ t α tl uc W V h l , logit t uc = W lm ⊤ o t uc .
Similarly, by exploiting the previously defined block-matrix parameterization, these expressions can be simplified in terms of the token-level representations:
o ~ t u c = [ o t u c 0 ] , o t u c = ∑ l = 1 t α t l u c W V f x l , logit t u c = W l m ⊤ o t u c . \widetilde{o}_t^{\mathrm{uc}} = \begin{bmatrix} o_t^{\mathrm{uc}} \\ 0 \end{bmatrix},\quad o_t^{\mathrm{uc}} = \sum_{l=1}^{t}\alpha_{tl}^{\mathrm{uc}}W_Vf_{x_l},\quad\operatorname{logit}_t^{\mathrm{uc}} = W_{\mathrm{lm}}^{\top}o_t^{\mathrm{uc}}. o t uc = [ o t uc 0 ] , o t uc = l = 1 ∑ t α tl uc W V f x l , logit t uc = W lm ⊤ o t uc .
For clarity, we denote the i i i -th element of logit t ∈ R K + J \operatorname{logit}_t \in\mathbb{R}^{K+J} logit t ∈ R K + J as logit t [ i ] \operatorname{logit}_t[i] logit t [ i ] , which also applies for logit t u c \operatorname{logit}_t^{\mathrm{uc}} logit t uc and logit t λ \operatorname{logit}_t^{\lambda} logit t λ .
Equivalent Form of CFG on Output Given that the output matrix W l m W_{\mathrm{lm}} W lm is fixed, we can establish an operational equivalence between applying CFG at the logit level and the attention output level. At position t t t , the CFG-modified logits with guidance scale λ \lambda λ are formulated as:
logit t λ = logit t + λ ( logit t − logit t u c ) = W l m ⊤ ( o t + λ ( o t − o t u c ) ) . (4) \operatorname{logit}_t^{\lambda} = \operatorname{logit}_t + \lambda(\operatorname{logit}_t - \operatorname{logit}_t^{\mathrm{uc}}) = W_{\mathrm{lm}}^{\top}(o_t + \lambda(o_t-o_t^{\mathrm{uc}})). \tag*{(4)} logit t λ = logit t + λ ( logit t − logit t uc ) = W lm ⊤ ( o t + λ ( o t − o t uc )) . (4)
where the first equation follows from the definition in Eqn. (2) , and the second relies on the simplified representation introduced previously.
Compact Notation for Sequences To simplify the exposition, we adopt the superscript × L \times L × L to denote a token repeated L L L times. For instance, a representative sample from our data distribution is denoted as ( K + J + k 1 , ( K + j 1 ) × τ , ( k 1 ) × L , ( K + j 1 ) × ( T − τ − L ) ) (K+J+k_1, (K+j_1)^{\times\tau}, (k_1)^{\times L}, (K+j_1)^{\times(T-\tau-L)}) ( K + J + k 1 , ( K + j 1 ) × τ , ( k 1 ) × L , ( K + j 1 ) × ( T − τ − L ) ) . This sequence consists of an initial text token K + J + k 1 K+J+k_1 K + J + k 1 , followed by a block of τ \tau τ background tokens K + j 1 K+j_1 K + j 1 , a segment of L L L feature tokens k 1 k_1 k 1 , and a final padding of T − τ − L T-\tau-L T − τ − L background tokens.
Per-sequence loss and Population loss To analyze the training dynamics, we derive a closed-form expression for the population loss. We begin by defining the loss for an individual sequence ( x 0 , x 1 , … , x T ) ∈ I k , j (x_0,x_1,\ldots,x_T) \in\mathcal{I}_{k,j} ( x 0 , x 1 , … , x T ) ∈ I k , j , where k ∈ [ K ] k \in[K] k ∈ [ K ] and j ∈ [ J ] j \in[J] j ∈ [ J ] denote the visual feature and background classes, respectively. The cross-entropy loss for this sequence is given by:
L ( k , j ; θ ) = − ∑ t = 1 T − 1 log P θ ( x t + 1 ∣ x 0 , x 1 , … , x t ) , where ( x 0 , x 1 , … , x T ) = I k , j . (5) \mathcal{L}(k,j;\theta) = -\sum_{t=1}^{T-1}\log P_{\theta}(x_{t+1}\mid x_0,x_1,\ldots,x_t),\quad\text{where }(x_0,x_1,\ldots,x_T)=\mathcal{I}_{k,j}. \tag*{(5)} L ( k , j ; θ ) = − t = 1 ∑ T − 1 log P θ ( x t + 1 ∣ x 0 , x 1 , … , x t ) , where ( x 0 , x 1 , … , x T ) = I k , j . (5)
The population loss under the data distribution P d a t a P_{\mathrm{data}} P data (defined in § 5 ) is then formulated as the expected loss over all sequences:
L v i s ( θ ) = E ( z 1 , x 1 : T ) ∼ P d a t a [ ∑ t = 1 T − 1 − log P θ ( x t + 1 ∣ x 0 , x 1 : t ) ] = ∑ k = 1 K p k ∑ j = 1 J q j L ( k , j ; θ ) . (6) \mathcal{L}_{\mathrm{vis}}(\theta) = \mathbb{E}_{(z_1,x_{1:T})\sim P_{\mathrm{data}}}\left[\sum_{t=1}^{T-1}-\log P_{\theta}(x_{t+1}\mid x_0,x_{1:t})\right] = \sum_{k=1}^{K}p_k\sum_{j=1}^{J}q_j\mathcal{L}(k,j;\theta). \tag*{(6)} L vis ( θ ) = E ( z 1 , x 1 : T ) ∼ P data [ t = 1 ∑ T − 1 − log P θ ( x t + 1 ∣ x 0 , x 1 : t ) ] = k = 1 ∑ K p k j = 1 ∑ J q j L ( k , j ; θ ) . (6)
where the first equation is the definition of population loss in § 5 , and the second equation holds because the probability of sampling visual feature class k k k is p k p_k p k , and sampling visual background class j j j is q j q_j q j .
Gradient Formulas
To facilitate the subsequent analysis of gradient dynamics, we define several auxiliary quantities that characterize the prediction error and its projection back into the hidden representation space.
Let P t = P θ ( x t + 1 ∣ x 0 : t ) = sm ( logit t ) ∈ R K + J P_t = P_{\theta}(x_{t+1}\mid x_{0:t}) = \operatorname{sm}(\operatorname{logit}_t) \in\mathbb{R}^{K+J} P t = P θ ( x t + 1 ∣ x 0 : t ) = sm ( logit t ) ∈ R K + J be the predicted probability distribution over the vocabulary at position t t t . We define the prediction residual δ t \delta_t δ t and its pullback g ~ t \widetilde{g}_t g t through the language modeling head W ~ L M \widetilde{W}_{\mathrm{LM}} W LM as follows:
y t = 1 x t + 1 ∈ R K + J , δ t = P t − y t ∈ R K + J , g ~ t = W ~ L M δ t = [ g t 0 ] ∈ R D , g t = W l m δ t ∈ R d . y_t = \mathbf{1}_{x_{t+1}} \in\mathbb{R}^{K+J}, \qquad\delta_t = P_t-y_t \in\mathbb{R}^{K+J}, \qquad\widetilde{g}_t = \widetilde{W}_{\mathrm{LM}}\delta_t = \begin{bmatrix} g_t \\ 0 \end{bmatrix} \in\mathbb{R}^{D}, \qquad g_t = W_{\mathrm{lm}}\delta_t \in\mathbb{R}^{d}. y t = 1 x t + 1 ∈ R K + J , δ t = P t − y t ∈ R K + J , g t = W LM δ t = [ g t 0 ] ∈ R D , g t = W lm δ t ∈ R d .
where 1 i \mathbf{1}_i 1 i is the i i i -th standard basis vector in R K + J \mathbb{R}^{K+J} R K + J , and here 1 x t + 1 \mathbf{1}_{x_{t+1}} 1 x t + 1 acts as indicator vector for class x t + 1 x_{t+1} x t + 1 . The structure of g ~ t \widetilde{g}_t g t comes from the simplified structure of parameters.
Lemma C.1 (Single-sequence gradients). Fix any token sequence ( x 0 , … , x T ) (x_0,\ldots,x_T) ( x 0 , … , x T ) and parameters θ = ( W V , W Q K ) \theta=(W_V,W_{QK}) θ = ( W V , W Q K ) . The gradients of the single-sequence loss L \mathcal{L} L in Eqn. (C.2) with respect to W V W_V W V and W Q K W_{QK} W Q K are
∇ W V L = ∑ t = 1 T − 1 ∑ l = 0 t α t l g t f x l T . (7) \nabla_{W_V}\mathcal{L} = \sum_{t=1}^{T-1}\sum_{l=0}^{t}\alpha_{tl}g_t f_{x_l}^{\mathsf{T}}. \tag*{(7)} ∇ W V L = t = 1 ∑ T − 1 l = 0 ∑ t α tl g t f x l T . (7) ∇ W Q K L = ∑ t = 1 T − 1 ∑ l = 0 t α t l [ g t T ( W V f x l − o t ) ] e t f x l T . (8) \nabla_{W_{QK}}\mathcal{L} = \sum_{t=1}^{T-1}\sum_{l=0}^{t}\alpha_{tl}\left[g_t^{\mathsf{T}}\left(W_V f_{x_l}-o_t\right)\right]e_t f_{x_l}^{\mathsf{T}}. \tag*{(8)} ∇ W Q K L = t = 1 ∑ T − 1 l = 0 ∑ t α tl [ g t T ( W V f x l − o t ) ] e t f x l T . (8)
Proof. Gradient w.r.t. W V W_V W V . Write the per-step loss as L t = − log P t ( x t + 1 ∣ x 0 : t ) \mathcal{L}_t=-\log P_t(x_{t+1}\mid x_{0:t}) L t = − log P t ( x t + 1 ∣ x 0 : t ) . Because P t = sm ( logit t ) = sm ( W l m T o t ) P_t=\operatorname{sm}(\operatorname{logit}_t)=\operatorname{sm}(W_{\mathrm{lm}}^{\mathsf{T}}o_t) P t = sm ( logit t ) = sm ( W lm T o t ) . Applying the standard gradient property of the softmax cross-entropy loss and the chain rule via logit t = W l m T o t \operatorname{logit}_t=W_{\mathrm{lm}}^{\mathsf{T}}o_t logit t = W lm T o t , we obtain
∂ L t ∂ logit t = P t − y t = δ t , ∂ L t ∂ o t = W l m δ t = g t . \frac{\partial\mathcal{L}_t}{\partial\operatorname{logit}_t}=P_t-y_t=\delta_t,\qquad\frac{\partial\mathcal{L}_t}{\partial o_t}=W_{\mathrm{lm}}\delta_t=g_t. ∂ logit t ∂ L t = P t − y t = δ t , ∂ o t ∂ L t = W lm δ t = g t .
Since o t = ∑ l = 0 t α t l W V f x l o_t=\sum_{l=0}^{t}\alpha_{tl}W_Vf_{x_l} o t = ∑ l = 0 t α tl W V f x l and α t l \alpha_{tl} α tl does not depend on W V W_V W V , differentiating entry-wise gives
∂ o t ∂ ( W V ) a b = ∑ l = 0 t α t l ( f x l ) b 1 a , \frac{\partial o_t}{\partial(W_V)_{ab}}=\sum_{l=0}^{t}\alpha_{tl}(f_{x_l})_b\mathbf{1}_a, ∂ ( W V ) ab ∂ o t = l = 0 ∑ t α tl ( f x l ) b 1 a ,
where 1 a \mathbf{1}_a 1 a is the a a a -th standard basis vector in R K + J \mathbb{R}^{K+J} R K + J . Applying the chain rule from ∂ L t ∂ o t \frac{\partial\mathcal{L}_t}{\partial o_t} ∂ o t ∂ L t , ∂ o t ∂ ( W V ) a b \frac{\partial o_t}{\partial(W_V)_{ab}} ∂ ( W V ) ab ∂ o t and collecting into matrix form, we have
∂ L t ∂ W V = g t ( ∑ l = 0 t α t l f x l ) T = ∑ l = 0 t α t l g t f x l T . \frac{\partial\mathcal{L}_t}{\partial W_V}=g_t\left(\sum_{l=0}^{t}\alpha_{tl}f_{x_l}\right)^{\mathsf{T}}=\sum_{l=0}^{t}\alpha_{tl}g_tf_{x_l}^{\mathsf{T}}. ∂ W V ∂ L t = g t ( l = 0 ∑ t α tl f x l ) T = l = 0 ∑ t α tl g t f x l T .
Summing over t = 1 , … , T − 1 t=1,\ldots,T-1 t = 1 , … , T − 1 , we have
∇ W V L = ∑ t = 1 T − 1 ∂ L t ∂ W V = ∑ t = 1 T − 1 ∑ l = 0 t α t l g t f x l T . \nabla_{W_V}\mathcal{L}=\sum_{t=1}^{T-1}\frac{\partial\mathcal{L}_t}{\partial W_V}=\sum_{t=1}^{T-1}\sum_{l=0}^{t}\alpha_{tl}g_tf_{x_l}^{\mathsf{T}}. ∇ W V L = t = 1 ∑ T − 1 ∂ W V ∂ L t = t = 1 ∑ T − 1 l = 0 ∑ t α tl g t f x l T .
Gradient w.r.t. W Q K W_{QK} W Q K . We decompose the chain via the intermediate variables α t j \alpha_{tj} α t j and s t l s_{tl} s tl . Since o t = ∑ l = 0 t α t l W V f x l o_t=\sum_{l=0}^{t}\alpha_{tl}W_Vf_{x_l} o t = ∑ l = 0 t α tl W V f x l , varying α t j \alpha_{tj} α t j while keeping all other attention weights fixed gives ∂ o t / ∂ α t j = W V f x j \partial o_t/\partial\alpha_{tj}=W_Vf_{x_j} ∂ o t / ∂ α t j = W V f x j . Combined with ∂ L t / ∂ o t = g t \partial\mathcal{L}_t/\partial o_t=g_t ∂ L t / ∂ o t = g t , by chain rule, we have
∂ L t ∂ α t j = g t T W V f x j . \frac{\partial\mathcal{L}_t}{\partial\alpha_{tj}}=g_t^{\mathsf{T}}W_Vf_{x_j}. ∂ α t j ∂ L t = g t T W V f x j .
From the softmax formula α t j = exp ( s t j ) / ∑ s ′ = 0 t exp ( s t s ′ ) \alpha_{tj} = \exp(s_{tj})/\sum_{s'=0}^{t}\exp(s_{ts'}) α t j = exp ( s t j ) / ∑ s ′ = 0 t exp ( s t s ′ ) , standard differentiation yields the Jacobian
∂ α t j ∂ s t l = α t j ( I { j = l } − α t l ) . \frac{\partial\alpha_{tj}}{\partial s_{tl}} = \alpha_{tj}\left(\mathbb{I}\{j=l\}-\alpha_{tl}\right). ∂ s tl ∂ α t j = α t j ( I { j = l } − α tl ) .
By the chain rule over j j j , we have
∂ L t ∂ s t l = ∑ j = 0 t ∂ L t ∂ α t j ⋅ ∂ α t j ∂ s t l = ∑ j = 0 t ( g t T W V f x j ) α t j ( I { j = l } − α t l ) = α t l g t T W V f x l − α t l ∑ j = 0 t α t j g t T W V f x j = α t l g t T ( W V f x l − o t ) . \begin{aligned}
\frac{\partial\mathcal{L}_t}{\partial s_{tl}} = \sum_{j=0}^{t}\frac{\partial\mathcal{L}_t}{\partial\alpha_{tj}}\cdot\frac{\partial\alpha_{tj}}{\partial s_{tl}} \\
&= \sum_{j=0}^{t}\left(g_t^{\mathsf{T}}W_Vf_{x_j}\right)\alpha_{tj}\left(\mathbb{I}\{j=l\}-\alpha_{tl}\right) \\
&= \alpha_{tl}g_t^{\mathsf{T}}W_Vf_{x_l}-\alpha_{tl}\sum_{j=0}^{t}\alpha_{tj}g_t^{\mathsf{T}}W_Vf_{x_j} \\
&= \alpha_{tl}g_t^{\mathsf{T}}\left(W_Vf_{x_l}-o_t\right).
\end{aligned} ∂ s tl ∂ L t = j = 0 ∑ t ∂ α t j ∂ L t ⋅ ∂ s tl ∂ α t j = j = 0 ∑ t ( g t T W V f x j ) α t j ( I { j = l } − α tl ) = α tl g t T W V f x l − α tl j = 0 ∑ t α t j g t T W V f x j = α tl g t T ( W V f x l − o t ) .
where the second and third equalities follow from previous results of ∂ L t ∂ α t j \frac{\partial\mathcal{L}_t}{\partial\alpha_{tj}} ∂ α t j ∂ L t , ∂ α t j ∂ s t l \frac{\partial\alpha_{tj}}{\partial s_{tl}} ∂ s tl ∂ α t j and direct expansion, the last step invokes the structural form of o t = ∑ j = 0 t α t j g t T W V f x j o_t=\sum_{j=0}^{t}\alpha_{tj}g_t^{\mathsf{T}}W_Vf_{x_j} o t = ∑ j = 0 t α t j g t T W V f x j .
From the simplification, we have s t l = e t T W Q K f x l s_{tl}=e_t^{\mathsf{T}}W_{QK}f_{x_l} s tl = e t T W Q K f x l , the differentiation gives ∂ s t l / ∂ W Q K = e t f x l T \partial s_{tl}/\partial W_{QK}=e_tf_{x_l}^{\mathsf{T}} ∂ s tl / ∂ W Q K = e t f x l T . Combining the previous results and applying the chain rule, we obtain
∂ L t ∂ W Q K = ∑ l = 0 t ∂ L t ∂ s t l ⋅ e t f x l T = ∑ l = 0 t α t l g t T ( W V f x l − o t ) e t f x l T . \frac{\partial\mathcal{L}_t}{\partial W_{QK}}=\sum_{l=0}^{t}\frac{\partial\mathcal{L}_t}{\partial s_{tl}}\cdot e_tf_{x_l}^{\mathsf{T}}=\sum_{l=0}^{t}\alpha_{tl}g_t^{\mathsf{T}}\left(W_Vf_{x_l}-o_t\right)e_tf_{x_l}^{\mathsf{T}}. ∂ W Q K ∂ L t = l = 0 ∑ t ∂ s tl ∂ L t ⋅ e t f x l T = l = 0 ∑ t α tl g t T ( W V f x l − o t ) e t f x l T .
where the first equation comes from chain rule expansion, and the second equation follow from previous results of ∂ L t ∂ s t l \frac{\partial\mathcal{L}_t}{\partial s_{tl}} ∂ s tl ∂ L t , ∂ L t ∂ W Q K \frac{\partial\mathcal{L}_t}{\partial W_{QK}} ∂ W Q K ∂ L t .
Summing over t = 1 , … , T − 1 t=1,\ldots,T-1 t = 1 , … , T − 1 , we have
∇ W Q K L = ∑ t = 1 T − 1 ∂ L t ∂ W Q K = ∑ t = 1 T − 1 ∑ l = 0 t α t l [ g t T ( W V f x l − o t ) ] e t f x l T . \nabla_{W_{QK}}\mathcal{L}=\sum_{t=1}^{T-1}\frac{\partial\mathcal{L}_t}{\partial W_{QK}}=\sum_{t=1}^{T-1}\sum_{l=0}^{t}\alpha_{tl}\left[g_t^{\mathsf{T}}\left(W_Vf_{x_l}-o_t\right)\right]e_tf_{x_l}^{\mathsf{T}}. ∇ W Q K L = t = 1 ∑ T − 1 ∂ W Q K ∂ L t = t = 1 ∑ T − 1 l = 0 ∑ t α tl [ g t T ( W V f x l − o t ) ] e t f x l T .
Thus, we conclude the proof of Lemma C.1.
Proof of Theorem 5.3
In the proof of Theorem 5.3 , we follow the training protocol in Appendix § 10 and analyze the approximation errors of θ ( 1 ) \theta^{(1)} θ ( 1 ) and θ ( 2 ) \theta^{(2)} θ ( 2 ) sequentially. For ease of notation, we will write T v i s T_{\mathrm{vis}} T vis as T T T in the proof. Before the proof, we will first state the formal version of Theorem 5.3 as follows.
Theorem D.1. Under Assumptions 5.1 and 5.2 , suppose the following parameter regime holds as T v i s → ∞ T_{\mathrm{vis}}\to\infty T vis → ∞ : the start positions of features satisfy τ k = τ = Θ ( T v i s β ) \tau_k=\tau=\Theta(T_{\mathrm{vis}}^\beta) τ k = τ = Θ ( T vis β ) for all k ∈ [ K ] k\in[K] k ∈ [ K ] , and some fixed β ∈ ( 1 / 2 , 1 ) \beta\in(1/2,1) β ∈ ( 1/2 , 1 ) ; the number of visual background tokens satisfies J = ⌈ τ log T v i s / c L ⌉ J=\lceil\tau\log T_{\mathrm{vis}}/cL\rceil J = ⌈ τ log T vis / c L ⌉ for a constant c c c with 1 < c < 1 / ( 2 − 2 β ) 1<c<1/(2-2\beta) 1 < c < 1/ ( 2 − 2 β ) ; the number of visual feature tokens satisfies K = Θ ( 1 ) K=\Theta(1) K = Θ ( 1 ) ; the distribution of images satisfies p k = Θ ( 1 / K ) p_k=\Theta(1/K) p k = Θ ( 1/ K ) , q j = 1 / J q_j=1/J q j = 1/ J ; the learning rates satisfy η V = Θ ( 1 ) \eta_V=\Theta(1) η V = Θ ( 1 ) , η Q K = Θ ( T v i s β ) \eta_{QK}=\Theta(T_{\mathrm{vis}}^\beta) η Q K = Θ ( T vis β ) . Let θ ( 2 ) = ( W V ( 1 ) , W Q K ( 1 ) ) \theta^{(2)}=(W_V^{(1)},W_{QK}^{(1)}) θ ( 2 ) = ( W V ( 1 ) , W Q K ( 1 ) ) be the output of Algorithm 2 applied to the Transformer model P θ P_\theta P θ . Then the following three statements hold.
(Training loss.) The population loss is asymptotically small, with
L v i s ( θ ( 2 ) ) = Θ ( ( log T v i s ) 2 T v i s ) . \mathcal{L}_{\mathrm{vis}}\left(\theta^{(2)}\right)=\Theta\left(\frac{(\log T_{\mathrm{vis}})^2}{T_{\mathrm{vis}}}\right). L vis ( θ ( 2 ) ) = Θ ( T vis ( log T vis ) 2 ) .
(Conditional generation fails and repeats.) With guidance scale λ = 0 \lambda= 0 λ = 0 (pure conditional generation), the generated sequence is not a valid image and repeats backgrounds for any query:
I ^ k , j 0 ( θ ( 2 ) ) = ( K + j , ⋯ , K + j ) ≠ I k , j , for all k ∈ [ K ] , j ∈ [ J ] . \widehat{I}_{k,j}^{0}(\theta^{(2)}) = (K+j,\cdots,K+j) \ne I_{k,j}, \qquad\text{for all } k \in[K],\ j \in[J]. I k , j 0 ( θ ( 2 ) ) = ( K + j , ⋯ , K + j ) = I k , j , for all k ∈ [ K ] , j ∈ [ J ] .
(CFG recovers valid images.) There exists λ ∗ = Θ ( 1 ) \lambda^* = \Theta(1) λ ∗ = Θ ( 1 ) with λ ∗ > 0 \lambda^* > 0 λ ∗ > 0 such that CFG at guidance scale λ ∗ \lambda^* λ ∗ generates a valid image for every query:
I ^ k , j λ ∗ ( θ ( 2 ) ) = I k , j , for all k ∈ [ K ] , j ∈ [ J ] . \widehat{I}_{k,j}^{\lambda^*}(\theta^{(2)}) = I_{k,j}, \qquad\text{for all } k \in[K],\ j \in[J]. I k , j λ ∗ ( θ ( 2 ) ) = I k , j , for all k ∈ [ K ] , j ∈ [ J ] .
(Alignment of conditional and unconditional prediction.) The conditional model and unconditional model has the same prediction when generating image with guidance scale λ ∗ \lambda^* λ ∗ , which means
arg max x ∈ X v i s logit t c o n d = arg max x ∈ X v i s logit t u n c o n d \underset{x\in\mathcal{X}_{\mathrm{vis}}}{\arg\max}\ \operatorname{logit}^{\mathrm{cond}}_t
=
\underset{x\in\mathcal{X}_{\mathrm{vis}}}{\arg\max}\ \operatorname{logit}^{\mathrm{uncond}}_t x ∈ X vis arg max logit t cond = x ∈ X vis arg max logit t uncond
Proof Roadmap. We begin by outlining the roadmap for the proof of Theorem D.1 . Following the two-stage training procedure in Algorithm 2, we first analyze the update of W V ( 1 ) W_V^{(1)} W V ( 1 ) and then characterize the subsequent update of W Q K W_{QK} W Q K based on the first-stage results. We then demonstrate that the training loss is asymptotically minimized. Finally, we establish the model’s generation behavior: while the model successfully generates target images using CFG with a suitable guidance scale, it fails when restricted to conditional decoding. We also prove that the predictions of the conditional and unconditional branches remain aligned.
Steps 1–4 establish the first-stage parameter estimates: Step 1 computes the population gradient of W V W_V W V at initialization; Step 2 derives the asymptotic order of its coefficients; Step 3 verifies a pivotal asymptotic property induced by the parameter regime; and Step 4 converts these results into an explicit one-step approximation for W V ( 1 ) W_V^{(1)} W V ( 1 ) , analyzing how embeddings are projected into the value space. Step 5 examines the logits and probabilities induced by W V ( 1 ) W_V^{(1)} W V ( 1 ) , laying the groundwork for the second stage. Steps 6–7 analyze the population gradient and one-step update of W Q K W_{QK} W Q K , yielding an explicit approximation for W Q K ( 1 ) W_{QK}^{(1)} W Q K ( 1 ) and characterizing the computation of position-feature correlations. Step 8 leverages these estimates to analyze CFG behavior across different time regimes and defines the valid range for the guidance scale. Step 9 proves that the training loss is asymptotically small. Steps 10–11 establish our two generation claims: CFG-based decoding correctly generates the target image, whereas pure conditional decoding collapses into repetitive background patterns. Step 12 proves the alignment between conditional and unconditional predictions. Finally, Step 13 synthesizes these intermediate results to complete the proof of Theorem D.1 .
Step 1: Population Gradient of W V W_V W V at Initialization
To compute the first update in Algorithm 2, we first derive ∇ W V L v i s ( θ ( 0 ) ) \nabla_{W_V}\mathcal{L}_{\mathrm{vis}}(\theta^{(0)}) ∇ W V L vis ( θ ( 0 ) ) at initialization, where θ ( 0 ) = ( W V ( 0 ) , W Q K ( 0 ) ) = ( 0 , 0 ) \theta^{(0)} = (W_V^{(0)}, W_{QK}^{(0)}) = (0,0) θ ( 0 ) = ( W V ( 0 ) , W Q K ( 0 ) ) = ( 0 , 0 ) .
Lemma D.2 (Population gradient of W V W_V W V at initialization). At initialization of Algorithm 2, where θ ( 0 ) = ( W V ( 0 ) , W Q K ( 0 ) ) = ( 0 , 0 ) \theta^{(0)} = (W_V^{(0)}, W_{QK}^{(0)}) = (0,0) θ ( 0 ) = ( W V ( 0 ) , W Q K ( 0 ) ) = ( 0 , 0 ) , the population gradient is
∇ W V L v i s ( θ ( 0 ) ) = ∑ k = 1 K ∑ j = 1 J p k q j ∇ W V L ( k , j ; θ ( 0 ) ) , \nabla_{W_V}\mathcal{L}_{\mathrm{vis}}(\theta^{(0)}) =
\sum_{k=1}^{K}\sum_{j=1}^{J} p_k q_j \nabla_{W_V}\mathcal{L}(k,j;\theta^{(0)}), ∇ W V L vis ( θ ( 0 ) ) = k = 1 ∑ K j = 1 ∑ J p k q j ∇ W V L ( k , j ; θ ( 0 ) ) , where for each ( k , j ) (k,j) ( k , j ) ,
∇ W V L ( k , j ; θ ( 0 ) ) = f ˉ ( A K + J + k f K + J + k T + A k f k T + A K + j f K + j T ) − f K + J ( B K + J + k f K + J + k T + B k f k T + B K + j f K + j T ) − f k ( C K + J + k f K + J + k T + C k f k T + C K + j f K + j T ) , (9) \begin{aligned}
\nabla_{W_V}\mathcal{L}(k,j;\theta^{(0)}) ={}&
\bar{f}\left(A_{K+J+k}f_{K+J+k}^{\mathsf{T}} + A_kf_k^{\mathsf{T}} + A_{K+j}f_{K+j}^{\mathsf{T}}\right)\\
&-f_{K+J}\left(B_{K+J+k}f_{K+J+k}^{\mathsf{T}} + B_kf_k^{\mathsf{T}} + B_{K+j}f_{K+j}^{\mathsf{T}}\right)\\
&-f_k\left(C_{K+J+k}f_{K+J+k}^{\mathsf{T}} + C_kf_k^{\mathsf{T}} + C_{K+j}f_{K+j}^{\mathsf{T}}\right), \tag*{(9)}
\end{aligned} ∇ W V L ( k , j ; θ ( 0 ) ) = f ˉ ( A K + J + k f K + J + k T + A k f k T + A K + j f K + j T ) − f K + J ( B K + J + k f K + J + k T + B k f k T + B K + j f K + j T ) − f k ( C K + J + k f K + J + k T + C k f k T + C K + j f K + j T ) , (9)
for some positive constant A K + J + k , A k , A K + j , B K + J + k , B k , B K + j , C K + J + k , C k , C K + j A_{K+J+k}, A_k, A_{K+j}, B_{K+J+k}, B_k, B_{K+j}, C_{K+J+k}, C_k, C_{K+j} A K + J + k , A k , A K + j , B K + J + k , B k , B K + j , C K + J + k , C k , C K + j .
Proof. Uniform attention and uniform prediction at initialization. When W Q K = 0 W_{QK}=0 W Q K = 0 , because s t l = e t T W Q K f x l s_{tl}=e_t^{\mathsf{T}}W_{QK}f_{x_l} s tl = e t T W Q K f x l , all pre-softmax attention scores s t l s_{tl} s tl are zero, so the attention score α t l = 1 / ( t + 1 ) \alpha_{tl}=1/(t+1) α tl = 1/ ( t + 1 ) for all l = 0 , … , t l=0,\ldots,t l = 0 , … , t . When W V = 0 W_V=0 W V = 0 , o t = ∑ l = 0 t α t l W V f x l = 0 o_t=\sum_{l=0}^{t}\alpha_{tl}W_Vf_{x_l}=0 o t = ∑ l = 0 t α tl W V f x l = 0 for all t t t , hence
P t = sm ( [ 0 ] ) = 1 K + J 1 , g t = W l m δ t = f ˉ − f x t + 1 , f ˉ = 1 K + J ∑ a = 1 K + J f a . P_t=\operatorname{sm}([0])=\frac{1}{K+J}\mathbf{1},\qquad g_t=W_{\mathrm{lm}}\delta_t=\bar{f}-f_{x_{t+1}},\qquad\bar{f}=\frac{1}{K+J}\sum_{a=1}^{K+J}f_a. P t = sm ([ 0 ]) = K + J 1 1 , g t = W lm δ t = f ˉ − f x t + 1 , f ˉ = K + J 1 a = 1 ∑ K + J f a .
where 1 ∈ R K + J \mathbf{1}\in\mathbb{R}^{K+J} 1 ∈ R K + J denotes all one vector, 0 ∈ R K + J \mathbf{0}\in\mathbb{R}^{K+J} 0 ∈ R K + J denotes all zero vector, and the second equations holds because of the fixed languages model head W l m = [ f 1 , ⋯ f K + J ] W_{\mathrm{lm}}=[f_1,\cdots f_{K+J}] W lm = [ f 1 , ⋯ f K + J ] . The piecewise structure of f x t + 1 f_{x_{t+1}} f x t + 1 determined by the data model given visual feature class k ∈ [ K ] k\in[K] k ∈ [ K ] and visual background class j ∈ [ J ] j\in[J] j ∈ [ J ] is
f x t + 1 = { f K + j , 1 ≤ t ≤ τ − 2 , f k , τ − 1 ≤ t ≤ τ + L − 2 , f K + j , τ + L − 1 ≤ t ≤ T − 1. (10) f_{x_{t+1}}=
\begin{cases}
f_{K+j}, & 1\le t\le\tau-2,\\
f_k, & \tau-1\le t\le\tau+L-2,\\
f_{K+j}, & \tau+L-1\le t\le T-1.
\end{cases} \tag*{(10)} f x t + 1 = ⎩ ⎨ ⎧ f K + j , f k , f K + j , 1 ≤ t ≤ τ − 2 , τ − 1 ≤ t ≤ τ + L − 2 , τ + L − 1 ≤ t ≤ T − 1. (10)
Applying Eqn. (C.4) in Lemma C.1 with α t l = 1 / ( t + 1 ) \alpha_{tl}=1/(t+1) α tl = 1/ ( t + 1 ) , the gradient of the single-sequence loss L ( k , j ; θ ) \mathcal{L}(k,j;\theta) L ( k , j ; θ ) in Eqn. (C.2) at initialization is
∇ W V L ( k , j ; θ ( 0 ) ) = ∑ t = 1 T ∑ l = 0 t α t l g t f x l T = ∑ t = 1 T − 1 1 t + 1 g t ( ∑ l = 0 t f x l ) T . (11) \nabla_{W_V}\mathcal{L}(k,j;\theta^{(0)})=\sum_{t=1}^{T}\sum_{l=0}^{t}\alpha_{tl}g_tf_{x_l}^{\mathsf{T}}=\sum_{t=1}^{T-1}\frac{1}{t+1}g_t\left(\sum_{l=0}^{t}f_{x_l}\right)^{\mathsf{T}}. \tag*{(11)} ∇ W V L ( k , j ; θ ( 0 ) ) = t = 1 ∑ T l = 0 ∑ t α tl g t f x l T = t = 1 ∑ T − 1 t + 1 1 g t ( l = 0 ∑ t f x l ) T . (11)
Token prefix sum. Define the number of feature in prefix at position t t t as
n F ( t ) = ∣ { τ , … , τ + L − 1 } ∩ { 1 , … , t } ∣ = { 0 , t < τ , t − τ + 1 , τ ≤ t ≤ τ + L − 1 , L , t ≥ τ + L − 1. (12) n_F(t)=\left|\{\tau,\ldots,\tau+L-1\}\cap\{1,\ldots,t\}\right|=
\begin{cases}
0, & t<\tau,\\
t-\tau+1, & \tau\le t\le\tau+L-1,\\
L, & t\ge\tau+L-1.
\end{cases} \tag*{(12)} n F ( t ) = ∣ { τ , … , τ + L − 1 } ∩ { 1 , … , t } ∣ = ⎩ ⎨ ⎧ 0 , t − τ + 1 , L , t < τ , τ ≤ t ≤ τ + L − 1 , t ≥ τ + L − 1. (12)
Since position t = 0 t=0 t = 0 is the text token x 0 = K + J + k x_0=K+J+k x 0 = K + J + k for visual feature class k k k and all non-feature positions carry the same background token x t = K + j x_t=K+j x t = K + j for visual background class j j j , the prefix sum is
∑ l = 0 t f x l = f K + J + k + n F ( t ) f k + ( t − n F ( t ) ) f K + j . (13) \sum_{l=0}^{t}f_{x_l}=f_{K+J+k}+n_F(t)f_k+\left(t-n_F(t)\right)f_{K+j}. \tag*{(13)} l = 0 ∑ t f x l = f K + J + k + n F ( t ) f k + ( t − n F ( t ) ) f K + j . (13)
Expansion. Substituting Eqn. (D.5) into Eqn. (D.3) and expand g t = f ˉ − f x t + 1 g_t=\bar{f}-f_{x_{t+1}} g t = f ˉ − f x t + 1 gives
∇ W V L ( k , j ; θ ( 0 ) ) = ∑ t = 1 T − 1 1 t + 1 f ˉ f K + J + k T + ∑ t = 1 T − 1 n F ( t ) t + 1 f ˉ f k T + ∑ t = 1 T − 1 t − n F ( t ) t + 1 f ˉ f K + j T − ∑ t = 1 T − 1 1 t + 1 f x t + 1 f K + J + k T − ∑ t = 1 T − 1 n F ( t ) t + 1 f x t + 1 f k T − ∑ t = 1 T − 1 t − n F ( t ) t + 1 f x t + 1 f K + j T , \begin{aligned}
\nabla_{W_V}\mathcal{L}(k,j;\theta^{(0)})={}&\sum_{t=1}^{T-1}\frac{1}{t+1}\bar{f}f_{K+J+k}^{\mathsf{T}}+\sum_{t=1}^{T-1}\frac{n_F(t)}{t+1}\bar{f}f_k^{\mathsf{T}}+\sum_{t=1}^{T-1}\frac{t-n_F(t)}{t+1}\bar{f}f_{K+j}^{\mathsf{T}}\\
&-\sum_{t=1}^{T-1}\frac{1}{t+1}f_{x_{t+1}}f_{K+J+k}^{\mathsf{T}}-\sum_{t=1}^{T-1}\frac{n_F(t)}{t+1}f_{x_{t+1}}f_k^{\mathsf{T}}-\sum_{t=1}^{T-1}\frac{t-n_F(t)}{t+1}f_{x_{t+1}}f_{K+j}^{\mathsf{T}},
\end{aligned} ∇ W V L ( k , j ; θ ( 0 ) ) = t = 1 ∑ T − 1 t + 1 1 f ˉ f K + J + k T + t = 1 ∑ T − 1 t + 1 n F ( t ) f ˉ f k T + t = 1 ∑ T − 1 t + 1 t − n F ( t ) f ˉ f K + j T − t = 1 ∑ T − 1 t + 1 1 f x t + 1 f K + J + k T − t = 1 ∑ T − 1 t + 1 n F ( t ) f x t + 1 f k T − t = 1 ∑ T − 1 t + 1 t − n F ( t ) f x t + 1 f K + j T ,
where we decompose and group the terms into several sums of outer products. To investigate f x t + 1 f_{x_{t+1}} f x t + 1 within the summation, we then split each resulting time sum according to the next token:
B = { 1 , … , T − 1 } ∖ { τ − 1 , … , τ + L − 2 } , F = { τ − 1 , … , τ + L − 2 } . (14) \mathcal{B}=\{1,\ldots,T-1\}\setminus\{\tau-1,\ldots,\tau+L-2\},\qquad\mathcal{F}=\{\tau-1,\ldots,\tau+L-2\}. \tag*{(14)} B = { 1 , … , T − 1 } ∖ { τ − 1 , … , τ + L − 2 } , F = { τ − 1 , … , τ + L − 2 } . (14)
where on B \mathcal{B} B we have f x t + 1 = f K + j f_{x_{t+1}}=f_{K+j} f x t + 1 = f K + j , while on F \mathcal{F} F we have f x t + 1 = f k f_{x_{t+1}}=f_k f x t + 1 = f k . Grouping coefficients of the same outer products yields
∑ t = 1 T − 1 1 t + 1 f x t + 1 f K + J + k T = ( ∑ t ∈ B 1 t + 1 ) f K + j f K + J + k T + ( ∑ t ∈ F 1 t + 1 ) f k f K + J + k T , \sum_{t=1}^{T-1}\frac{1}{t+1}f_{x_{t+1}}f_{K+J+k}^{\mathsf{T}}=\left(\sum_{t\in\mathcal{B}}\frac{1}{t+1}\right)f_{K+j}f_{K+J+k}^{\mathsf{T}}+\left(\sum_{t\in\mathcal{F}}\frac{1}{t+1}\right)f_kf_{K+J+k}^{\mathsf{T}}, t = 1 ∑ T − 1 t + 1 1 f x t + 1 f K + J + k T = ( t ∈ B ∑ t + 1 1 ) f K + j f K + J + k T + ( t ∈ F ∑ t + 1 1 ) f k f K + J + k T ,
∑ t = 1 T − 1 n F ( t ) t + 1 f x t + 1 f k T = ( ∑ t ∈ B n F ( t ) t + 1 ) f K + j f k T + ( ∑ t ∈ F n F ( t ) t + 1 ) f k f k T , \sum_{t=1}^{T-1}\frac{n_{\mathcal{F}}(t)}{t+1}f_{x_{t+1}}f_k^{\mathsf{T}}=\left(\sum_{t\in\mathcal{B}}\frac{n_{\mathcal{F}}(t)}{t+1}\right)f_{K+j}f_k^{\mathsf{T}}+\left(\sum_{t\in\mathcal{F}}\frac{n_{\mathcal{F}}(t)}{t+1}\right)f_kf_k^{\mathsf{T}}, t = 1 ∑ T − 1 t + 1 n F ( t ) f x t + 1 f k T = ( t ∈ B ∑ t + 1 n F ( t ) ) f K + j f k T + ( t ∈ F ∑ t + 1 n F ( t ) ) f k f k T ,
∑ t = 1 T − 1 t − n F ( t ) t + 1 f x t + 1 f K + j T = ( ∑ t ∈ B t − n F ( t ) t + 1 ) f K + j f K + j T + ( ∑ t ∈ F t − n F ( t ) t + 1 ) f k f K + j T . \sum_{t=1}^{T-1}\frac{t-n_{\mathcal{F}}(t)}{t+1}f_{x_{t+1}}f_{K+j}^{\mathsf{T}}=\left(\sum_{t\in\mathcal{B}}\frac{t-n_{\mathcal{F}}(t)}{t+1}\right)f_{K+j}f_{K+j}^{\mathsf{T}}+\left(\sum_{t\in\mathcal{F}}\frac{t-n_{\mathcal{F}}(t)}{t+1}\right)f_kf_{K+j}^{\mathsf{T}}. t = 1 ∑ T − 1 t + 1 t − n F ( t ) f x t + 1 f K + j T = ( t ∈ B ∑ t + 1 t − n F ( t ) ) f K + j f K + j T + ( t ∈ F ∑ t + 1 t − n F ( t ) ) f k f K + j T .
So we plug group the terms in the summation according to their left factors in the outer product and get
∇ W V L ( k , j ; θ ( 0 ) ) = f ˉ ( A K + J + k f K + J + k T + A k f k T + A K + j f K + j T ) − f K + j ( B K + J + k f K + J + k T + B k f k T + B K + j f K + j T ) − f k ( C K + J + k f K + J + k T + C k f k T + C K + j f K + j T ) . \begin{aligned}
\nabla_{W_V}\mathcal{L}(k,j;\theta^{(0)})={}&\bar{f}\left(A_{K+J+k}f_{K+J+k}^{\mathsf{T}}+A_kf_k^{\mathsf{T}}+A_{K+j}f_{K+j}^{\mathsf{T}}\right)\\
&-f_{K+j}\left(B_{K+J+k}f_{K+J+k}^{\mathsf{T}}+B_kf_k^{\mathsf{T}}+B_{K+j}f_{K+j}^{\mathsf{T}}\right)\\
&-f_k\left(C_{K+J+k}f_{K+J+k}^{\mathsf{T}}+C_kf_k^{\mathsf{T}}+C_{K+j}f_{K+j}^{\mathsf{T}}\right).
\end{aligned} ∇ W V L ( k , j ; θ ( 0 ) ) = f ˉ ( A K + J + k f K + J + k T + A k f k T + A K + j f K + j T ) − f K + j ( B K + J + k f K + J + k T + B k f k T + B K + j f K + j T ) − f k ( C K + J + k f K + J + k T + C k f k T + C K + j f K + j T ) .
where the coefficients can be interpreted as the learned association strengths from specific input features to target features, mediated by the linear transformation W V W_V W V prior to their aggregation via the attention mechanism. A K + J + k , A k , A K + j A_{K+J+k}, A_k, A_{K+j} A K + J + k , A k , A K + j means the contribution from f K + J + k , f k , f K + j f_{K+J+k}, f_k, f_{K+j} f K + J + k , f k , f K + j to f ˉ \bar{f} f ˉ . B K + J + k , B k , B K + j B_{K+J+k}, B_k, B_{K+j} B K + J + k , B k , B K + j means the contribution from f K + J + k , f k , f K + j f_{K+J+k}, f_k, f_{K+j} f K + J + k , f k , f K + j to f K + j f_{K+j} f K + j . C K + J + k , C k , C K + j C_{K+J+k}, C_k, C_{K+j} C K + J + k , C k , C K + j means the contribution from f K + J + k , f k , f K + j f_{K+J+k}, f_k, f_{K+j} f K + J + k , f k , f K + j to f k f_k f k . We can further derive the closed form of these coefficient as follows:
A K + J + k = ∑ t = 1 T − 1 1 t + 1 , A k = ∑ t = 1 T − 1 n F ( t ) t + 1 , A K + j = ∑ t = 1 T − 1 t − n F ( t ) t + 1 , B K + J + k = ∑ t ∈ B 1 t + 1 , B k = ∑ t ∈ B n F ( t ) t + 1 , B K + j = ∑ t ∈ B t − n F ( t ) t + 1 , C K + J + k = ∑ t ∈ F 1 t + 1 , C k = ∑ t ∈ F n F ( t ) t + 1 , C K + j = ∑ t ∈ F t − n F ( t ) t + 1 . (15) \begin{aligned}
A_{K+J+k}&=\sum_{t=1}^{T-1}\frac{1}{t+1},\quad A_k=\sum_{t=1}^{T-1}\frac{n_{\mathcal{F}}(t)}{t+1},\quad A_{K+j}=\sum_{t=1}^{T-1}\frac{t-n_{\mathcal{F}}(t)}{t+1},\\
B_{K+J+k}&=\sum_{t\in\mathcal{B}}\frac{1}{t+1},\quad B_k=\sum_{t\in\mathcal{B}}\frac{n_{\mathcal{F}}(t)}{t+1},\quad B_{K+j}=\sum_{t\in\mathcal{B}}\frac{t-n_{\mathcal{F}}(t)}{t+1},\\
C_{K+J+k}&=\sum_{t\in\mathcal{F}}\frac{1}{t+1},\quad C_k=\sum_{t\in\mathcal{F}}\frac{n_{\mathcal{F}}(t)}{t+1},\quad C_{K+j}=\sum_{t\in\mathcal{F}}\frac{t-n_{\mathcal{F}}(t)}{t+1}. \tag*{(15)}
\end{aligned} A K + J + k B K + J + k C K + J + k = t = 1 ∑ T − 1 t + 1 1 , A k = t = 1 ∑ T − 1 t + 1 n F ( t ) , A K + j = t = 1 ∑ T − 1 t + 1 t − n F ( t ) , = t ∈ B ∑ t + 1 1 , B k = t ∈ B ∑ t + 1 n F ( t ) , B K + j = t ∈ B ∑ t + 1 t − n F ( t ) , = t ∈ F ∑ t + 1 1 , C k = t ∈ F ∑ t + 1 n F ( t ) , C K + j = t ∈ F ∑ t + 1 t − n F ( t ) . (15)
which is a results of direct computation from the previous expansion. From the closed form in Eqn. (C.3), we have
∇ W V L v i s ( θ ( 0 ) ) = ∑ k = 1 K ∑ j = 1 J p k q j ∇ W V L ( k , j ; θ ( 0 ) ) . \nabla_{W_V}\mathcal{L}_{\mathrm{vis}}(\theta^{(0)})=\sum_{k=1}^{K}\sum_{j=1}^{J}p_kq_j\nabla_{W_V}\mathcal{L}(k,j;\theta^{(0)}). ∇ W V L vis ( θ ( 0 ) ) = k = 1 ∑ K j = 1 ∑ J p k q j ∇ W V L ( k , j ; θ ( 0 ) ) .
Thus, we conclude the proof of Lemma D.2.
Step 2: Asymptotic Oder of Coefficients
In this step, we derive the asymptotic order of the embedding coefficients in Lemma D.2, which is crucial for our subsequent analysis.
Proposition D.3 (Asymptotic Order of B B B , C C C coefficients). Under assumptions in Theorem D.1, the asymptotic order of coefficients B K + J + k , B k , B K + j , C K + J + k , C k , C K + j B_{K+J+k}, B_k, B_{K+j}, C_{K+J+k}, C_k, C_{K+j} B K + J + k , B k , B K + j , C K + J + k , C k , C K + j in Lemma D.2 are
B K + J + k = Θ ( log T ) , B k = Θ ( ( log T ) 2 ) , B K + j = Θ ( T ) , B_{K+J+k}=\Theta(\log T),\quad B_k=\Theta((\log T)^2),\quad B_{K+j}=\Theta(T), B K + J + k = Θ ( log T ) , B k = Θ (( log T ) 2 ) , B K + j = Θ ( T ) , C K + J + k = Θ ( log T T β ) , C k = Θ ( ( log T ) 2 T β ) , C K + j = Θ ( log T ) . (16) C_{K+J+k}=\Theta\left(\frac{\log T}{T^\beta}\right),\quad C_k=\Theta\left(\frac{(\log T)^2}{T^\beta}\right),\quad C_{K+j}=\Theta(\log T). \tag*{(16)} C K + J + k = Θ ( T β log T ) , C k = Θ ( T β ( log T ) 2 ) , C K + j = Θ ( log T ) . (16)
Proof. Let H n = ∑ i = 1 n 1 / i H_n=\sum_{i=1}^{n}1/i H n = ∑ i = 1 n 1/ i denote the n n n -th harmonic number, and H n = log n + γ + O ( 1 / n ) H_n=\log n+\gamma+O(1/n) H n = log n + γ + O ( 1/ n ) .
Order of C K + J + k C_{K+J+k} C K + J + k . From the closed form of coefficient in Eqn. (D.7), we have
C K + J + k = ∑ t ∈ F 1 t + 1 = ∑ r = 0 L − 1 1 τ + r = L τ ( 1 + o ( 1 ) ) = Θ ( log T T β ) . C_{K+J+k}=\sum_{t\in\mathcal{F}}\frac{1}{t+1}=\sum_{r=0}^{L-1}\frac{1}{\tau+r}=\frac{L}{\tau}(1+o(1))=\Theta\left(\frac{\log T}{T^\beta}\right). C K + J + k = t ∈ F ∑ t + 1 1 = r = 0 ∑ L − 1 τ + r 1 = τ L ( 1 + o ( 1 )) = Θ ( T β log T ) .
where the second equation comes from expansion using Eqn. (D.6), the third and fourth equation come from assumption L = Θ ( log T ) , τ = Θ ( T β ) L=\Theta(\log T),\tau=\Theta(T^\beta) L = Θ ( log T ) , τ = Θ ( T β ) .
Order of B K + J + k B_{K+J+k} B K + J + k . From the closed form in Eqn. (D.7), we have
B K + J + k = ∑ t ∈ B 1 t + 1 = ∑ t = τ + L − 1 T − 1 1 t + 1 − ∑ t = τ − 1 τ + L − 2 1 t + 1 = ( H τ − 1 − H 1 ) + ( H T − H τ + L − 1 ) , B_{K+J+k}=\sum_{t\in\mathcal{B}}\frac{1}{t+1}=\sum_{t=\tau+L-1}^{T-1}\frac{1}{t+1}-\sum_{t=\tau-1}^{\tau+L-2}\frac{1}{t+1}=(H_{\tau-1}-H_1)+(H_T-H_{\tau+L-1}), B K + J + k = t ∈ B ∑ t + 1 1 = t = τ + L − 1 ∑ T − 1 t + 1 1 − t = τ − 1 ∑ τ + L − 2 t + 1 1 = ( H τ − 1 − H 1 ) + ( H T − H τ + L − 1 ) ,
where the second equation comes from Eqn. (D.6), and the third equation rewrites the terms as a harmonic sum. Expand it via the harmonic approximation,
B K + J + k = log τ + O ( 1 ) + log T − log ( τ + L − 1 ) + O ( 1 ) = Θ ( log T ) , B_{K+J+k}=\log\tau+O(1)+\log T-\log(\tau+L-1)+O(1)=\Theta(\log T), B K + J + k = log τ + O ( 1 ) + log T − log ( τ + L − 1 ) + O ( 1 ) = Θ ( log T ) ,
where the last equation comes from assumption L = Θ ( log T ) , τ = Θ ( T β ) L=\Theta(\log T),\tau=\Theta(T^\beta) L = Θ ( log T ) , τ = Θ ( T β ) .
Order of C k C_k C k . From the closed form in Eqn. (D.7), we have
C k = ∑ t ∈ F n F ( t ) t + 1 = ∑ t = τ τ + L − 2 t − τ + 1 t + 1 = ( L − 1 ) − τ ∑ r = 1 L − 1 1 τ + r , C_k=\sum_{t\in\mathcal{F}}\frac{n_F(t)}{t+1}=\sum_{t=\tau}^{\tau+L-2}\frac{t-\tau+1}{t+1}=(L-1)-\tau\sum_{r=1}^{L-1}\frac{1}{\tau+r}, C k = t ∈ F ∑ t + 1 n F ( t ) = t = τ ∑ τ + L − 2 t + 1 t − τ + 1 = ( L − 1 ) − τ r = 1 ∑ L − 1 τ + r 1 ,
where the second equation uses the results in Eqn. (D.4) and Eqn. (D.6), the third equation is a direct expansion. Using Taylor expansion 1 / ( τ + r ) = 1 / τ − r / τ 2 + O ( r 2 / τ 3 ) 1/(\tau+r)=1/\tau-r/\tau^2+O(r^2/\tau^3) 1/ ( τ + r ) = 1/ τ − r / τ 2 + O ( r 2 / τ 3 ) , we have
∑ r = 1 L − 1 1 τ + r = L − 1 τ − L ( L − 1 ) 2 τ 2 + O ( L 3 τ 3 ) , \sum_{r=1}^{L-1}\frac{1}{\tau+r}=\frac{L-1}{\tau}-\frac{L(L-1)}{2\tau^2}+O\left(\frac{L^3}{\tau^3}\right), r = 1 ∑ L − 1 τ + r 1 = τ L − 1 − 2 τ 2 L ( L − 1 ) + O ( τ 3 L 3 ) ,
and plug it in the previous results, we have
C k = ( L − 1 ) − τ ∑ r = 1 L − 1 1 τ + r = L ( L − 1 ) 2 τ + O ( L 3 τ 2 ) = Θ ( ( log T ) 2 T β ) , C_k=(L-1)-\tau\sum_{r=1}^{L-1}\frac{1}{\tau+r}=\frac{L(L-1)}{2\tau}+O\left(\frac{L^3}{\tau^2}\right)=\Theta\left(\frac{(\log T)^2}{T^\beta}\right), C k = ( L − 1 ) − τ r = 1 ∑ L − 1 τ + r 1 = 2 τ L ( L − 1 ) + O ( τ 2 L 3 ) = Θ ( T β ( log T ) 2 ) ,
where the last equation comes from assumption L = Θ ( log T ) , τ = Θ ( T β ) L=\Theta(\log T),\tau=\Theta(T^\beta) L = Θ ( log T ) , τ = Θ ( T β ) .
Order of B k B_k B k . From the closed form in Eqn. (D.7), we have
B k = ∑ t ∈ B n F ( t ) t + 1 = ∑ t = τ + L − 1 T − 1 L t + 1 = L ( H T − H τ + L − 1 ) = L ( log T − log ( τ + L − 1 ) + O ( 1 ) ) , B_k=\sum_{t\in\mathcal{B}}\frac{n_F(t)}{t+1}=\sum_{t=\tau+L-1}^{T-1}\frac{L}{t+1}=L(H_T-H_{\tau+L-1})=L\left(\log T-\log(\tau+L-1)+O(1)\right), B k = t ∈ B ∑ t + 1 n F ( t ) = t = τ + L − 1 ∑ T − 1 t + 1 L = L ( H T − H τ + L − 1 ) = L ( log T − log ( τ + L − 1 ) + O ( 1 ) ) ,
where the second equation uses the results in Eqn. (D.4) and Eqn. (D.6), the third equation rewrites the terms as harmonic sum, and the fourth equation uses the approximation results of harmonic sum. Using the assumption that L = Θ ( log T ) , τ = Θ ( T β ) L=\Theta(\log T),\tau=\Theta(T^\beta) L = Θ ( log T ) , τ = Θ ( T β ) , we have log ( τ + L − 1 ) = β log T + O ( 1 ) \log(\tau+L-1)=\beta\log T+O(1) log ( τ + L − 1 ) = β log T + O ( 1 ) , so plug it in the previous results, we have
B k = L ( ( 1 − β ) log T + O ( 1 ) ) = Θ ( ( log T ) 2 ) . B_k=L\left((1-\beta)\log T+O(1)\right)=\Theta((\log T)^2). B k = L ( ( 1 − β ) log T + O ( 1 ) ) = Θ (( log T ) 2 ) .
Order of C K + j C_{K+j} C K + j . From the closed form in Eqn. (D.7), we have
C K + j = ∑ t ∈ F t − n F ( t ) t + 1 = ∑ t = τ − 1 τ + L − 2 t − n F ( t ) t + 1 = τ − 1 τ + 1 + ∑ t = τ τ + L − 2 t − t + τ − 1 t + 1 = ( τ − 1 ) ∑ t = τ − 1 τ + L − 2 1 t + 1 (17) C_{K+j}=\sum_{t\in\mathcal{F}}\frac{t-n_F(t)}{t+1}=\sum_{t=\tau-1}^{\tau+L-2}\frac{t-n_F(t)}{t+1}=\frac{\tau-1}{\tau+1}+\sum_{t=\tau}^{\tau+L-2}\frac{t-t+\tau-1}{t+1}=(\tau-1)\sum_{t=\tau-1}^{\tau+L-2}\frac{1}{t+1} \tag*{(17)} C K + j = t ∈ F ∑ t + 1 t − n F ( t ) = t = τ − 1 ∑ τ + L − 2 t + 1 t − n F ( t ) = τ + 1 τ − 1 + t = τ ∑ τ + L − 2 t + 1 t − t + τ − 1 = ( τ − 1 ) t = τ − 1 ∑ τ + L − 2 t + 1 1 (17)
where the second equation uses the results in Eqn. (D.6), the third equation uses the results in Eqn. (D.4), the fourth equation is a direct computation. Reorganize the summation, we have
C K + j = ( τ − 1 ) ∑ r = 0 L − 1 1 τ + r = ( τ − 1 ) ⋅ L τ ( 1 + o ( 1 ) ) = Θ ( L ) = Θ ( log T ) , C_{K+j}=(\tau-1)\sum_{r=0}^{L-1}\frac{1}{\tau+r}=(\tau-1)\cdot\frac{L}{\tau}(1+o(1))=\Theta(L)=\Theta(\log T), C K + j = ( τ − 1 ) r = 0 ∑ L − 1 τ + r 1 = ( τ − 1 ) ⋅ τ L ( 1 + o ( 1 )) = Θ ( L ) = Θ ( log T ) ,
where the last two equations use the assumption that L = Θ ( log T ) L=\Theta(\log T) L = Θ ( log T ) , τ = Θ ( T β ) \tau=\Theta(T^\beta) τ = Θ ( T β ) .
Order of B K + j B_{K+j} B K + j . From the closed form in Eqn. (D.7), we have
B K + j = ∑ t ∈ B t − n F ( t ) t + 1 = ∑ t = 1 τ − 2 t t + 1 + ∑ t = τ + L − 1 T − 1 t − L t + 1 = ( T − L − 1 ) − ( H τ − 1 − H 1 ) − ( L + 1 ) ( H T − H τ + L − 1 ) = Θ ( T ) \begin{aligned}
B_{K+j}=\sum_{t\in\mathcal{B}}\frac{t-n_F(t)}{t+1} \\
&=\sum_{t=1}^{\tau-2}\frac{t}{t+1}+\sum_{t=\tau+L-1}^{T-1}\frac{t-L}{t+1} \\
&=(T-L-1)-(H_{\tau-1}-H_1)-(L+1)(H_T-H_{\tau+L-1}) \\
&=\Theta(T)
\end{aligned} B K + j = t ∈ B ∑ t + 1 t − n F ( t ) = t = 1 ∑ τ − 2 t + 1 t + t = τ + L − 1 ∑ T − 1 t + 1 t − L = ( T − L − 1 ) − ( H τ − 1 − H 1 ) − ( L + 1 ) ( H T − H τ + L − 1 ) = Θ ( T )
where the second equation uses results in Eqn. (D.4) and Eqn. (D.6), and the third equation rewrites the terms as harmonic sum. The fourth equation uses assumption L = Θ ( log T ) L=\Theta(\log T) L = Θ ( log T ) , τ = Θ ( T β ) \tau=\Theta(T^\beta) τ = Θ ( T β ) , to get T − L − 1 = Θ ( T ) T-L-1=\Theta(T) T − L − 1 = Θ ( T ) , H τ − 1 − H 1 = Θ ( log T ) H_{\tau-1}-H_1=\Theta(\log T) H τ − 1 − H 1 = Θ ( log T ) , and ( L + 1 ) ( H T − H τ + L − 1 ) = Θ ( ( log T ) 2 ) (L+1)(H_T-H_{\tau+L-1})=\Theta((\log T)^2) ( L + 1 ) ( H T − H τ + L − 1 ) = Θ (( log T ) 2 ) , thus we can conclude that B K + j = Θ ( T ) B_{K+j}=\Theta(T) B K + j = Θ ( T ) .
Thus, we conclude the proof of Proposition D.3 . □
Step 3: Asymptotic Sandwich Property
We now verify that, under the parameter regime of Theorem D.1 , q j q_j q j is asymptotically sandwiched between the two critical ratios C K + J + k / B K + J + k C_{K+J+k}/B_{K+J+k} C K + J + k / B K + J + k and C k / B k C_k/B_k C k / B k . Specifically, we show that q j B K + J + k > C K + J + k q_jB_{K+J+k}>C_{K+J+k} q j B K + J + k > C K + J + k and q j B k < C k q_jB_k<C_k q j B k < C k for sufficiently large T T T . These conditions are pivotal for the subsequent analysis, as they ensure that the projection via W V ( 1 ) W_V^{(1)} W V ( 1 ) maps f K + J + k f_{K+J+k} f K + J + k predominantly to background tokens, while preserving f k f_k f k as itself.
Proposition D.4 (Asymptotic sandwich on q j q_j q j ). Under the assumptions of Theorem D.1 , we know that q j = 1 / J q_j=1/J q j = 1/ J , with J = ⌈ τ log T / c L ⌉ J=\left\lceil\tau\log T/cL\right\rceil J = ⌈ τ log T / c L ⌉ for some constant c ∈ ( 1 , L − 1 2 ( 1 − β ) L ) c\in\left(1,\frac{L-1}{2(1-\beta)L}\right) c ∈ ( 1 , 2 ( 1 − β ) L L − 1 ) . Then, for sufficiently large T T T ,
C K + J + k B K + J + k < q j < C k B k . \frac{C_{K+J+k}}{B_{K+J+k}}<q_j<\frac{C_k}{B_k}. B K + J + k C K + J + k < q j < B k C k .
Proof. Using the exact expressions from Proposition D.3 , we compute the two ratio bounds:
C K + J + k B K + J + k = L τ ( 1 + o ( 1 ) ) log T + O ( 1 ) = L τ log T + o ( 1 ) , \frac{C_{K+J+k}}{B_{K+J+k}}=\frac{\frac{L}{\tau}(1+o(1))}{\log T+O(1)}=\frac{L}{\tau\log T}+o(1), B K + J + k C K + J + k = log T + O ( 1 ) τ L ( 1 + o ( 1 )) = τ log T L + o ( 1 ) ,
C k B k = L ( L − 1 ) 2 τ + O ( L 3 / τ 2 ) L ( 1 − β ) log T + O ( 1 ) = L − 1 2 ( 1 − β ) τ log T + o ( 1 ) , \frac{C_k}{B_k}=\frac{\frac{L(L-1)}{2\tau}+O(L^3/\tau^2)}{L(1-\beta)\log T+O(1)}=\frac{L-1}{2(1-\beta)\tau\log T}+o(1), B k C k = L ( 1 − β ) log T + O ( 1 ) 2 τ L ( L − 1 ) + O ( L 3 / τ 2 ) = 2 ( 1 − β ) τ log T L − 1 + o ( 1 ) ,
where for both row, the first equations come from the closed form in proof of Proposition D.3 , and the second equations use the asymptotic results in Eqn. (D.8). Since q j = 1 / J q_j=1/J q j = 1/ J , with J = ⌈ τ log T / c L ⌉ J=\lceil\tau\log T/cL\rceil J = ⌈ τ log T / c L ⌉ , when c ∈ ( 1 , L − 1 2 ( 1 − β ) L ) c\in\left(1,\frac{L-1}{2(1-\beta)L}\right) c ∈ ( 1 , 2 ( 1 − β ) L L − 1 ) , we know that
L τ log T < c L τ log T < L − 1 2 ( 1 − β ) L L τ log T = L − 1 2 ( 1 − β ) τ log T , (18) \frac{L}{\tau\log T}<\frac{cL}{\tau\log T}<\frac{L-1}{2(1-\beta)L}\frac{L}{\tau\log T}=\frac{L-1}{2(1-\beta)\tau\log T}, \tag*{(18)} τ log T L < τ log T c L < 2 ( 1 − β ) L L − 1 τ log T L = 2 ( 1 − β ) τ log T L − 1 , (18)
so C K + J + k / B K + J + k < q j < C k / B k C_{K+J+k}/B_{K+J+k}<q_j<C_k/B_k C K + J + k / B K + J + k < q j < C k / B k holds for sufficiently large T T T . Equivalently, we know q j B K + J + k > C K + J + k q_jB_{K+J+k}>C_{K+J+k} q j B K + J + k > C K + J + k and q j B k < C k q_jB_k<C_k q j B k < C k .
Because when β ∈ ( 1 / 2 , 1 ) \beta\in(1/2,1) β ∈ ( 1/2 , 1 ) , the upper bound satisfies L − 1 2 ( 1 − β ) L → 1 2 ( 1 − β ) > 1 \frac{L-1}{2(1-\beta)L}\to\frac{1}{2(1-\beta)}>1 2 ( 1 − β ) L L − 1 → 2 ( 1 − β ) 1 > 1 as L → ∞ L\to\infty L → ∞ , such a constant c c c exists. Because L = Θ ( log T ) L=\Theta(\log T) L = Θ ( log T ) , the interval is non-empty for sufficiently large T T T .
Thus, we conclude the proof of Proposition D.3 . □
Step 4: One-Step Update of W V W_V W V
Now we compute W V ( 1 ) W_V^{(1)} W V ( 1 ) , and analyze the projection of embeddings into the value space via it.
Lemma D.5 (Projection of embeddings via W V ( 1 ) W_V^{(1)} W V ( 1 ) ). After the first step update in Algorithm 2, the value matrix is
W V ( 1 ) = − η V ∑ k = 1 K p k ∑ j = 1 J q j ∇ W V L ( k , j ; θ ( 0 ) ) . W_V^{(1)}=-\eta_V\sum_{k=1}^{K}p_k\sum_{j=1}^{J}q_j\nabla_{W_V}\mathcal{L}(k,j;\theta^{(0)}). W V ( 1 ) = − η V k = 1 ∑ K p k j = 1 ∑ J q j ∇ W V L ( k , j ; θ ( 0 ) ) . Projecting f K + j 1 f_{K+j_1} f K + j 1 , f k 1 f_{k_1} f k 1 , and f K + J + k 1 f_{K+J+k_1} f K + J + k 1 , with feature class k 1 ∈ [ K ] k_1\in[K] k 1 ∈ [ K ] , background class j 1 ∈ [ J ] j_1\in[J] j 1 ∈ [ J ] , into the value space via W V W_V W V yields:
W V ( 1 ) f K + j 1 = η V [ − q j 1 A K + j 1 f ˉ + q j 1 B K + j 1 f K + j 1 + q j 1 C K + j 1 ∑ k p k f k ] W_V^{(1)}f_{K+j_1}=\eta_V\left[-q_{j_1}A_{K+j_1}\bar{f}+q_{j_1}B_{K+j_1}f_{K+j_1}+q_{j_1}C_{K+j_1}\sum_k p_kf_k\right] W V ( 1 ) f K + j 1 = η V [ − q j 1 A K + j 1 f ˉ + q j 1 B K + j 1 f K + j 1 + q j 1 C K + j 1 k ∑ p k f k ] W V ( 1 ) f k 1 = η V [ − p k 1 A k 1 f ˉ + p k 1 ∑ j q j B k 1 f K + j + p k 1 C k 1 f k 1 ] W_V^{(1)}f_{k_1}=\eta_V\left[-p_{k_1}A_{k_1}\bar{f}+p_{k_1}\sum_jq_jB_{k_1}f_{K+j}+p_{k_1}C_{k_1}f_{k_1}\right] W V ( 1 ) f k 1 = η V [ − p k 1 A k 1 f ˉ + p k 1 j ∑ q j B k 1 f K + j + p k 1 C k 1 f k 1 ] W V ( 1 ) f K + J + k 1 = η V [ − p k 1 A K + J + k 1 f ˉ + p k 1 ∑ j q j B K + J + k 1 f K + j + p k 1 C K + J + k 1 f k 1 ] . W_V^{(1)}f_{K+J+k_1}=\eta_V\left[-p_{k_1}A_{K+J+k_1}\bar{f}+p_{k_1}\sum_jq_jB_{K+J+k_1}f_{K+j}+p_{k_1}C_{K+J+k_1}f_{k_1}\right]. W V ( 1 ) f K + J + k 1 = η V [ − p k 1 A K + J + k 1 f ˉ + p k 1 j ∑ q j B K + J + k 1 f K + j + p k 1 C K + J + k 1 f k 1 ] .
Proof. The first step gradient descent in Algorithm 2 using population loss will help us get
W V ( 1 ) = 0 − η V ∇ W V L v i s ( θ ( 0 ) ) = − η V ∑ k = 1 K p k ∑ j = 1 J q j ∇ W V L ( k , j ; θ ( 0 ) ) . W_V^{(1)}=0-\eta_V\nabla_{W_V}\mathcal{L}_{\mathrm{vis}}(\theta^{(0)})=-\eta_V\sum_{k=1}^{K}p_k\sum_{j=1}^{J}q_j\nabla_{W_V}\mathcal{L}(k,j;\theta^{(0)}). W V ( 1 ) = 0 − η V ∇ W V L vis ( θ ( 0 ) ) = − η V k = 1 ∑ K p k j = 1 ∑ J q j ∇ W V L ( k , j ; θ ( 0 ) ) .
which is a direct expansion using the results in Lemma D.2. For k 1 ∈ [ K ] k_1\in[K] k 1 ∈ [ K ] , j 1 ∈ [ J ] j_1\in[J] j 1 ∈ [ J ] , We can analyze the projection of an embedding into the value space via the weight matrix W V ( 1 ) W_V^{(1)} W V ( 1 ) .
For W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 , we have
W V ( 1 ) f K + j 1 = − η V ∑ k p k ∑ j q j ∇ W V L ( k , j ; θ ( 0 ) ) f K + j 1 = η V [ − q j 1 A K + j 1 f ˉ + q j 1 B K + j 1 f K + j 1 + q j 1 C K + j 1 ∑ k p k f k ] . \begin{aligned}
W_V^{(1)}f_{K+j_1}=-\eta_V\sum_kp_k\sum_jq_j\nabla_{W_V}\mathcal{L}(k,j;\theta^{(0)})f_{K+j_1} \\
&=\eta_V\left[-q_{j_1}A_{K+j_1}\bar{f}+q_{j_1}B_{K+j_1}f_{K+j_1}+q_{j_1}C_{K+j_1}\sum_kp_kf_k\right].
\end{aligned} W V ( 1 ) f K + j 1 = − η V k ∑ p k j ∑ q j ∇ W V L ( k , j ; θ ( 0 ) ) f K + j 1 = η V [ − q j 1 A K + j 1 f ˉ + q j 1 B K + j 1 f K + j 1 + q j 1 C K + j 1 k ∑ p k f k ] .
where the second equality comes from expansion of ∇ W V L ( k , j ; θ ( 0 ) ) \nabla_{W_V}\mathcal{L}(k,j;\theta^{(0)}) ∇ W V L ( k , j ; θ ( 0 ) ) using Lemma D.2, and direct computation using the orthonormality of embeddings and property ∑ k = 1 K p k = 1 , ∑ j = 1 J q j = 1 \sum_{k=1}^{K}p_k=1,\sum_{j=1}^{J}q_j=1 ∑ k = 1 K p k = 1 , ∑ j = 1 J q j = 1 .
Similarly, we apply the same technique to expand W V ( 1 ) f k 1 W_V^{(1)}f_{k_1} W V ( 1 ) f k 1 , W V ( 1 ) f K + J + k 1 W_V^{(1)}f_{K+J+k_1} W V ( 1 ) f K + J + k 1 and can get
W V ( 1 ) f k 1 = η V [ − p k 1 A k 1 f ˉ + p k 1 ∑ j q j B k 1 f K + j + p k 1 C k 1 f k 1 ] , W_V^{(1)}f_{k_1}=\eta_V\left[-p_{k_1}A_{k_1}\bar{f}+p_{k_1}\sum_jq_jB_{k_1}f_{K+j}+p_{k_1}C_{k_1}f_{k_1}\right], W V ( 1 ) f k 1 = η V [ − p k 1 A k 1 f ˉ + p k 1 j ∑ q j B k 1 f K + j + p k 1 C k 1 f k 1 ] ,
W V ( 1 ) f K + J + k 1 = η V [ − p k 1 A K + J + k 1 f ˉ + p k 1 ∑ j q j B K + J + k 1 f K + j + p k 1 C K + J + k 1 f k 1 ] . W_V^{(1)}f_{K+J+k_1}=\eta_V\left[-p_{k_1}A_{K+J+k_1}\bar{f}+p_{k_1}\sum_jq_jB_{K+J+k_1}f_{K+j}+p_{k_1}C_{K+J+k_1}f_{k_1}\right]. W V ( 1 ) f K + J + k 1 = η V [ − p k 1 A K + J + k 1 f ˉ + p k 1 j ∑ q j B K + J + k 1 f K + j + p k 1 C K + J + k 1 f k 1 ] .
Thus, we conclude the proof of Lemma D.5 .
Step 5: Logits and Probabilities under W V ( 1 ) W_V^{(1)} W V ( 1 )
After knowing how W V ( 1 ) W_V^{(1)} W V ( 1 ) works, we can analyze the logits and probabilities of the model after the frist update, which is crucial for the analysis of the second update.
Lemma D.6 (Logits of tokens after First step update). With the parameter after the first step optimization θ ( 1 ) = ( W V ( 1 ) , 0 ) \theta^{(1)} = (W_V^{(1)}, 0) θ ( 1 ) = ( W V ( 1 ) , 0 ) , when the input is an image with visual feature class k 1 ∈ [ K ] k_1 \in[K] k 1 ∈ [ K ] and visual background class j 1 ∈ [ J ] j_1 \in[J] j 1 ∈ [ J ] , i.e. x 0 = K + J + k 1 x_0 = K + J + k_1 x 0 = K + J + k 1 and x 1 : T ∈ I k 1 , j 1 x_{1:T} \in\mathcal{I}_{k_1,j_1} x 1 : T ∈ I k 1 , j 1 , logit t ∈ R K + J \operatorname{logit}_t \in\mathbb{R}^{K+J} logit t ∈ R K + J satisfies
logit t [ k ] = A ~ ( t ) + η V t + 1 p k q j 1 ( t − n F ( t ) ) C K + j 1 , k ∈ [ K ] , k ≠ k 1 , \operatorname{logit}_t[k] = \widetilde{A}(t) + \frac{\eta_V}{t+1}p_{kq_{j_1}}(t-n_F(t))C_{K+j_1}, \qquad k \in[K], k \ne k_1, logit t [ k ] = A ( t ) + t + 1 η V p k q j 1 ( t − n F ( t )) C K + j 1 , k ∈ [ K ] , k = k 1 , logit t [ k 1 ] = A ~ ( t ) + η V t + 1 p k 1 ( q j 1 ( t − n F ( t ) ) C K + j 1 + C K + J + k 1 + n F ( t ) C k 1 ) , \operatorname{logit}_t[k_1] = \widetilde{A}(t) + \frac{\eta_V}{t+1}p_{k_1}\left(q_{j_1}(t-n_F(t))C_{K+j_1}+C_{K+J+k_1}+n_F(t)C_{k_1}\right), logit t [ k 1 ] = A ( t ) + t + 1 η V p k 1 ( q j 1 ( t − n F ( t )) C K + j 1 + C K + J + k 1 + n F ( t ) C k 1 ) , logit t [ K + j ] = A ~ ( t ) + η V t + 1 q j [ p k 1 ( B K + J + k 1 + n F ( t ) B k 1 ) ] , j ∈ [ J ] , j ≠ j 1 , \operatorname{logit}_t[K+j] = \widetilde{A}(t) + \frac{\eta_V}{t+1}q_j\left[p_{k_1}\left(B_{K+J+k_1}+n_F(t)B_{k_1}\right)\right], \qquad j \in[J], j \ne j_1, logit t [ K + j ] = A ( t ) + t + 1 η V q j [ p k 1 ( B K + J + k 1 + n F ( t ) B k 1 ) ] , j ∈ [ J ] , j = j 1 , logit t [ K + j 1 ] = A ~ ( t ) + η V t + 1 q j 1 [ p k 1 ( B K + J + k 1 + n F ( t ) B k 1 ) ] + η V t + 1 ( t − n F ( t ) ) q j 1 B K + j 1 , \operatorname{logit}_t[K+j_1] = \widetilde{A}(t) + \frac{\eta_V}{t+1}q_{j_1}\left[p_{k_1}\left(B_{K+J+k_1}+n_F(t)B_{k_1}\right)\right] + \frac{\eta_V}{t+1}(t-n_F(t))q_{j_1}B_{K+j_1}, logit t [ K + j 1 ] = A ( t ) + t + 1 η V q j 1 [ p k 1 ( B K + J + k 1 + n F ( t ) B k 1 ) ] + t + 1 η V ( t − n F ( t )) q j 1 B K + j 1 , where the shared terms above also has a closed form
A ~ ( t ) = η V ( t + 1 ) ( K + J ) [ p k 1 ( A K + J + k 1 + n F ( t ) A k 1 ) + ( t − n F ( t ) ) q j 1 A K + j 1 ] . \widetilde{A}(t) = \frac{\eta_V}{(t+1)(K+J)}\left[p_{k_1}\left(A_{K+J+k_1}+n_F(t)A_{k_1}\right)+(t-n_F(t))q_{j_1}A_{K+j_1}\right]. A ( t ) = ( t + 1 ) ( K + J ) η V [ p k 1 ( A K + J + k 1 + n F ( t ) A k 1 ) + ( t − n F ( t )) q j 1 A K + j 1 ] . The coefficients A i , B i , C i A_i, B_i, C_i A i , B i , C i , for i ∈ [ K + J ] i \in[K+J] i ∈ [ K + J ] , comes from Lemma D.2.
Proof. With the input sequence x 0 : T x_{0:T} x 0 : T , because W Q K = 0 W_{QK}=0 W Q K = 0 , s t l = e t T W Q K f x l = 0 s_{tl}=e_t^{\mathsf{T}}W_{QK}f_{x_l}=0 s tl = e t T W Q K f x l = 0 for 0 ≤ l ≤ t 0 \le l \le t 0 ≤ l ≤ t , so α t l = 1 / ( t + 1 ) \alpha_{tl}=1/(t+1) α tl = 1/ ( t + 1 ) , using the definition of o t o_t o t with W V = W V ( 1 ) W_V=W_V^{(1)} W V = W V ( 1 ) , we have
o t = ∑ l = 0 t 1 t + 1 W V ( 1 ) f x l = 1 t + 1 W V ( 1 ) ( f K + J + k 1 + n F ( t ) f k 1 + ( t − n F ( t ) ) ) = η V t + 1 ( − p k 1 A K + J + k 1 f ˉ + p k 1 ∑ j q j B K + J + k 1 f K + j + p k 1 C K + J + k 1 f k 1 \begin{aligned}
o_t = \sum_{l=0}^{t}\frac{1}{t+1}W_V^{(1)}f_{x_l} \\
&= \frac{1}{t+1}W_V^{(1)}\left(f_{K+J+k_1}+n_F(t)f_{k_1}+(t-n_F(t))\right) \\
&= \frac{\eta_V}{t+1}\left(-p_{k_1}A_{K+J+k_1}\bar{f}+p_{k_1}\sum_j q_jB_{K+J+k_1}f_{K+j}+p_{k_1}C_{K+J+k_1}f_{k_1}
\right.
\end{aligned} o t = l = 0 ∑ t t + 1 1 W V ( 1 ) f x l = t + 1 1 W V ( 1 ) ( f K + J + k 1 + n F ( t ) f k 1 + ( t − n F ( t )) ) = t + 1 η V ( − p k 1 A K + J + k 1 f ˉ + p k 1 j ∑ q j B K + J + k 1 f K + j + p k 1 C K + J + k 1 f k 1
+ n F ( t ) ( − p k 1 A k 1 f ˉ + p k 1 ∑ j q j B k 1 f K + j + p k 1 C k 1 f k 1 ) \left.
+n_F(t)\left(-p_{k_1}A_{k_1}\bar{f}+p_{k_1}\sum_jq_jB_{k_1}f_{K+j}+p_{k_1}C_{k_1}f_{k_1}\right)
\right. + n F ( t ) ( − p k 1 A k 1 f ˉ + p k 1 j ∑ q j B k 1 f K + j + p k 1 C k 1 f k 1 )
+ ( t − n F ( t ) ) ( − q j 1 A K + j 1 f ˉ + ( ∑ k p k q j 1 B K + j 1 ) f K + j 1 + ∑ k p k q j 1 C K + j 1 f k ) ) , \left.
+(t-n_F(t))\left(-q_{j_1}A_{K+j_1}\bar{f}+\left(\sum_kp_kq_{j_1}B_{K+j_1}\right)f_{K+j_1}+\sum_kp_kq_{j_1}C_{K+j_1}f_k\right)\right), + ( t − n F ( t )) ( − q j 1 A K + j 1 f ˉ + ( k ∑ p k q j 1 B K + j 1 ) f K + j 1 + k ∑ p k q j 1 C K + j 1 f k ) ) ,
where the second equation use the results in Eqn. (D.5), and the third equation use the results of W V ( 1 ) f k 1 W_V^{(1)}f_{k_1} W V ( 1 ) f k 1 , W V ( 1 ) f K + J + k 1 W_V^{(1)}f_{K+J+k_1} W V ( 1 ) f K + J + k 1 , W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 in Lemma D.5. Reorganize it with Eqn. (D.4), we have
o t = η V t + 1 { f ˉ ( − [ p k 1 ( A K + J + k 1 + n F ( t ) A k 1 ) + ( t − n F ( t ) ) q j 1 A K + j 1 ] ) + ∑ k f k ( p k [ I { k = k 1 } ( C K + J + k 1 + n F ( t ) C k 1 ) + ( t − n F ( t ) ) q j 1 C K + j 1 ] ) + ∑ j f K + j ( q j [ p k 1 ( B K + J + k 1 + n F ( t ) B k 1 ) ] + I { j = j 1 } ( t − n F ( t ) ) q j 1 B K + j 1 ) } , \begin{aligned}
o_t = \frac{\eta_V}{t+1}\Bigg\{&
\bar{f}\left(-\left[p_{k_1}\left(A_{K+J+k_1}+n_F(t)A_{k_1}\right)+(t-n_F(t))q_{j_1}A_{K+j_1}\right]\right) \\
&+\sum_k f_k\left(p_k\left[\mathbb{I}\{k=k_1\}\left(C_{K+J+k_1}+n_F(t)C_{k_1}\right)+(t-n_F(t))q_{j_1}C_{K+j_1}\right]\right) \\
&+\sum_j f_{K+j}\left(q_j\left[p_{k_1}\left(B_{K+J+k_1}+n_F(t)B_{k_1}\right)\right]+\mathbb{I}\{j=j_1\}(t-n_F(t))q_{j_1}B_{K+j_1}\right)\Bigg\},
\end{aligned} o t = t + 1 η V { f ˉ ( − [ p k 1 ( A K + J + k 1 + n F ( t ) A k 1 ) + ( t − n F ( t )) q j 1 A K + j 1 ] ) + k ∑ f k ( p k [ I { k = k 1 } ( C K + J + k 1 + n F ( t ) C k 1 ) + ( t − n F ( t )) q j 1 C K + j 1 ] ) + j ∑ f K + j ( q j [ p k 1 ( B K + J + k 1 + n F ( t ) B k 1 ) ] + I { j = j 1 } ( t − n F ( t )) q j 1 B K + j 1 ) } ,
where we group the terms according to the embeddings. Because f ˉ = ∑ i = 1 K + J f i / ( K + J ) \bar{f}=\sum_{i=1}^{K+J}f_i/(K+J) f ˉ = ∑ i = 1 K + J f i / ( K + J ) , we can further group the coefficient of embeddings and rewrite o t o_t o t as linear combination of embeddings. Due to the weight tying W l m W_{\mathrm{lm}} W lm , we have o_t=\sum_{i=1}^{K+J}\logit_t[i]f_i , where
\logit_t[k]=\widetilde{A}(t)+\frac{\eta_V}{t+1}p_kq_{j_1}\left(t-n_F(t)\right)C_{K+j_1},\qquad k\in[K],\ k\ne k_1,
\logit_t[k_1]=\widetilde{A}(t)+\frac{\eta_V}{t+1}p_{k_1}\left(q_{j_1}\left(t-n_F(t)\right)C_{K+j_1}+C_{K+J+k_1}+n_F(t)C_{k_1}\right),
\logit_t[K+j]=\widetilde{A}(t)+\frac{\eta_V}{t+1}q_j\left[p_{k_1}\left(B_{K+J+k_1}+n_F(t)B_{k_1}\right)\right],\qquad j\in[J],\ j\ne j_1,
\logit_t[K+j_1]=\widetilde{A}(t)+\frac{\eta_V}{t+1}q_{j_1}\left[p_{k_1}\left(B_{K+J+k_1}+n_F(t)B_{k_1}\right)\right]+\frac{\eta_V}{t+1}\left(t-n_F(t)\right)q_{j_1}B_{K+j_1},
where we directly decompose the factors and I { k = k 1 } , I { j = j 1 } \mathbb{I}\{k=k_1\},\mathbb{I}\{j=j_1\} I { k = k 1 } , I { j = j 1 } . The common factor of every embedding is provided by coefficient of f ~ \widetilde{f} f , which is
A ~ ( t ) = η V ( t + 1 ) ( K + J ) [ p k 1 ( A K + J + k 1 + n F ( t ) A k 1 ) + ( t − n F ( t ) ) q j 1 ∑ k p k A K + j ] , \widetilde{A}(t)=\frac{\eta_V}{(t+1)(K+J)}\left[p_{k_1}\left(A_{K+J+k_1}+n_F(t)A_{k_1}\right)+\left(t-n_F(t)\right)q_{j_1}\sum_k p_kA_{K+j}\right], A ( t ) = ( t + 1 ) ( K + J ) η V [ p k 1 ( A K + J + k 1 + n F ( t ) A k 1 ) + ( t − n F ( t ) ) q j 1 k ∑ p k A K + j ] ,
which will be eliminated in the computation of softmax function. Thus, we conclude the proof of Lemma D.6. □
Lemma D.7 (Concentration of probability on the background token after first step). Under assumptions in Theorem D.1 , after the first step optimization, for all t ∈ { 1 , … , T − 1 } t\in\{1,\ldots,T-1\} t ∈ { 1 , … , T − 1 } and all three phases of n F ( t ) n_F(t) n F ( t ) in Eqn. (D.4), with an input sequence with visual feature class k 1 ∈ [ K ] k_1\in[K] k 1 ∈ [ K ] and visual background class j 1 ∈ [ J ] j_1\in[J] j 1 ∈ [ J ] , i.e. x 0 = K + J + k 1 , x 1 : T ∈ I k 1 , j 1 x_0=K+J+k_1,x_{1:T}\in\mathcal{I}_{k_1,j_1} x 0 = K + J + k 1 , x 1 : T ∈ I k 1 , j 1 , the probability satisfies
P t [ i ] = { e − Θ ( T 1 − β ) , i ≠ K + j 1 , 1 − Θ ( T β e − Θ ( T 1 − β ) ) , i = K + j 1 . P_t[i]=
\begin{cases}
e^{-\Theta(T^{1-\beta})}, & i\ne K+j_1,\\
1-\Theta\left(T^\beta e^{-\Theta(T^{1-\beta})}\right), & i=K+j_1.
\end{cases} P t [ i ] = { e − Θ ( T 1 − β ) , 1 − Θ ( T β e − Θ ( T 1 − β ) ) , i = K + j 1 , i = K + j 1 . The dominant logit gap is driven by C K + j 1 = Θ ( T 1 − β ) C_{K+j_1}=\Theta(T^{1-\beta}) C K + j 1 = Θ ( T 1 − β ) , while all other logits are Θ ( ( log T ) 3 / T β ) \Theta((\log T)^3/T^\beta) Θ (( log T ) 3 / T β ) or smaller.
Proof. From Lemma D.6, we know the closed form of logits after the first step with an input sequence with feature k 1 k_1 k 1 and background j 1 j_1 j 1 in Lemma D.6. Note that A ~ ( t ) \widetilde{A}(t) A ( t ) is the same for every logits, so when we feed \logit_t^{(1)} into softmax, the term A ~ ( t ) \widetilde{A}(t) A ( t ) will be eliminated, which means
\operatorname{sm}(\logit_t)[a]=\operatorname{sm}\left(\left[\logit_t[1]-\widetilde{A}(t),\ldots,\logit_t[K+J]-\widetilde{A}(t)\right]^{\mathsf T}\right)[a],
which holds because we divide A ~ ( t ) \widetilde{A}(t) A ( t ) from the numerator and denominator, and then use the definition of softmax function. Therefore, the probability P t [ i ] P_t[i] P t [ i ] only determined by \logit_t[i]-\widetilde{A}(t) . Now we analysis their order at different region using the results in Eqn. (D.8).
When t < τ t<\tau t < τ , from Eqn. (D.4), n F ( t ) = 0 n_F(t)=0 n F ( t ) = 0 , we plug them in results in Lemma D.6 and get
\logit_t[k]-\widetilde{A}(t)=\frac{\eta_V}{t+1}p_kq_{j_1}tC_{K+j_1},\qquad k\in[K],\ k\ne k_1,
\logit_t[k_1]-\widetilde{A}(t)=\frac{\eta_V}{t+1}p_{k_1}\left(q_{j_1}tC_{K+j_1}+C_{K+J+k_1}\right),
\logit_t[K+j]-\widetilde{A}(t)=\frac{\eta_V}{t+1}q_jp_{k_1}B_{K+J+k_1},\qquad j\in[J],\ j\ne j_1,
\logit_t[K+j_1]-\widetilde{A}(t)=\frac{\eta_V}{t+1}q_{j_1}p_{k_1}B_{K+J+k_1}+\frac{\eta_V}{t+1}tq_{j_1}B_{K+j_1}.
Then we plug in the order of the coefficients computed in Eqn. (D.8), and use the assumption in Theorem D.1 with direct computation, finally we get
\logit_t[i]-\widetilde{A}(t)=
\begin{cases}
\Theta\left(\dfrac{\log T}{T^\beta}\right), & i=k\in[K],\ k\ne k_1,\\
\Theta\left(\dfrac{\log T}{T^\beta}\right), & i=k_1,\\
\Theta\left(\dfrac{\log T}{(t+1)T^\beta}\right), & i=K+j,\ j\in[J],\ j\ne j_1,\\
\Theta(T^{1-\beta}), & i=K+j_1.
\end{cases}
Similarly, from Eqn. (D.4), when τ ≤ t ≤ τ + L − 1 \tau\le t \le\tau+L-1 τ ≤ t ≤ τ + L − 1 , t − n F ( t ) = τ − 1 = Θ ( 1 ) t-n_F(t)=\tau-1=\Theta(1) t − n F ( t ) = τ − 1 = Θ ( 1 ) , we plug them in Lemma D.6 and use the coefficient order in Eqn. (D.8) with assumption in Theorem D.1 , we can get
logit t [ i ] − A ~ ( t ) = { Θ ( log T T β ) , i = k ∈ [ K ] , k ≠ k 1 , Θ ( log T T β ) , i = k 1 , [ Θ ( ( log T ) 2 T 2 β ) , Θ ( ( log T ) 3 T 2 β ) ] , i = K + j , j ∈ [ J ] , j ≠ j 1 , Θ ( T 1 − β ) , i = K + j 1 . \operatorname{logit}_t[i]-\widetilde{A}(t)=
\begin{cases}
\Theta\left(\frac{\log T}{T^\beta}\right), & i=k\in[K],\ k\ne k_1,\\
\Theta\left(\frac{\log T}{T^\beta}\right), & i=k_1,\\
\left[\Theta\left(\frac{(\log T)^2}{T^{2\beta}}\right),\Theta\left(\frac{(\log T)^3}{T^{2\beta}}\right)\right], & i=K+j,\ j\in[J],\ j\ne j_1,\\
\Theta(T^{1-\beta}), & i=K+j_1.
\end{cases} logit t [ i ] − A ( t ) = ⎩ ⎨ ⎧ Θ ( T β l o g T ) , Θ ( T β l o g T ) , [ Θ ( T 2 β ( l o g T ) 2 ) , Θ ( T 2 β ( l o g T ) 3 ) ] , Θ ( T 1 − β ) , i = k ∈ [ K ] , k = k 1 , i = k 1 , i = K + j , j ∈ [ J ] , j = j 1 , i = K + j 1 .
where those for i = K + j , j ≠ j 1 i=K+j,j\ne j_1 i = K + j , j = j 1 lies in an interval because from Eqn. D.4, when τ ≤ t ≤ τ + L − 1 \tau\le t\le\tau+L-1 τ ≤ t ≤ τ + L − 1 , n F ( t ) ∈ [ 1 , L ] n_F(t)\in[1,L] n F ( t ) ∈ [ 1 , L ] , and L = Θ ( log T ) L=\Theta(\log T) L = Θ ( log T ) .
Similarly, from Eqn. (D.4), when t ≥ τ + L − 1 t\ge\tau+L-1 t ≥ τ + L − 1 , n F ( t ) = L n_F(t)=L n F ( t ) = L , t − n F = t − L t-n_F=t-L t − n F = t − L , t t t can be at most T T T , so we also plug them in Lemma D.6 and use the coefficient order in Eqn. (D.8) with assumption in Theorem D.1 , we can get
logit t [ i ] − A ~ ( t ) = { Θ ( log T T β ) , i = k ∈ [ K ] , k ≠ k 1 , Θ ( log T T β ) , i = k 1 , Θ ( ( log T ) 3 ( t + 1 ) T β ) , i = K + j , j ∈ [ J ] , j ≠ j 1 , Θ ( T 1 − β ) , i = K + j 1 . \operatorname{logit}_t[i]-\widetilde{A}(t)=
\begin{cases}
\Theta\left(\frac{\log T}{T^\beta}\right), & i=k\in[K],\ k\ne k_1,\\
\Theta\left(\frac{\log T}{T^\beta}\right), & i=k_1,\\
\Theta\left(\frac{(\log T)^3}{(t+1)T^\beta}\right), & i=K+j,\ j\in[J],\ j\ne j_1,\\
\Theta(T^{1-\beta}), & i=K+j_1.
\end{cases} logit t [ i ] − A ( t ) = ⎩ ⎨ ⎧ Θ ( T β l o g T ) , Θ ( T β l o g T ) , Θ ( ( t + 1 ) T β ( l o g T ) 3 ) , Θ ( T 1 − β ) , i = k ∈ [ K ] , k = k 1 , i = k 1 , i = K + j , j ∈ [ J ] , j = j 1 , i = K + j 1 .
Now feed them into softmax. Firstly, we can find that in different time region, K + j 1 K+j_1 K + j 1 always dominates, but we also need to consider that J = ⌊ τ log T / c L ⌋ J=\lfloor\tau\log T/cL\rfloor J = ⌊ τ log T / c L ⌋ . Therefore, for all t t t , we apply softmax function and get
sm ( logit t ) [ K + j 1 ] = 1 K exp ( − Θ ( T 1 − β ) ) + ( J − 1 ) exp ( − Θ ( T 1 − β ) ) + 1 = 1 − Θ ( T β e − Θ ( T 1 − β ) ) . \operatorname{sm}(\operatorname{logit}_t)[K+j_1]=\frac{1}{K\exp\left(-\Theta(T^{1-\beta})\right)+(J-1)\exp\left(-\Theta(T^{1-\beta})\right)+1}=1-\Theta\left(T^\beta e^{-\Theta(T^{1-\beta})}\right). sm ( logit t ) [ K + j 1 ] = K exp ( − Θ ( T 1 − β ) ) + ( J − 1 ) exp ( − Θ ( T 1 − β ) ) + 1 1 = 1 − Θ ( T β e − Θ ( T 1 − β ) ) .
where the second equation is a results of divide exp ( logit t [ K + j 1 ] − A ~ ( t ) ) \exp\left(\operatorname{logit}_t[K+j_1]-\widetilde{A}(t)\right) exp ( logit t [ K + j 1 ] − A ( t ) ) from the numerator and denominator, and logit t [ K + j 1 ] − A ~ ( t ) = Θ ( T 1 − β ) \operatorname{logit}_t[K+j_1]-\widetilde{A}(t)=\Theta(T^{1-\beta}) logit t [ K + j 1 ] − A ( t ) = Θ ( T 1 − β ) for every t ∈ [ 1 , T − 1 ] t\in[1,T-1] t ∈ [ 1 , T − 1 ] and dominate others. The third equation comes from direct computation. So for i ≠ K + j 1 i\ne K+j_1 i = K + j 1 , we have P t [ i ] = e − Θ ( T 1 − β ) P_t[i]=e^{-\Theta(T^{1-\beta})} P t [ i ] = e − Θ ( T 1 − β ) . Conclude the above results, for t ∈ [ 1 , T − 1 ] t\in[1,T-1] t ∈ [ 1 , T − 1 ] we have
P t [ i ] = { e − Θ ( T 1 − β ) , i ≠ K + j 1 , 1 − Θ ( T β e − Θ ( T 1 − β ) ) , i = K + j 1 . P_t[i]=
\begin{cases}
e^{-\Theta(T^{1-\beta})}, & i\ne K+j_1,\\
1-\Theta\left(T^\beta e^{-\Theta(T^{1-\beta})}\right), & i=K+j_1.
\end{cases} P t [ i ] = { e − Θ ( T 1 − β ) , 1 − Θ ( T β e − Θ ( T 1 − β ) ) , i = K + j 1 , i = K + j 1 .
Thus, we conclude the proof of Lemma D.6 . □ \square □
Step 6: Population Gradient of W Q K W_{QK} W Q K after first Update
In this step, we can compute the population gradient of W Q K W_{QK} W Q K , which will be used in the second update.
Lemma D.8 (Population gradient of W Q K W_{QK} W Q K ). At θ ( 1 ) = ( W V ( 1 ) , 0 ) \theta^{(1)}=(W_V^{(1)},0) θ ( 1 ) = ( W V ( 1 ) , 0 ) , the negative gradient of W Q K W_{QK} W Q K on a sample with visual feature class k 1 ∈ [ K ] k_1\in[K] k 1 ∈ [ K ] and visual background class j 1 ∈ [ J ] j_1\in[J] j 1 ∈ [ J ] is
− ∇ W Q K L ( k 1 , j 1 ; θ ( 1 ) ) -\nabla_{W_{QK}}\mathcal{L}(k_1,j_1;\theta^{(1)}) − ∇ W Q K L ( k 1 , j 1 ; θ ( 1 ) ) = ∑ t = τ − 1 τ + L − 2 γ ( k 1 , j 1 , t , K + J + k 1 ) e t f K + J + k 1 T + ∑ t = τ − 1 τ + L − 2 ( τ − 1 ) γ ( k , j , t , K + j ) e t f K + j T =\sum_{t=\tau-1}^{\tau+L-2}\gamma(k_1,j_1,t,K+J+k_1)e_tf_{K+J+k_1}^{\mathsf T}
+\sum_{t=\tau-1}^{\tau+L-2}(\tau-1)\gamma(k,j,t,K+j)e_tf_{K+j}^{\mathsf T} = t = τ − 1 ∑ τ + L − 2 γ ( k 1 , j 1 , t , K + J + k 1 ) e t f K + J + k 1 T + t = τ − 1 ∑ τ + L − 2 ( τ − 1 ) γ ( k , j , t , K + j ) e t f K + j T + ∑ t = τ − 1 τ + L − 2 ( t − τ + 1 ) γ ( k 1 , j 1 , t , k 1 ) e t f k 1 T + ∑ t = 1 T − 1 ∑ l = 0 t ξ ( k 1 , j 1 , t , x l ) e t f x l T , +\sum_{t=\tau-1}^{\tau+L-2}(t-\tau+1)\gamma(k_1,j_1,t,k_1)e_tf_{k_1}^{\mathsf T}
+\sum_{t=1}^{T-1}\sum_{l=0}^{t}\xi(k_1,j_1,t,x_l)e_tf_{x_l}^{\mathsf T}, + t = τ − 1 ∑ τ + L − 2 ( t − τ + 1 ) γ ( k 1 , j 1 , t , k 1 ) e t f k 1 T + t = 1 ∑ T − 1 l = 0 ∑ t ξ ( k 1 , j 1 , t , x l ) e t f x l T ,
where the scalar γ ( k 1 , j 1 , t , a ) \gamma(k_1,j_1,t,a) γ ( k 1 , j 1 , t , a ) parameterd by class k 1 , j 1 k_1,j_1 k 1 , j 1 , position t t t and token a a a satisfies
γ ( k 1 , j 1 , t , K + j 1 ) = 1 ( t + 1 ) 2 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + n F ( t ) ( t + 1 ) 2 ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) − 1 + n F ( t ) ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) , \begin{aligned}
\gamma(k_1,j_1,t,K+j_1)
&=\frac{1}{(t+1)^2}\left(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1}\right)
+\frac{n_F(t)}{(t+1)^2}\left(p_{k_1}q_{j_1}B_{k_1}-p_{k_1}C_{k_1}\right)\\
&\quad-\frac{1+n_F(t)}{(t+1)^2}\left(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}\right),
\end{aligned} γ ( k 1 , j 1 , t , K + j 1 ) = ( t + 1 ) 2 1 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + ( t + 1 ) 2 n F ( t ) ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) − ( t + 1 ) 2 1 + n F ( t ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) ,
γ ( k 1 , j 1 , t , k 1 ) = 1 ( t + 1 ) 2 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) − t + 1 − n F ( t ) ( t + 1 ) 2 ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) + t − n F ( t ) ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) , \begin{aligned}
\gamma(k_1,j_1,t,k_1)
&=\frac{1}{(t+1)^2}\left(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1}\right)
-\frac{t+1-n_F(t)}{(t+1)^2}\left(p_{k_1}q_{j_1}B_{k_1}-p_{k_1}C_{k_1}\right)\\
&\quad+\frac{t-n_F(t)}{(t+1)^2}\left(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}\right),
\end{aligned} γ ( k 1 , j 1 , t , k 1 ) = ( t + 1 ) 2 1 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) − ( t + 1 ) 2 t + 1 − n F ( t ) ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) + ( t + 1 ) 2 t − n F ( t ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) ,
γ ( k 1 , j 1 , t , K + J + k 1 ) = − t ( t + 1 ) 2 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + n F ( t ) ( t + 1 ) 2 ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) + t − n F ( t ) ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) . \begin{aligned}
\gamma(k_1,j_1,t,K+J+k_1)
&=-\frac{t}{(t+1)^2}\left(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1}\right)
+\frac{n_F(t)}{(t+1)^2}\left(p_{k_1}q_{j_1}B_{k_1}-p_{k_1}C_{k_1}\right)\\
&\quad+\frac{t-n_F(t)}{(t+1)^2}\left(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}\right).
\end{aligned} γ ( k 1 , j 1 , t , K + J + k 1 ) = − ( t + 1 ) 2 t ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + ( t + 1 ) 2 n F ( t ) ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) + ( t + 1 ) 2 t − n F ( t ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) .
Another group of scaler ξ ( k 1 , j 1 , t , a ) \xi(k_1,j_1,t,a) ξ ( k 1 , j 1 , t , a ) parameterd by class k 1 , j 1 k_1,j_1 k 1 , j 1 , position t t t and token a a a satisfies: ξ ( k 1 , j 1 , t , K + j 1 ) = O ( t + 1 T e − Θ ( T 1 − β ) ) \xi(k_1,j_1,t,K+j_1)=O\left(\frac{t+1}{T}e^{-\Theta(T^{1-\beta})}\right) ξ ( k 1 , j 1 , t , K + j 1 ) = O ( T t + 1 e − Θ ( T 1 − β ) ) , ξ ( k 1 , j 1 , t , K + J + k 1 ) = O ( T t + 1 e − Θ ( T 1 − β ) ) \xi(k_1,j_1,t,K+J+k_1)=O\left(\frac{T}{t+1}e^{-\Theta(T^{1-\beta})}\right) ξ ( k 1 , j 1 , t , K + J + k 1 ) = O ( t + 1 T e − Θ ( T 1 − β ) ) , ξ ( k 1 , j 1 , t , k 1 ) = O ( T t + 1 e − Θ ( T 1 − β ) ) \xi(k_1,j_1,t,k_1)=O\left(\frac{T}{t+1}e^{-\Theta(T^{1-\beta})}\right) ξ ( k 1 , j 1 , t , k 1 ) = O ( t + 1 T e − Θ ( T 1 − β ) ) , which are exponentially small.
Proof. Recall the definition in Section C.1, for each position t t t , we have δ t = P t − y t \delta_t=P_t-y_t δ t = P t − y t and g t = W l m δ t g_t=W_{\mathrm{lm}}\delta_t g t = W lm δ t . For a sequence with visual feature class k 1 ∈ [ K ] k_1\in[K] k 1 ∈ [ K ] , and visual background class j 1 ∈ [ J ] j_1\in[J] j 1 ∈ [ J ] , by Lemma D.7, we know that the probability P t ( 1 ) P_t^{(1)} P t ( 1 ) concentrates on K + j 1 K+j_1 K + j 1 , which means
δ t = P t − y t = ( 1 − ϵ K + j 1 ) 1 K + j 1 + ∑ i ≠ K + j 1 ϵ i 1 i − 1 x t + 1 , \delta_t=P_t-y_t=(1-\epsilon_{K+j_1})\mathbf{1}_{K+j_1}+\sum_{i\ne K+j_1}\epsilon_i\mathbf{1}_i-\mathbf{1}_{x_{t+1}}, δ t = P t − y t = ( 1 − ϵ K + j 1 ) 1 K + j 1 + i = K + j 1 ∑ ϵ i 1 i − 1 x t + 1 ,
where ϵ K + j 1 = Θ ( T β e − Θ ( T 1 − β ) ) \epsilon_{K+j_1}=\Theta(T^\beta e^{-\Theta(T^{1-\beta})}) ϵ K + j 1 = Θ ( T β e − Θ ( T 1 − β ) ) , and ϵ i = e − Θ ( T 1 − β ) \epsilon_i=e^{-\Theta(T^{1-\beta})} ϵ i = e − Θ ( T 1 − β ) , i ≠ K + j 1 i\ne K+j_1 i = K + j 1 , and ∑ i = 1 K + J ϵ i = 1 \sum_{i=1}^{K+J}\epsilon_i=1 ∑ i = 1 K + J ϵ i = 1 . So we have
g t = { f K + j 1 − f k 1 + ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 , x t + 1 = k 1 , ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 , x t + 1 = K + j 1 , (19) g_t=
\begin{cases}
f_{K+j_1}-f_{k_1}+\sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1}, & x_{t+1}=k_1,\\
\sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1}, & x_{t+1}=K+j_1,
\end{cases} \tag*{(19)} g t = { f K + j 1 − f k 1 + ∑ i = K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 , ∑ i = K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 , x t + 1 = k 1 , x t + 1 = K + j 1 , (19)
which is direct expansion using weight tying language model head W l m W_{\mathrm{lm}} W lm . Because all the ϵ i \epsilon_i ϵ i , i ∈ [ K + J ] i\in[K+J] i ∈ [ K + J ] are exponentially small, when x t + 1 = k 1 x_{t+1}=k_1 x t + 1 = k 1 , g t ≈ f K + j 1 − f k 1 g_t\approx f_{K+j_1}-f_{k_1} g t ≈ f K + j 1 − f k 1 ; when x t + 1 = K + j 1 x_{t+1}=K+j_1 x t + 1 = K + j 1 , g t ≈ 0 g_t\approx0 g t ≈ 0 , for sufficiently large T T T . We can divide them into the main part f K + j 1 − f k 1 f_{K+j_1}-f_{k_1} f K + j 1 − f k 1 and the residual part ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 \sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1} ∑ i = K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 .
Because s t l = e t T W Q K f x l = 0 s_{tl}=e_t^{\mathsf T}W_{QK}f_{x_l}=0 s tl = e t T W Q K f x l = 0 , the attention score is uniform, i.e. α t l = 1 / ( t + 1 ) \alpha_{tl}=1/(t+1) α tl = 1/ ( t + 1 ) , for all 0 ≤ l ≤ t 0\le l\le t 0 ≤ l ≤ t . So from Eqn. (C.5), we know that, at ( W V , W Q K ) = ( W V ( 1 ) , 0 ) (W_V,W_{QK})=(W_V^{(1)},0) ( W V , W Q K ) = ( W V ( 1 ) , 0 ) , the negative of the exact per-sample gradient is
− ∇ W Q K L = ∑ t = 1 T − 1 ∑ l = 0 t 1 t + 1 [ g t T ( o t − W V ( 1 ) f x l ) ] e t f x l T , (20) -\nabla_{W_{QK}}\mathcal{L}=\sum_{t=1}^{T-1}\sum_{l=0}^{t}\frac{1}{t+1}\left[g_t^{\mathsf T}\left(o_t-W_V^{(1)}f_{x_l}\right)\right]e_tf_{x_l}^{\mathsf T}, \tag*{(20)} − ∇ W Q K L = t = 1 ∑ T − 1 l = 0 ∑ t t + 1 1 [ g t T ( o t − W V ( 1 ) f x l ) ] e t f x l T , (20)
which is a simple reverse of sign in the Eqn. (C.5). To compute the closed form of the gradient of W Q K W_{QK} W Q K , we should consider to decompose the term g t T ( o t − W V ( 1 ) f x l ) g_t^{\mathsf T}\left(o_t-W_V^{(1)}f_{x_l}\right) g t T ( o t − W V ( 1 ) f x l ) . Frisly, we expand the o t − W V ( 1 ) f x l o_t-W_V^{(1)}f_{x_l} o t − W V ( 1 ) f x l part by considering 3 kinds of embeddings respectively, so we can get
o t − W V ( 1 ) f K + j 1 = W V ( 1 ) ( 1 t + 1 f K + J + k 1 + n F ( t ) t + 1 f k 1 − 1 + n F ( t ) t + 1 f K + j 1 ) o_t-W_V^{(1)}f_{K+j_1}=W_V^{(1)}\left(\frac{1}{t+1}f_{K+J+k_1}+\frac{n_F(t)}{t+1}f_{k_1}-\frac{1+n_F(t)}{t+1}f_{K+j_1}\right) o t − W V ( 1 ) f K + j 1 = W V ( 1 ) ( t + 1 1 f K + J + k 1 + t + 1 n F ( t ) f k 1 − t + 1 1 + n F ( t ) f K + j 1 )
o t − W V ( 1 ) f k 1 = W V ( 1 ) ( 1 t + 1 f K + J + k 1 − t + 1 − n F ( t ) t + 1 f k 1 + t − n F ( t ) t + 1 f K + j 1 ) o_t-W_V^{(1)}f_{k_1}=W_V^{(1)}\left(\frac{1}{t+1}f_{K+J+k_1}-\frac{t+1-n_F(t)}{t+1}f_{k_1}+\frac{t-n_F(t)}{t+1}f_{K+j_1}\right) o t − W V ( 1 ) f k 1 = W V ( 1 ) ( t + 1 1 f K + J + k 1 − t + 1 t + 1 − n F ( t ) f k 1 + t + 1 t − n F ( t ) f K + j 1 )
o t − W V ( 1 ) f K + J + k 1 = W V ( 1 ) ( − t t + 1 f K + J + k 1 + n F ( t ) t + 1 f k 1 + t − n F ( t ) t + 1 f K + j 1 ) o_t-W_V^{(1)}f_{K+J+k_1}=W_V^{(1)}\left(-\frac{t}{t+1}f_{K+J+k_1}+\frac{n_F(t)}{t+1}f_{k_1}+\frac{t-n_F(t)}{t+1}f_{K+j_1}\right) o t − W V ( 1 ) f K + J + k 1 = W V ( 1 ) ( − t + 1 t f K + J + k 1 + t + 1 n F ( t ) f k 1 + t + 1 t − n F ( t ) f K + j 1 )
where the equation all comes from the direct computation using definition o t = ∑ l = 0 t α t l W V ( 1 ) f x l o_t=\sum_{l=0}^{t}\alpha_{tl}W_V^{(1)}f_{x_l} o t = ∑ l = 0 t α tl W V ( 1 ) f x l with uniform attention α t l = 1 / ( t + 1 ) \alpha_{tl}=1/(t+1) α tl = 1/ ( t + 1 ) and the results in Eqn. (D.5).
Then we should consider the inner product g t ⊤ ( o t − W V ( 1 ) f x l ) g_t^\top(o_t-W_V^{(1)}f_{x_l}) g t ⊤ ( o t − W V ( 1 ) f x l ) . But due to the structure of g t g_t g t in Eqn. (D.10), we need to consider the main part and the residual part separately, and then merge them.
Main Part: From the structure of g t g_t g t in Eqn. (D.10), the main part f K + j 1 − f k 1 f_{K+j_1}-f_{k_1} f K + j 1 − f k 1 exists when t ∈ F t\in\mathcal{F} t ∈ F in Eqn. (D.6), because x t + 1 = k 1 x_{t+1}=k_1 x t + 1 = k 1 . We firstly consider the quadratic form when f K + j 1 − f k 1 f_{K+j_1}-f_{k_1} f K + j 1 − f k 1 work on W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 to simplify the computation. Combine the results in Lemma D.5, we have
( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f K + j 1 = − η V ( f K + j 1 − f k 1 ) ⊤ ∑ k p k q j 1 A K + j 1 f ˉ + η V ( ∑ k p k q j 1 B K + j 1 ) ( f K + j 1 − f k 1 ) ⊤ f K + j 1 + η V ∑ k p k q j 1 C K + j 1 ( f K + j 1 − f k 1 ) ⊤ f k = η V q j 1 B K + j 1 − η V p k 1 q j 1 C K + j 1 , \begin{aligned}
(f_{K+j_1}-f_{k_1})^\top W_V^{(1)}f_{K+j_1}
={}&-\eta_V(f_{K+j_1}-f_{k_1})^\top\sum_k p_kq_{j_1}A_{K+j_1}\bar{f}
+\eta_V\left(\sum_k p_kq_{j_1}B_{K+j_1}\right)(f_{K+j_1}-f_{k_1})^\top f_{K+j_1}\\
&+\eta_V\sum_k p_kq_{j_1}C_{K+j_1}(f_{K+j_1}-f_{k_1})^\top f_k\\
={}&\eta_Vq_{j_1}B_{K+j_1}-\eta_Vp_{k_1}q_{j_1}C_{K+j_1},
\end{aligned} ( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f K + j 1 = = − η V ( f K + j 1 − f k 1 ) ⊤ k ∑ p k q j 1 A K + j 1 f ˉ + η V ( k ∑ p k q j 1 B K + j 1 ) ( f K + j 1 − f k 1 ) ⊤ f K + j 1 + η V k ∑ p k q j 1 C K + j 1 ( f K + j 1 − f k 1 ) ⊤ f k η V q j 1 B K + j 1 − η V p k 1 q j 1 C K + j 1 ,
where the first equation is a direct expansion of the W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 , and the second equation comes from the orthonormality of the embeddings. Similarly, using the same technique, we can get
( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f k 1 = η V p k 1 q j 1 B k 1 − η V p k 1 C k 1 , (f_{K+j_1}-f_{k_1})^\top W_V^{(1)}f_{k_1}=\eta_Vp_{k_1}q_{j_1}B_{k_1}-\eta_Vp_{k_1}C_{k_1}, ( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f k 1 = η V p k 1 q j 1 B k 1 − η V p k 1 C k 1 ,
( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f K + J + k 1 = η V p k 1 q j 1 B K + J + k 1 − η V p k 1 C K + J + k 1 . (f_{K+j_1}-f_{k_1})^\top W_V^{(1)}f_{K+J+k_1}=\eta_Vp_{k_1}q_{j_1}B_{K+J+k_1}-\eta_Vp_{k_1}C_{K+J+k_1}. ( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f K + J + k 1 = η V p k 1 q j 1 B K + J + k 1 − η V p k 1 C K + J + k 1 .
To simplify the computation, we denote the scaler γ ( k 1 , j 1 , t , a ) = ( f K + j − f k ) ⊤ ( o t − W V ( 1 ) f a ) / ( t + 1 ) \gamma(k_1,j_1,t,a)=(f_{K+j}-f_k)^\top(o_t-W_V^{(1)}f_a)/(t+1) γ ( k 1 , j 1 , t , a ) = ( f K + j − f k ) ⊤ ( o t − W V ( 1 ) f a ) / ( t + 1 ) to pack the term before e t f x l ⊤ e_tf_{x_l}^{\top} e t f x l ⊤ in Eqn. (D.11) for a sequence with feature class k 1 k_1 k 1 and background class j 1 j_1 j 1 when computing the loss, and x l = a x_l=a x l = a . When x l = K + j 1 x_l=K+j_1 x l = K + j 1 , we have
γ ( k 1 , j 1 , t , K + j 1 ) = 1 t + 1 ( f K + j 1 − f k 1 ) ⊤ ( o t − W V ( 1 ) f K + j 1 ) = 1 ( t + 1 ) 2 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + n F ( t ) ( t + 1 ) 2 ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) − 1 + n F ( t ) ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) , \begin{aligned}
\gamma(k_1,j_1,t,K+j_1)
&=\frac{1}{t+1}(f_{K+j_1}-f_{k_1})^\top(o_t-W_V^{(1)}f_{K+j_1})\\
&=\frac{1}{(t+1)^2}(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1})
+\frac{n_F(t)}{(t+1)^2}(p_{k_1}q_{j_1}B_{k_1}-p_{k_1}C_{k_1})\\
&\quad-\frac{1+n_F(t)}{(t+1)^2}(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}),
\end{aligned} γ ( k 1 , j 1 , t , K + j 1 ) = t + 1 1 ( f K + j 1 − f k 1 ) ⊤ ( o t − W V ( 1 ) f K + j 1 ) = ( t + 1 ) 2 1 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + ( t + 1 ) 2 n F ( t ) ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) − ( t + 1 ) 2 1 + n F ( t ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) ,
where the second equation use the results of o t − W V ( 1 ) f K + j 1 o_t-W_V^{(1)}f_{K+j_1} o t − W V ( 1 ) f K + j 1 and expand them with the closed form of quadratic form ( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f K + j 1 (f_{K+j_1}-f_{k_1})^\top W_V^{(1)}f_{K+j_1} ( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f K + j 1 , ( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f k 1 (f_{K+j_1}-f_{k_1})^\top W_V^{(1)}f_{k_1} ( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f k 1 and ( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f K + J + k 1 (f_{K+j_1}-f_{k_1})^\top W_V^{(1)}f_{K+J+k_1} ( f K + j 1 − f k 1 ) ⊤ W V ( 1 ) f K + J + k 1 . Similarly, we can use the same technique to derive those form when x l = k 1 x_l = k_1 x l = k 1 and x l = K + J + k 1 x_l = K + J + k_1 x l = K + J + k 1 as follows
γ ( k 1 , j 1 , t , k 1 ) = 1 ( t + 1 ) 2 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) − t + 1 − n F ( t ) ( t + 1 ) 2 ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) + t − n F ( t ) ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) , \begin{aligned}
\gamma(k_1,j_1,t,k_1)
&= \frac{1}{(t+1)^2}\left(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1}\right) - \frac{t+1-n_F(t)}{(t+1)^2}\left(p_{k_1}q_{j_1}B_{k_1}-p_{k_1}C_{k_1}\right) \\
&\quad+ \frac{t-n_F(t)}{(t+1)^2}\left(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}\right),
\end{aligned} γ ( k 1 , j 1 , t , k 1 ) = ( t + 1 ) 2 1 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) − ( t + 1 ) 2 t + 1 − n F ( t ) ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) + ( t + 1 ) 2 t − n F ( t ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) ,
γ ( k 1 , j 1 , t , K + J + k 1 ) = − t ( t + 1 ) 2 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + n F ( t ) ( t + 1 ) 2 ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) + t − n F ( t ) ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) . \begin{aligned}
\gamma(k_1,j_1,t,K+J+k_1)
&= -\frac{t}{(t+1)^2}\left(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1}\right) + \frac{n_F(t)}{(t+1)^2}\left(p_{k_1}q_{j_1}B_{k_1}-p_{k_1}C_{k_1}\right) \\
&\quad+ \frac{t-n_F(t)}{(t+1)^2}\left(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}\right).
\end{aligned} γ ( k 1 , j 1 , t , K + J + k 1 ) = − ( t + 1 ) 2 t ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + ( t + 1 ) 2 n F ( t ) ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) + ( t + 1 ) 2 t − n F ( t ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) .
Residual Part: Because ϵ i \epsilon_i ϵ i are exponentially small, so for any i ∈ [ K + J ] i \in[K+J] i ∈ [ K + J ] , we have ϵ i f i T W V ( 1 ) f K + J + k 1 = o ( 1 ) \epsilon_i f_i^{\mathsf T}W_V^{(1)}f_{K+J+k_1}=o(1) ϵ i f i T W V ( 1 ) f K + J + k 1 = o ( 1 ) , ϵ i f i T W V ( 1 ) f k 1 = o ( 1 ) \epsilon_i f_i^{\mathsf T}W_V^{(1)}f_{k_1}=o(1) ϵ i f i T W V ( 1 ) f k 1 = o ( 1 ) , and ϵ i f i T W V ( 1 ) f K + j 1 = o ( 1 ) \epsilon_i f_i^{\mathsf T}W_V^{(1)}f_{K+j_1}=o(1) ϵ i f i T W V ( 1 ) f K + j 1 = o ( 1 ) . We explicitly describe these in the part. For the residuals ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 \sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1} ∑ i = K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 , we also compute the quadratic form made by it and W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 , W V ( 1 ) f K + J + k 1 W_V^{(1)}f_{K+J+k_1} W V ( 1 ) f K + J + k 1 , W V ( 1 ) f k 1 W_V^{(1)}f_{k_1} W V ( 1 ) f k 1 . For W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 , we have
( ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 ) T W V ( 1 ) f K + j 1 = − η V ( ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 ) T ∑ k p k q j 1 A K + j 1 f ˉ + η V ( ∑ k p k q j 1 B K + j 1 ) ( ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 ) T f K + j 1 + η V ∑ k p k q j 1 C K + j 1 ( ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 ) T f k = − ϵ K + j 1 η V ( ∑ k p k q j 1 B K + j 1 ) + η V ∑ k ϵ k p k q j 1 C K + j 1 = − Θ ( T e − Θ ( T 1 − β ) ) , \begin{aligned}
\left(\sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1}\right)^{\mathsf T}W_V^{(1)}f_{K+j_1}
&=-\eta_V\left(\sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1}\right)^{\mathsf T}\sum_k p_kq_{j_1}A_{K+j_1}\bar f \\
&\quad+\eta_V\left(\sum_k p_kq_{j_1}B_{K+j_1}\right)\left(\sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1}\right)^{\mathsf T}f_{K+j_1} \\
&\quad+\eta_V\sum_k p_kq_{j_1}C_{K+j_1}\left(\sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1}\right)^{\mathsf T}f_k \\
&=-\epsilon_{K+j_1}\eta_V\left(\sum_k p_kq_{j_1}B_{K+j_1}\right)+\eta_V\sum_k\epsilon_kp_kq_{j_1}C_{K+j_1} \\
&=-\Theta\left(Te^{-\Theta(T^{1-\beta})}\right),
\end{aligned} i = K + j 1 ∑ ϵ i f i − ϵ K + j 1 f K + j 1 T W V ( 1 ) f K + j 1 = − η V i = K + j 1 ∑ ϵ i f i − ϵ K + j 1 f K + j 1 T k ∑ p k q j 1 A K + j 1 f ˉ + η V ( k ∑ p k q j 1 B K + j 1 ) i = K + j 1 ∑ ϵ i f i − ϵ K + j 1 f K + j 1 T f K + j 1 + η V k ∑ p k q j 1 C K + j 1 i = K + j 1 ∑ ϵ i f i − ϵ K + j 1 f K + j 1 T f k = − ϵ K + j 1 η V ( k ∑ p k q j 1 B K + j 1 ) + η V k ∑ ϵ k p k q j 1 C K + j 1 = − Θ ( T e − Θ ( T 1 − β ) ) ,
where the first equation comes from direct expansion of W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 using results in Lemma D.5 , the second equation uses the orthonormality of embeddings, and the third equation use the assumption in Theorem D.1 and the order of the coefficient in Eqn. (D.8). Use the same technique, we have
( ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 ) T W V ( 1 ) f k 1 = Θ ( ( log T ) 2 e − Θ ( T 1 − β ) ) , \left(\sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1}\right)^{\mathsf T}W_V^{(1)}f_{k_1}
=\Theta\left((\log T)^2e^{-\Theta(T^{1-\beta})}\right), i = K + j 1 ∑ ϵ i f i − ϵ K + j 1 f K + j 1 T W V ( 1 ) f k 1 = Θ ( ( log T ) 2 e − Θ ( T 1 − β ) ) ,
( ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 ) T W V ( 1 ) f K + J + k 1 = Θ ( log T T β e − Θ ( T 1 − β ) ) . \left(\sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1}\right)^{\mathsf T}W_V^{(1)}f_{K+J+k_1}
=\Theta\left(\frac{\log T}{T^\beta}e^{-\Theta(T^{1-\beta})}\right). i = K + j 1 ∑ ϵ i f i − ϵ K + j 1 f K + j 1 T W V ( 1 ) f K + J + k 1 = Θ ( T β log T e − Θ ( T 1 − β ) ) .
To simplify the computation, we denote a scaler similar to the previous γ ( k 1 , j 1 , t , a ) \gamma(k_1,j_1,t,a) γ ( k 1 , j 1 , t , a ) , which is ξ ( k 1 , j 1 , t , a ) = ( ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 ) T ( o t − W V ( 1 ) f a ) / ( t + 1 ) \xi(k_1,j_1,t,a)=\left(\sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1}\right)^{\mathsf T}(o_t-W_V^{(1)}f_a)/(t+1) ξ ( k 1 , j 1 , t , a ) = ( ∑ i = K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 ) T ( o t − W V ( 1 ) f a ) / ( t + 1 ) to pack the term befor e t f x l T e_tf_{x_l}^{\mathsf T} e t f x l T in Eqn. (D.11) for a sequence with feature class k 1 k_1 k 1 and background class j 1 j_1 j 1 when computing the loss, and x l = a x_l=a x l = a . And for different x l x_l x l , we have
ξ ( k 1 , j 1 , t , K + j 1 ) = 1 t + 1 ( ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 ) T ( o t − W V ( 1 ) f K + j 1 ) = O ( T t + 1 e − Θ ( T 1 − β ) ) . \begin{aligned}
\xi(k_1,j_1,t,K+j_1)
&=\frac{1}{t+1}\left(\sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1}\right)^{\mathsf T}(o_t-W_V^{(1)}f_{K+j_1}) \\
&=O\left(\frac{T}{t+1}e^{-\Theta(T^{1-\beta})}\right).
\end{aligned} ξ ( k 1 , j 1 , t , K + j 1 ) = t + 1 1 i = K + j 1 ∑ ϵ i f i − ϵ K + j 1 f K + j 1 T ( o t − W V ( 1 ) f K + j 1 ) = O ( t + 1 T e − Θ ( T 1 − β ) ) .
where the second equation uses the previous expansion results of o t − W V ( 1 ) f K + j 1 o_t-W_V^{(1)}f_{K+j_1} o t − W V ( 1 ) f K + j 1 and plug in the results of the order of the previous quadratic form of the residual part ∑ i ≠ K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 \sum_{i\ne K+j_1}\epsilon_i f_i-\epsilon_{K+j_1}f_{K+j_1} ∑ i = K + j 1 ϵ i f i − ϵ K + j 1 f K + j 1 . Use similar technique for x l = k 1 x_l=k_1 x l = k 1 and x l = K + J + k 1 x_l=K+J+k_1 x l = K + J + k 1 , we have
ξ ( k 1 , j 1 , t , k 1 ) = O ( T t + 1 e − Θ ( T 1 − β ) ) , ξ ( k 1 , j 1 , t , K + J + k 1 ) = O ( T t + 1 e − Θ ( T 1 − β ) ) . \xi(k_1,j_1,t,k_1)=O\left(\frac{T}{t+1}e^{-\Theta(T^{1-\beta})}\right),\qquad\xi(k_1,j_1,t,K+J+k_1)=O\left(\frac{T}{t+1}e^{-\Theta(T^{1-\beta})}\right). ξ ( k 1 , j 1 , t , k 1 ) = O ( t + 1 T e − Θ ( T 1 − β ) ) , ξ ( k 1 , j 1 , t , K + J + k 1 ) = O ( t + 1 T e − Θ ( T 1 − β ) ) .
For the negative gradient for general per sequence in Eqn. (D.11), we can fixed the input sequence with a visual feature class k 1 k_1 k 1 and visual background class j 1 j_1 j 1 , and expand the summation using the structure of g t g_t g t in Eqn. (D.10) and the next-token structure in Eqn. (D.2), we have
− ∇ W Q K L ( k 1 , j 1 , θ ( 1 ) ) = ∑ t = 1 T − 1 ∑ l = 0 t 1 t + 1 [ g t ⊤ ( o t − W V ( 1 ) f x l ) ] e t f x l ⊤ = ∑ t = τ − 1 τ + L − 2 ∑ l = 0 t ( γ ( k 1 , j 1 , t , x l ) + ξ ( k 1 , j 1 , t , x l ) ) e t f x l ⊤ + ∑ t = 1 τ − 2 ∑ l = 0 t ξ ( k 1 , j 1 , t , x l ) e t f x l ⊤ + ∑ t = τ + L − 1 T − 1 ∑ l = 0 t ξ ( k 1 , j 1 , t , x l ) e t f x l ⊤ = ∑ t = τ − 1 τ + L − 2 ∑ l = 0 t γ ( k 1 , j 1 , t , x l ) e t f x l ⊤ + ∑ t = 1 T − 1 ∑ l = 0 t ξ ( k 1 , j 1 , t , x l ) e t f x l ⊤ . \begin{aligned}
-\nabla_{W_{QK}}\mathcal{L}(k_1,j_1,\theta^{(1)})=\sum_{t=1}^{T-1}\sum_{l=0}^{t}\frac{1}{t+1}\left[g_t^{\top}\left(o_t-W_V^{(1)}f_{x_l}\right)\right]e_t f_{x_l}^{\top} \\
&=\sum_{t=\tau-1}^{\tau+L-2}\sum_{l=0}^{t}\left(\gamma(k_1,j_1,t,x_l)+\xi(k_1,j_1,t,x_l)\right)e_t f_{x_l}^{\top}
+\sum_{t=1}^{\tau-2}\sum_{l=0}^{t}\xi(k_1,j_1,t,x_l)e_t f_{x_l}^{\top}
+\sum_{t=\tau+L-1}^{T-1}\sum_{l=0}^{t}\xi(k_1,j_1,t,x_l)e_t f_{x_l}^{\top} \\
&=\sum_{t=\tau-1}^{\tau+L-2}\sum_{l=0}^{t}\gamma(k_1,j_1,t,x_l)e_t f_{x_l}^{\top}
+\sum_{t=1}^{T-1}\sum_{l=0}^{t}\xi(k_1,j_1,t,x_l)e_t f_{x_l}^{\top}.
\end{aligned} − ∇ W Q K L ( k 1 , j 1 , θ ( 1 ) ) = t = 1 ∑ T − 1 l = 0 ∑ t t + 1 1 [ g t ⊤ ( o t − W V ( 1 ) f x l ) ] e t f x l ⊤ = t = τ − 1 ∑ τ + L − 2 l = 0 ∑ t ( γ ( k 1 , j 1 , t , x l ) + ξ ( k 1 , j 1 , t , x l ) ) e t f x l ⊤ + t = 1 ∑ τ − 2 l = 0 ∑ t ξ ( k 1 , j 1 , t , x l ) e t f x l ⊤ + t = τ + L − 1 ∑ T − 1 l = 0 ∑ t ξ ( k 1 , j 1 , t , x l ) e t f x l ⊤ = t = τ − 1 ∑ τ + L − 2 l = 0 ∑ t γ ( k 1 , j 1 , t , x l ) e t f x l ⊤ + t = 1 ∑ T − 1 l = 0 ∑ t ξ ( k 1 , j 1 , t , x l ) e t f x l ⊤ .
where the second equation is a direct expansion using Eqn. (D.2) and Eqn. (D.10). We can further expand the formula using the data model structure and get
− ∇ W Q K L ( k 1 , j 1 , θ ( 1 ) ) = ∑ t = τ − 1 τ + L − 2 γ ( k 1 , j 1 , t , K + J + k 1 ) e t f K + J + k 1 ⊤ + ∑ t = τ − 1 τ + L − 2 ( τ − 1 ) γ ( k 1 , j 1 , t , K + j 1 ) e t f K + j 1 ⊤ \begin{aligned}
-\nabla_{W_{QK}}\mathcal{L}(k_1,j_1,\theta^{(1)}) \\
&=\sum_{t=\tau-1}^{\tau+L-2}\gamma(k_1,j_1,t,K+J+k_1)e_t f_{K+J+k_1}^{\top}
+\sum_{t=\tau-1}^{\tau+L-2}(\tau-1)\gamma(k_1,j_1,t,K+j_1)e_t f_{K+j_1}^{\top}
\end{aligned} − ∇ W Q K L ( k 1 , j 1 , θ ( 1 ) ) = t = τ − 1 ∑ τ + L − 2 γ ( k 1 , j 1 , t , K + J + k 1 ) e t f K + J + k 1 ⊤ + t = τ − 1 ∑ τ + L − 2 ( τ − 1 ) γ ( k 1 , j 1 , t , K + j 1 ) e t f K + j 1 ⊤
+ ∑ t = τ − 1 τ + L − 2 ( t − τ + 1 ) γ ( k 1 , j 1 , t , k 1 ) e t f k 1 ⊤ + ∑ t = 1 T − 1 ∑ l = 0 t ξ ( k 1 , j 1 , t , x l ) e t f x l ⊤ . \qquad+\sum_{t=\tau-1}^{\tau+L-2}(t-\tau+1)\gamma(k_1,j_1,t,k_1)e_t f_{k_1}^{\top}
+\sum_{t=1}^{T-1}\sum_{l=0}^{t}\xi(k_1,j_1,t,x_l)e_t f_{x_l}^{\top}. + t = τ − 1 ∑ τ + L − 2 ( t − τ + 1 ) γ ( k 1 , j 1 , t , k 1 ) e t f k 1 ⊤ + t = 1 ∑ T − 1 l = 0 ∑ t ξ ( k 1 , j 1 , t , x l ) e t f x l ⊤ .
where the equation comes from group of x l x_l x l , because at τ − 1 ≤ t ≤ τ + L − 2 \tau-1\le t\le\tau+L-2 τ − 1 ≤ t ≤ τ + L − 2 , the prefix contain 1 K + J + k 1 K+J+k_1 K + J + k 1 token, τ − 1 \tau-1 τ − 1 K + j 1 K+j_1 K + j 1 token, and t − τ + 1 t-\tau+1 t − τ + 1 k 1 k_1 k 1 token. The x l x_l x l in the last term is the l l l -th token in the sequence with feature and background k 1 , j 1 k_1,j_1 k 1 , j 1 . We don’t explicitly expand those because we will show that their effect is exponentially small.
Thus, we conclude the proof of Lemma D.8.
Step 7: One-Step Update of W Q K W_{QK} W Q K
With the population gradient of W Q K W_{QK} W Q K , we can compute the updated version W Q K ( 1 ) W_{QK}^{(1)} W Q K ( 1 ) and analyze its properties.
Proposition D.9 (Position-Feature correlation computed by W Q K ( 1 ) W_{QK}^{(1)} W Q K ( 1 ) ). After the second update in Algorithm 2, the query-key matrix W Q K ( 1 ) W_{QK}^{(1)} W Q K ( 1 ) will have the following properties when computes the position-feature correlation
on a sampled sequence with visual feature class k 1 ∈ [ K ] k_1 \in[K] k 1 ∈ [ K ] and visual background class j 1 ∈ [ J ] j_1 \in[J] j 1 ∈ [ J ] :
e t T W Q K ( 1 ) f K + j 1 = η Q K ∑ k = 1 K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) 1 { t ∈ F } + o ( 1 ) , e_t^{\mathsf{T}} W_{QK}^{(1)} f_{K+j_1} = \eta_{QK} \sum_{k=1}^{K} p_k q_{j_1} (\tau-1)\gamma(k,j_1,t,K+j_1)1\{t \in\mathcal{F}\} + o(1), e t T W Q K ( 1 ) f K + j 1 = η Q K k = 1 ∑ K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) 1 { t ∈ F } + o ( 1 ) ,
e t T W Q K ( 1 ) f k 1 = η Q K p k 1 ∑ j = 1 J q j ( t − τ + 1 ) γ ( k 1 , j , t , k 1 ) 1 { t ∈ F } + o ( 1 ) , e_t^{\mathsf{T}} W_{QK}^{(1)} f_{k_1} = \eta_{QK}p_{k_1}\sum_{j=1}^{J}q_j(t-\tau+1)\gamma(k_1,j,t,k_1)1\{t \in\mathcal{F}\} + o(1), e t T W Q K ( 1 ) f k 1 = η Q K p k 1 j = 1 ∑ J q j ( t − τ + 1 ) γ ( k 1 , j , t , k 1 ) 1 { t ∈ F } + o ( 1 ) ,
e t T W Q K ( 1 ) f K + J + k 1 = η Q K p k 1 ∑ j = 1 J q j γ ( k 1 , j , t , K + J + k 1 ) 1 { t ∈ F } + o ( 1 ) , e_t^{\mathsf{T}} W_{QK}^{(1)} f_{K+J+k_1} = \eta_{QK}p_{k_1}\sum_{j=1}^{J}q_j\gamma(k_1,j,t,K+J+k_1)1\{t \in\mathcal{F}\} + o(1), e t T W Q K ( 1 ) f K + J + k 1 = η Q K p k 1 j = 1 ∑ J q j γ ( k 1 , j , t , K + J + k 1 ) 1 { t ∈ F } + o ( 1 ) ,
where F \mathcal{F} F is the set of positions whose subsequent token is a feature, as defined in Eqn. D.6, and the o ( 1 ) o(1) o ( 1 ) term is specifically of order O ( T 2 + β e − Θ ( T 1 − β ) ) O(T^{2+\beta}e^{-\Theta(T^{1-\beta})}) O ( T 2 + β e − Θ ( T 1 − β ) ) .
Proof. From the closed form of population loss in Eqn. (C.3), the population gradient is
∇ W Q K L v i s ( θ ( 1 ) ) = ∑ k = 1 K p k ∑ j = 1 J q j ∇ W Q K L ( k , j ; θ ( 1 ) ) . (21) \nabla_{W_{QK}}\mathcal{L}_{\mathrm{vis}}(\theta^{(1)})=\sum_{k=1}^{K}p_k\sum_{j=1}^{J}q_j\nabla_{W_{QK}}\mathcal{L}(k,j;\theta^{(1)}). \tag*{(21)} ∇ W Q K L vis ( θ ( 1 ) ) = k = 1 ∑ K p k j = 1 ∑ J q j ∇ W Q K L ( k , j ; θ ( 1 ) ) . (21)
After the second update in Algorithm 2, and plug in the results in Lemma D.8, we can have the following form
W Q K ( 1 ) = − η Q K ∑ k = 1 K p k ∑ j = 1 J q j ∇ W Q K L ( k , j ; θ ( 1 ) ) γ ( k , j , t , K + J + k ) e t f K + J + k T + ∑ t = τ − 1 τ + L − 2 ( τ − 1 ) γ ( k , j , t , K + j ) e t f K + j T + ∑ t = τ − 1 τ + L − 2 ( t − τ + 1 ) γ ( k , j , t , k ) e t f k T + ∑ t = 1 T − 1 ∑ l = 0 t ξ ( k , j , t , x l ) e t f x l T , \begin{aligned}
W_{QK}^{(1)}
={}&-\eta_{QK}\sum_{k=1}^{K}p_k\sum_{j=1}^{J}q_j\nabla_{W_{QK}}\mathcal{L}(k,j;\theta^{(1)})\gamma(k,j,t,K+J+k)e_t f_{K+J+k}^{\mathsf{T}}\\
&+\sum_{t=\tau-1}^{\tau+L-2}(\tau-1)\gamma(k,j,t,K+j)e_t f_{K+j}^{\mathsf{T}}
+\sum_{t=\tau-1}^{\tau+L-2}(t-\tau+1)\gamma(k,j,t,k)e_t f_k^{\mathsf{T}}\\
&+\sum_{t=1}^{T-1}\sum_{l=0}^{t}\xi(k,j,t,x_l)e_t f_{x_l}^{\mathsf{T}},
\end{aligned} W Q K ( 1 ) = − η Q K k = 1 ∑ K p k j = 1 ∑ J q j ∇ W Q K L ( k , j ; θ ( 1 ) ) γ ( k , j , t , K + J + k ) e t f K + J + k T + t = τ − 1 ∑ τ + L − 2 ( τ − 1 ) γ ( k , j , t , K + j ) e t f K + j T + t = τ − 1 ∑ τ + L − 2 ( t − τ + 1 ) γ ( k , j , t , k ) e t f k T + t = 1 ∑ T − 1 l = 0 ∑ t ξ ( k , j , t , x l ) e t f x l T ,
where the second step use the results in Lemma D.8. Suppose the input sequence has feature k 1 k_1 k 1 and background j 1 j_1 j 1 , from e t e_t e t , we find the attention between feature f k 1 f_{k_1} f k 1 , f K + j 1 f_{K+j_1} f K + j 1 , f K + J + k 1 f_{K+J+k_1} f K + J + k 1 .
For e t T W Q K ( 1 ) f K + j 1 e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+j_1} e t T W Q K ( 1 ) f K + j 1 , we directly plug in the expansion in Lemma D.8 and get
e t T W Q K ( 1 ) f K + j 1 = η Q K ∑ k = 1 K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) 1 { t ∈ F } + η Q K ∑ k = 1 K p k q j 1 O ( T 2 e − Θ ( T 1 − β ) ) = η Q K ∑ k = 1 K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) 1 { t ∈ F } + O ( T 2 e − Θ ( T 1 − β ) ) , \begin{aligned}
e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+j_1}
={}&\eta_{QK}\sum_{k=1}^{K}p_kq_{j_1}(\tau-1)\gamma(k,j_1,t,K+j_1)1\{t\in\mathcal{F}\}\\
&+\eta_{QK}\sum_{k=1}^{K}p_kq_{j_1}O(T^2e^{-\Theta(T^{1-\beta})}) \\
&=\eta_{QK}\sum_{k=1}^{K}p_kq_{j_1}(\tau-1)\gamma(k,j_1,t,K+j_1)1\{t\in\mathcal{F}\}+O(T^2e^{-\Theta(T^{1-\beta})}),
\end{aligned} e t T W Q K ( 1 ) f K + j 1 = η Q K k = 1 ∑ K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) 1 { t ∈ F } + η Q K k = 1 ∑ K p k q j 1 O ( T 2 e − Θ ( T 1 − β ) ) = η Q K k = 1 ∑ K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) 1 { t ∈ F } + O ( T 2 e − Θ ( T 1 − β ) ) ,
where the first equation also use the orthornormality of embeddings and the last step use the assumptions in Theorem D.1 , which are η Q K = Θ ( T β ) \eta_{QK}=\Theta(T^\beta) η Q K = Θ ( T β ) , q j = 1 / J = Θ ( T − β ) q_j=1/J=\Theta(T^{-\beta}) q j = 1/ J = Θ ( T − β ) .
For e t T W Q K ( 1 ) f k 1 e_t^{\mathsf{T}}W_{QK}^{(1)}f_{k_1} e t T W Q K ( 1 ) f k 1 and e t T W Q K ( 1 ) f K + J + k 1 e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+J+k_1} e t T W Q K ( 1 ) f K + J + k 1 , with the same technique and results in Lemma D.8 and assumption in Theorem D.1 , we can derive
e t T W Q K ( 1 ) f k 1 = η Q K ∑ k = 1 K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) 1 { t ∈ F } + O ( T 2 + β e − Θ ( T 1 − β ) ) , e_t^{\mathsf{T}}W_{QK}^{(1)}f_{k_1}
=\eta_{QK}\sum_{k=1}^{K}p_kq_{j_1}(\tau-1)\gamma(k,j_1,t,K+j_1)1\{t\in\mathcal{F}\}+O(T^{2+\beta}e^{-\Theta(T^{1-\beta})}), e t T W Q K ( 1 ) f k 1 = η Q K k = 1 ∑ K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) 1 { t ∈ F } + O ( T 2 + β e − Θ ( T 1 − β ) ) ,
e t T W Q K ( 1 ) f K + J + k 1 = η Q K p k 1 ∑ j = 1 J q j γ ( k 1 , j , t , K + J + k 1 ) 1 { t ∈ F } + O ( T 2 + β e − Θ ( T 1 − β ) ) . e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+J+k_1}
=\eta_{QK}p_{k_1}\sum_{j=1}^{J}q_j\gamma(k_1,j,t,K+J+k_1)1\{t\in\mathcal{F}\}+O(T^{2+\beta}e^{-\Theta(T^{1-\beta})}). e t T W Q K ( 1 ) f K + J + k 1 = η Q K p k 1 j = 1 ∑ J q j γ ( k 1 , j , t , K + J + k 1 ) 1 { t ∈ F } + O ( T 2 + β e − Θ ( T 1 − β ) ) .
We can notice that the small error provided by the residual in g t g_t g t in Eqn. D.10 is exponentially small, and at most O ( T 2 + β e − Θ ( T 1 − β ) ) O(T^{2+\beta}e^{-\Theta(T^{1-\beta})}) O ( T 2 + β e − Θ ( T 1 − β ) ) . Thus, we conclude the proof of proposition D.9.
Step 8: CFG Analysis by Time Regime
From Eqn. (C.1), we know applying CFG is equivalent to applying CFG to the attention output. We now analyze the CFG on the attention output o t λ = o t + λ ( o t − o t u c ) o_t^\lambda= o_t + \lambda(o_t - o_t^{\mathrm{uc}}) o t λ = o t + λ ( o t − o t uc ) at the trained parameters ( W V ( 1 ) , W Q K ( 1 ) ) (W_V^{(1)}, W_{QK}^{(1)}) ( W V ( 1 ) , W Q K ( 1 ) ) for each time regime. Recall the settings above, for simplicity, we denote logit t \operatorname{logit}_t logit t for logit t c o n d \operatorname{logit}_t^{\mathrm{cond}} logit t cond , and logit t u c \operatorname{logit}_t^{\mathrm{uc}} logit t uc for logit t u n c o n d \operatorname{logit}_t^{\mathrm{uncond}} logit t uncond . For clarity, but we denote the i i i -th element of logit t ∈ R K + J \operatorname{logit}_t \in\mathbb{R}^{K+J} logit t ∈ R K + J as logit t [ i ] \operatorname{logit}_t[i] logit t [ i ] , which also apply for logit t u c \operatorname{logit}_t^{\mathrm{uc}} logit t uc and logit t λ \operatorname{logit}_t^\lambda logit t λ .
Lemma D.10 (Background positions: 1 ≤ t ≤ τ − 2 1 \le t \le\tau- 2 1 ≤ t ≤ τ − 2 ). When 1 ≤ t < τ − 1 1 \le t < \tau- 1 1 ≤ t < τ − 1 , suppose the input tokens are ( K + J + k 1 , ( K + j 1 ) × t ) (K + J + k_1, (K + j_1)^{\times t}) ( K + J + k 1 , ( K + j 1 ) × t ) , when λ < 1 + o ( 1 ) \lambda< 1 + o(1) λ < 1 + o ( 1 ) , where o ( 1 ) o(1) o ( 1 ) denotes a positive vanishing term, the CFG logits satisfies arg max i logit t λ [ i ] = K + j 1 \arg\max_i \operatorname{logit}_t^\lambda[i] = K + j_1 arg max i logit t λ [ i ] = K + j 1 .
Proof. From Proposition D.9, when 1 ≤ t < τ − 1 1 \le t < \tau- 1 1 ≤ t < τ − 1 , suppose the input tokens are [ K + J + k 1 , ( K + j 1 ) × t ] [K + J + k_1, (K + j_1)^{\times t}] [ K + J + k 1 , ( K + j 1 ) × t ] , we have
o t = α t 0 W V ( 1 ) f K + J + k 1 + ∑ l = 1 t α t l W V ( 1 ) f K + j 1 , o t u c = ∑ l = 1 t α t l u c W V ( 1 ) f K + j 1 = W V ( 1 ) f K + j 1 , o_t = \alpha_{t0}W_V^{(1)}f_{K+J+k_1} + \sum_{l=1}^{t}\alpha_{tl}W_V^{(1)}f_{K+j_1}, \quad o_t^{\mathrm{uc}} = \sum_{l=1}^{t}\alpha_{tl}^{\mathrm{uc}}W_V^{(1)}f_{K+j_1} = W_V^{(1)}f_{K+j_1}, o t = α t 0 W V ( 1 ) f K + J + k 1 + l = 1 ∑ t α tl W V ( 1 ) f K + j 1 , o t uc = l = 1 ∑ t α tl uc W V ( 1 ) f K + j 1 = W V ( 1 ) f K + j 1 ,
The output of CFG with λ \lambda λ is
o t λ = o t + λ ( o t − o t u c ) = ( 1 + λ ) ( α t 0 W V ( 1 ) f K + J + k 1 + ∑ l = 1 t α t l W V ( 1 ) f K + j 1 ) − λ W V ( 1 ) f K + j 1 = ( 1 − ( 1 + λ ) α t 0 ) W V ( 1 ) f K + j 1 + ( 1 + λ ) α t 0 W V ( 1 ) f K + J + k 1 , \begin{aligned}
o_t^\lambda= o_t + \lambda(o_t - o_t^{\mathrm{uc}}) \\
&= (1+\lambda)\left(\alpha_{t0}W_V^{(1)}f_{K+J+k_1}+\sum_{l=1}^{t}\alpha_{tl}W_V^{(1)}f_{K+j_1}\right)-\lambda W_V^{(1)}f_{K+j_1} \\
&= \left(1-(1+\lambda)\alpha_{t0}\right)W_V^{(1)}f_{K+j_1}+(1+\lambda)\alpha_{t0}W_V^{(1)}f_{K+J+k_1},
\end{aligned} o t λ = o t + λ ( o t − o t uc ) = ( 1 + λ ) ( α t 0 W V ( 1 ) f K + J + k 1 + l = 1 ∑ t α tl W V ( 1 ) f K + j 1 ) − λ W V ( 1 ) f K + j 1 = ( 1 − ( 1 + λ ) α t 0 ) W V ( 1 ) f K + j 1 + ( 1 + λ ) α t 0 W V ( 1 ) f K + J + k 1 ,
where the second equation comes from expansion of o t , o t u c o_t, o_t^{\mathrm{uc}} o t , o t uc , and the last equation comes from direct computation. For attention score α t 0 \alpha_{t0} α t 0 , 1 ≤ t ≤ τ − 1 1 \le t \le\tau- 1 1 ≤ t ≤ τ − 1 , we have
α t 0 = exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) + ∑ s = 1 t exp ( e s ⊤ W Q K ( 1 ) f K + J + k 1 ) = 1 t + 1 ( 1 + o ( 1 ) ) , \alpha_{t0} = \frac{\exp(e_t^{\top}W_{QK}^{(1)}f_{K+J+k_1})}{\exp(e_t^{\top}W_{QK}^{(1)}f_{K+J+k_1})+\sum_{s=1}^{t}\exp(e_s^{\top}W_{QK}^{(1)}f_{K+J+k_1})} = \frac{1}{t+1}(1+o(1)), α t 0 = exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) + ∑ s = 1 t exp ( e s ⊤ W Q K ( 1 ) f K + J + k 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) = t + 1 1 ( 1 + o ( 1 )) ,
where the last equation using the results in Proposition D.9, that when not inside the feature block, i.e. t ∉ F t \notin\mathcal{F} t ∈ / F , e t ⊤ W Q K ( 1 ) f K + J + k 1 = o ( 1 ) e_t^{\top}W_{QK}^{(1)}f_{K+J+k_1}=o(1) e t ⊤ W Q K ( 1 ) f K + J + k 1 = o ( 1 ) , where the error is exponentially small. Similarly, we know that α t l = ( 1 + o ( 1 ) ) / ( t + 1 ) \alpha_{tl}=(1+o(1))/(t+1) α tl = ( 1 + o ( 1 )) / ( t + 1 ) .
Therefore, we can know that the attention score is asymptotically uniform. With the attention score, we can further expand W V ( 1 ) f K + j 1 , W V ( 1 ) f K + J + k 1 W_V^{(1)}f_{K+j_1}, W_V^{(1)}f_{K+J+k_1} W V ( 1 ) f K + j 1 , W V ( 1 ) f K + J + k 1 using results in Lemma D.5, which can change o t λ o_t^\lambda o t λ into a linear combination of embeddings. Because we use weight tying language model head W l m W_{\mathrm{lm}} W lm , the coefficient before each embedding in o t λ o_t^\lambda o t λ is the corresponding value in logit t λ \operatorname{logit}_t^\lambda logit t λ . Observe that in Lemma D.5: f K + j 1 f_{K+j_1} f K + j 1 has an additional positive term than other f K + j f_{K+j} f K + j in W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 ; f k 1 f_{k_1} f k 1 has an additional positive term than other f k f_k f k in W V ( 1 ) f K + J + k 1 W_V^{(1)}f_{K+J+k_1} W V ( 1 ) f K + J + k 1 . We can know that logit t λ [ K + j 1 ] > logit t λ [ K + j ] \operatorname{logit}_t^\lambda[K+j_1]>\operatorname{logit}_t^\lambda[K+j] logit t λ [ K + j 1 ] > logit t λ [ K + j ] , j ≠ j 1 j\ne j_1 j = j 1 , logit t λ [ k 1 ] > logit t λ [ k ] \operatorname{logit}_t^\lambda[k_1]>\operatorname{logit}_t^\lambda[k] logit t λ [ k 1 ] > logit t λ [ k ] , k ≠ k 1 k\ne k_1 k = k 1 , so we only need to compare those of f K + j 1 f_{K+j_1} f K + j 1 and f k 1 f_{k_1} f k 1 . By expansion using Lemma D.5 and direct subtraction of the coefficient, we have
η V − 1 ( logit t λ [ K + j 1 ] − logit t λ [ k 1 ] ) = ( 1 − ( 1 + λ ) α t 0 ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) + ( 1 + λ ) α t 0 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) , \eta_V^{-1}\left(\operatorname{logit}_t^\lambda[K+j_1]-\operatorname{logit}_t^\lambda[k_1]\right) = \left(1-(1+\lambda)\alpha_{t0}\right)\left(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}\right)
+ (1+\lambda)\alpha_{t0}\left(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1}\right), η V − 1 ( logit t λ [ K + j 1 ] − logit t λ [ k 1 ] ) = ( 1 − ( 1 + λ ) α t 0 ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) + ( 1 + λ ) α t 0 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) ,
where the shared factor in coefficient of f ˉ \bar{f} f ˉ is eliminated. We know that logit t λ [ K + j 1 ] − logit t λ [ k 1 ] > 0 \operatorname{logit}^{\lambda}_{t}[K+j_1]-\operatorname{logit}^{\lambda}_{t}[k_1]>0 logit t λ [ K + j 1 ] − logit t λ [ k 1 ] > 0 holds when
λ < q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 α t 0 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 p k 1 q j 1 − p k 1 q j 1 B ˉ K + J + k 1 + p k 1 C K + J + k 1 ) − 1 = t ( 1 + o ( 1 ) ) \lambda< \frac{q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}}{\alpha_{t0}(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}p_{k_1}q_{j_1}-p_{k_1}q_{j_1}\bar{B}_{K+J+k_1}+p_{k_1}C_{K+J+k_1})}-1
= t(1+o(1)) λ < α t 0 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 p k 1 q j 1 − p k 1 q j 1 B ˉ K + J + k 1 + p k 1 C K + J + k 1 ) q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 − 1 = t ( 1 + o ( 1 ))
where the first equality comes from direct computation to make the gap positive, and the second equality follows from the asymptotic orders of the coefficients in Eqn. (D.8), noting that B K + j 1 B_{K+j_1} B K + j 1 is the dominant term, as well as the previously established order of α t 0 \alpha_{t0} α t 0 . The residual o ( 1 ) o(1) o ( 1 ) here is a positive vanishing term. Therefore, when λ < 1 + o ( 1 ) \lambda<1+o(1) λ < 1 + o ( 1 ) , K + j 1 = arg max i logit t λ [ i ] K+j_1=\operatorname{arg\,max}_i\operatorname{logit}^{\lambda}_{t}[i] K + j 1 = arg max i logit t λ [ i ] , so in greedy decoding at position 1 ≤ t < τ − 1 1\leq t<\tau-1 1 ≤ t < τ − 1 , the model will predict K + j 1 K+j_1 K + j 1 in the next position. Thus, we conclude the proof of Lemma D.10.
Lemma D.11 (Transition position: t = τ − 1 t=\tau-1 t = τ − 1 ). When t = τ − 1 t=\tau-1 t = τ − 1 , suppose the input tokens are ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) ) , when λ > o ( 1 ) \lambda>o(1) λ > o ( 1 ) , where o ( 1 ) o(1) o ( 1 ) denotes a positive vanishing term, the CFG logits satisfies arg max i logit t λ [ i ] = k 1 \operatorname{arg\,max}_i\operatorname{logit}^{\lambda}_{t}[i]=k_1 arg max i logit t λ [ i ] = k 1 .
Proof. Similar to Lemme D.10, from Proposition D.9 , when t = τ − 1 t=\tau-1 t = τ − 1 , suppose the input tokens are [ K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) ] [K+J+k_1,(K+j_1)^{\times(\tau-1)}] [ K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) ] , we have
o t = α t 0 W V ( 1 ) f K + J + k 1 + ∑ l = 1 τ − 1 α t l W V ( 1 ) f K + j 1 , o t u c = ∑ l = 1 τ − 1 α t l u c W V ( 1 ) f K + j 1 = W V ( 1 ) f K + j 1 o_t=\alpha_{t0}W_V^{(1)}f_{K+J+k_1}+\sum_{l=1}^{\tau-1}\alpha_{tl}W_V^{(1)}f_{K+j_1},\qquad o_t^{\mathrm{uc}}=\sum_{l=1}^{\tau-1}\alpha_{tl}^{\mathrm{uc}}W_V^{(1)}f_{K+j_1}=W_V^{(1)}f_{K+j_1} o t = α t 0 W V ( 1 ) f K + J + k 1 + l = 1 ∑ τ − 1 α tl W V ( 1 ) f K + j 1 , o t uc = l = 1 ∑ τ − 1 α tl uc W V ( 1 ) f K + j 1 = W V ( 1 ) f K + j 1
The output of CFG with λ \lambda λ is
o t λ = o t + λ ( o t − o t u c ) = ( 1 − ( 1 + λ ) α t 0 ) W V ( 1 ) f K + j 1 + λ α t 0 W V ( 1 ) f K + J + k 1 o_t^\lambda=o_t+\lambda(o_t-o_t^{\mathrm{uc}})=(1-(1+\lambda)\alpha_{t0})W_V^{(1)}f_{K+j_1}+\lambda\alpha_{t0}W_V^{(1)}f_{K+J+k_1} o t λ = o t + λ ( o t − o t uc ) = ( 1 − ( 1 + λ ) α t 0 ) W V ( 1 ) f K + j 1 + λ α t 0 W V ( 1 ) f K + J + k 1
where we use the same computation as Lemma D.10. For attention score α t 0 \alpha_{t0} α t 0 , t = τ − 1 t=\tau-1 t = τ − 1 , we have
α t 0 = exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) + ∑ s = 1 τ − 1 exp ( e t ⊤ W Q K ( 1 ) f K + j 1 ) = 1 1 + ( τ − 1 ) exp ( e t ⊤ W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) ) . \alpha_{t0}=\frac{\exp(e_t^\top W_{QK}^{(1)}f_{K+J+k_1})}{\exp(e_t^\top W_{QK}^{(1)}f_{K+J+k_1})+\sum_{s=1}^{\tau-1}\exp(e_t^\top W_{QK}^{(1)}f_{K+j_1})}
=\frac{1}{1+(\tau-1)\exp\left(e_t^\top W_{QK}^{(1)}(f_{K+j_1}-f_{K+J+k_1})\right)}. α t 0 = exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) + ∑ s = 1 τ − 1 exp ( e t ⊤ W Q K ( 1 ) f K + j 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) = 1 + ( τ − 1 ) exp ( e t ⊤ W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) ) 1 .
where we divide exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) \exp(e_t^\top W_{QK}^{(1)}f_{K+J+k_1}) exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) from numerator and denominator. So we need to focus on the order of e t ⊤ W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) e_t^\top W_{QK}^{(1)}(f_{K+j_1}-f_{K+J+k_1}) e t ⊤ W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) . Using the results in Lemma D.8, because t = τ − 1 t=\tau-1 t = τ − 1 , n F ( t ) = 0 n_F(t)=0 n F ( t ) = 0 , we can know that
γ ( k , j , t , K + j 1 ) = 1 ( t + 1 ) 2 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) − 1 ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) , \gamma(k,j,t,K+j_1)=\frac{1}{(t+1)^2}(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1})
-\frac{1}{(t+1)^2}(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}), γ ( k , j , t , K + j 1 ) = ( t + 1 ) 2 1 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) − ( t + 1 ) 2 1 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) ,
γ ( k , j , t , K + J + k 1 ) = − 1 ( t + 1 ) 2 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + t − n F ( t ) ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) . \gamma(k,j,t,K+J+k_1)=-\frac{1}{(t+1)^2}(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1})
+\frac{t-n_F(t)}{(t+1)^2}(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}). γ ( k , j , t , K + J + k 1 ) = − ( t + 1 ) 2 1 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + ( t + 1 ) 2 t − n F ( t ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) .
Using the results in Proposition D.9 to compute the position-feature correlation, and substract those with f ˉ K + j 1 \bar{f}_{K+j_1} f ˉ K + j 1 and f ˉ K + J + k 1 \bar{f}_{K+J+k_1} f ˉ K + J + k 1 , we have
e t T W Q ( 1 ) ( f K + j 1 − f K + J + k 1 ) = η Q K ∑ k = 1 K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) − η Q K p k 1 ∑ j = 1 J q j γ ( k 1 , j , t , K + J + k 1 ) + o ( 1 ) = − Θ ( T 1 − β ) , e_t^{\mathsf{T}}W_Q^{(1)}\left(f_{K+j_1}-f_{K+J+k_1}\right)
= \eta Q_K \sum_{k=1}^{K}p_kq_{j_1}(\tau-1)\gamma(k,j_1,t,K+j_1)-\eta Q_Kp_{k_1}\sum_{j=1}^{J}q_j\gamma(k_1,j,t,K+J+k_1)+o(1)
= -\Theta(T^{1-\beta}), e t T W Q ( 1 ) ( f K + j 1 − f K + J + k 1 ) = η Q K k = 1 ∑ K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) − η Q K p k 1 j = 1 ∑ J q j γ ( k 1 , j , t , K + J + k 1 ) + o ( 1 ) = − Θ ( T 1 − β ) ,
where the second equation uses the order in Eqn. (D.8) and the assumptions in Theorem D.1 that τ = Θ ( T β ) \tau=\Theta(T^\beta) τ = Θ ( T β ) , q j = Θ ( T − β ) q_j=\Theta(T^{-\beta}) q j = Θ ( T − β ) . Therefore, we can get the attention score
α t 0 = 1 1 + Θ ( T β ) exp ( − Θ ( T 1 − β ) ) = 1 + o ( 1 ) , \alpha_{t0}=\frac{1}{1+\Theta(T^\beta)\exp\left(-\Theta(T^{1-\beta})\right)}=1+o(1), α t 0 = 1 + Θ ( T β ) exp ( − Θ ( T 1 − β ) ) 1 = 1 + o ( 1 ) ,
where the first equation use the assumption that τ = Θ ( T β ) \tau=\Theta(T^\beta) τ = Θ ( T β ) . So we can observe that the attention score for conditional model is concentrates on the text token at t = 0 t=0 t = 0 . With the attention score, we can further expand W V ( 1 ) f K + j 1 , W V ( 1 ) f K + J + k 1 W_V^{(1)}f_{K+j_1},W_V^{(1)}f_{K+J+k_1} W V ( 1 ) f K + j 1 , W V ( 1 ) f K + J + k 1 using results in Lemma D.5, which can change α t λ \alpha_t^\lambda α t λ into a linear combination of embeddings. Similar to Lemma D.10, we compare the logits by comparing the coefficient before embeddings. Observe that in Lemma D.5: f K + j 1 f_{K+j_1} f K + j 1 has an additional positive term than other f K + j f_{K+j} f K + j in W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 ; f k 1 f_{k_1} f k 1 has an additional positive term than other f k f_k f k in W V ( 1 ) f K + J + k 1 W_V^{(1)}f_{K+J+k_1} W V ( 1 ) f K + J + k 1 . At t = τ − 1 t=\tau-1 t = τ − 1 we can observe that logit t λ [ K + j 1 ] > logit t λ [ K + j ] \operatorname{logit}_t^\lambda[K+j_1]>\operatorname{logit}_t^\lambda[K+j] logit t λ [ K + j 1 ] > logit t λ [ K + j ] , j ≠ j 1 j\ne j_1 j = j 1 , logit t λ [ k 1 ] > logit t λ [ k ] \operatorname{logit}_t^\lambda[k_1]>\operatorname{logit}_t^\lambda[k] logit t λ [ k 1 ] > logit t λ [ k ] , k ≠ k 1 k\ne k_1 k = k 1 , so we only need to compare those of f K + j 1 f_{K+j_1} f K + j 1 and f k 1 f_{k_1} f k 1 . By expansion using Lemma D.5 and direct substraction of the coefficient, we have
η V − 1 ( logit t λ [ K + j 1 ] − logit t λ [ k 1 ] ) = ( 1 − ( 1 + λ ) α t 0 ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) + ( 1 + λ ) α t 0 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) , \eta_V^{-1}\left(\operatorname{logit}_t^\lambda[K+j_1]-\operatorname{logit}_t^\lambda[k_1]\right)
=\left(1-(1+\lambda)\alpha_{t0}\right)\left(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}\right)
+\left(1+\lambda\right)\alpha_{t0}\left(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1}\right), η V − 1 ( logit t λ [ K + j 1 ] − logit t λ [ k 1 ] ) = ( 1 − ( 1 + λ ) α t 0 ) ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) + ( 1 + λ ) α t 0 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) ,
where the shared factor in coefficient of f ˉ \bar{f} f ˉ is eliminated. We know that logit t λ [ K + j 1 ] − logit t λ [ k 1 ] < 0 \operatorname{logit}_t^\lambda[K+j_1]-\operatorname{logit}_t^\lambda[k_1]<0 logit t λ [ K + j 1 ] − logit t λ [ k 1 ] < 0 holds when
λ > q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 α t 0 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 + p k 1 q j 1 − B K + J + k 1 + p k 1 C K + J + k 1 ) − 1 = o ( 1 ) , \lambda>\frac{q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}}{\alpha_{t0}\left(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}+p_{k_1}q_{j_1}-B_{K+J+k_1}+p_{k_1}C_{K+J+k_1}\right)}-1=o(1), λ > α t 0 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 + p k 1 q j 1 − B K + J + k 1 + p k 1 C K + J + k 1 ) q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 − 1 = o ( 1 ) ,
where the first equality comes from direct computation to make the gap positive, and the second equality follows from the asymptotic orders of the coefficients in Eqn. (D.8), noting that B K + j 1 B_{K+j_1} B K + j 1 is the dominant term, as well as the previously established order of α t 0 \alpha_{t0} α t 0 . The o ( 1 ) o(1) o ( 1 ) here is a positive vanishing term. Therefore, when λ > o ( 1 ) \lambda>o(1) λ > o ( 1 ) , k 1 = a r g m a x i logit t λ [ i ] k_1=\mathop{\rm arg\,max}_i\operatorname{logit}_t^\lambda[i] k 1 = arg max i logit t λ [ i ] , so in greedy decoding, the model will predict k 1 k_1 k 1 in the next position, thus successfully predict the feature tokens.
Thus, we conclude the proof of Lemma D.11.
Lemma D.12 (Feature block: τ ≤ t ≤ τ + L − 2 \tau\le t\le\tau+L-2 τ ≤ t ≤ τ + L − 2 ). When τ ≤ t ≤ τ + L − 2 \tau\le t\le\tau+L-2 τ ≤ t ≤ τ + L − 2 , suppose the input tokens are ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × ( t − τ + 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)},(k_1)^{\times(t-\tau+1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × ( t − τ + 1 ) ) , when λ < 1 + o ( 1 ) \lambda<1+o(1) λ < 1 + o ( 1 ) , where o ( 1 ) o(1) o ( 1 ) denotes a positive vanishing term, the CFG logits satisfies a r g m a x i logit t λ [ i ] = k 1 \mathop{\rm arg\,max}_i\operatorname{logit}_t^\lambda[i]=k_1 arg max i logit t λ [ i ] = k 1 .
Proof. When τ ≤ t ≤ τ + L − 2 \tau\le t\le\tau+L-2 τ ≤ t ≤ τ + L − 2 , there are some feature token after transition. Suppose the input tokens are ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , k 1 × ( t − τ + 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)},k_1^{\times(t-\tau+1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , k 1 × ( t − τ + 1 ) ) , we have
o t = α t 0 W V ( 1 ) f K + J + k 1 + ∑ l = 1 τ − 1 α t l W V ( 1 ) f K + j 1 + ∑ l = τ t α t l W V ( 1 ) f k 1 , o_t=\alpha_{t0}W_V^{(1)}f_{K+J+k_1}+\sum_{l=1}^{\tau-1}\alpha_{tl}W_V^{(1)}f_{K+j_1}+\sum_{l=\tau}^{t}\alpha_{tl}W_V^{(1)}f_{k_1}, o t = α t 0 W V ( 1 ) f K + J + k 1 + l = 1 ∑ τ − 1 α tl W V ( 1 ) f K + j 1 + l = τ ∑ t α tl W V ( 1 ) f k 1 ,
o t u c = ∑ l = 1 t α t l u c W V ( 1 ) f K + j 1 + ∑ l = τ t α t l u c W V ( 1 ) f k 1 , o_t^{\mathrm{uc}}=\sum_{l=1}^{t}\alpha_{tl}^{\mathrm{uc}}W_V^{(1)}f_{K+j_1}+\sum_{l=\tau}^{t}\alpha_{tl}^{\mathrm{uc}}W_V^{(1)}f_{k_1}, o t uc = l = 1 ∑ t α tl uc W V ( 1 ) f K + j 1 + l = τ ∑ t α tl uc W V ( 1 ) f k 1 ,
which are direct expansion using the definition. Therefore, we know that
o t λ = o t + λ ( o t − o t u c ) = ( − λ ∑ l = 1 τ − 1 α t l u c + ( 1 + λ ) ∑ t = 1 τ − 1 α t l ) W V ( 1 ) f K + j 1 + ( − λ ∑ l = τ t α t l u c + ( 1 + λ ) ∑ l = τ t α t l ) W V ( 1 ) f k 1 + ( 1 + λ ) α t 0 W V ( 1 ) f K + J + k 1 , \begin{aligned}
o_t^\lambda&= o_t+\lambda(o_t-o_t^{\mathrm{uc}}) \\
&=\left(-\lambda\sum_{l=1}^{\tau-1}\alpha_{tl}^{\mathrm{uc}}+(1+\lambda)\sum_{t=1}^{\tau-1}\alpha_{tl}\right)W_V^{(1)}f_{K+j_1}
+\left(-\lambda\sum_{l=\tau}^{t}\alpha_{tl}^{\mathrm{uc}}+(1+\lambda)\sum_{l=\tau}^{t}\alpha_{tl}\right)W_V^{(1)}f_{k_1} \\
&\quad+(1+\lambda)\alpha_{t0}W_V^{(1)}f_{K+J+k_1},
\end{aligned} o t λ = o t + λ ( o t − o t uc ) = ( − λ l = 1 ∑ τ − 1 α tl uc + ( 1 + λ ) t = 1 ∑ τ − 1 α tl ) W V ( 1 ) f K + j 1 + ( − λ l = τ ∑ t α tl uc + ( 1 + λ ) l = τ ∑ t α tl ) W V ( 1 ) f k 1 + ( 1 + λ ) α t 0 W V ( 1 ) f K + J + k 1 ,
where the second equation comes from direct expansion of o t , o t u c o_t,o_t^{\mathrm{uc}} o t , o t uc and group according to embeddings. Now we need to compute the attention scores. Because of the structure, we group the attention score by the embeddings. Firstly, for conditional model, we have
α t 0 = exp ( e t T W Q K ( 1 ) f K + J + k 1 ) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) + ( τ − 1 ) exp ( e t T W Q K ( 1 ) f K + j 1 ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) f k 1 ) = 1 1 + ( τ − 1 ) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) ( f k 1 − f K + J + k 1 ) ) , \begin{aligned}
\alpha_{t0}=\frac{\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+J+k_1})}{\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+J+k_1})+(\tau-1)\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+j_1})+(t-\tau+1)\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{k_1})} \\
&=\frac{1}{1+(\tau-1)\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}(f_{K+j_1}-f_{K+J+k_1}))+(t-\tau+1)\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}(f_{k_1}-f_{K+J+k_1}))},
\end{aligned} α t 0 = exp ( e t T W Q K ( 1 ) f K + J + k 1 ) + ( τ − 1 ) exp ( e t T W Q K ( 1 ) f K + j 1 ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) f k 1 ) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) = 1 + ( τ − 1 ) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 )) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) ( f k 1 − f K + J + k 1 )) 1 ,
where we divide exp ( e t T W Q K ( 1 ) f K + J + k 1 ) \exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+J+k_1}) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) from the numerator and denominator. Similarly, using the same technique, we have
∑ l = τ t α t l = t − τ + 1 exp ( e t T W Q K ( 1 ) ( f K + J + k 1 − f k 1 ) ) + ( τ − 1 ) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f k 1 ) ) + ( t − τ + 1 ) , \sum_{l=\tau}^{t}\alpha_{tl}=\frac{t-\tau+1}{\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}(f_{K+J+k_1}-f_{k_1}))+(\tau-1)\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}(f_{K+j_1}-f_{k_1}))+(t-\tau+1)}, l = τ ∑ t α tl = exp ( e t T W Q K ( 1 ) ( f K + J + k 1 − f k 1 )) + ( τ − 1 ) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f k 1 )) + ( t − τ + 1 ) t − τ + 1 ,
∑ l = 1 τ − 1 α t l = τ − 1 exp ( e t T W Q K ( 1 ) ( f K + J + k 1 − f K + j 1 ) ) + ( τ − 1 ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) ( f k 1 − f K + j 1 ) ) , \sum_{l=1}^{\tau-1}\alpha_{tl}=\frac{\tau-1}{\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}(f_{K+J+k_1}-f_{K+j_1}))+(\tau-1)+(t-\tau+1)\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}(f_{k_1}-f_{K+j_1}))}, l = 1 ∑ τ − 1 α tl = exp ( e t T W Q K ( 1 ) ( f K + J + k 1 − f K + j 1 )) + ( τ − 1 ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) ( f k 1 − f K + j 1 )) τ − 1 ,
where we also write the softmax function explicitly, but divide exp ( e t T W Q K ( 1 ) f K + j 1 ) \exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+j_1}) exp ( e t T W Q K ( 1 ) f K + j 1 ) and exp ( e t T W Q K ( 1 ) f k 1 ) \exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{k_1}) exp ( e t T W Q K ( 1 ) f k 1 ) respectively.
Similar to conditional model, but expand with a different softmax structure in unconditional model, we have
∑ l = τ t α t l u c = ∑ l = τ t exp ( e t T W Q K ( 1 ) f k 1 ) ∑ l = 1 τ − 1 exp ( e t T W Q K ( 1 ) f K + j 1 ) + ∑ l = τ t exp ( e t T W Q K ( 1 ) f k 1 ) = t − τ + 1 ( τ − 1 ) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f k 1 ) ) + ( t − τ + 1 ) , \begin{aligned}
\sum_{l=\tau}^{t}\alpha_{tl}^{\mathrm{uc}}=\frac{\sum_{l=\tau}^{t}\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{k_1})}{\sum_{l=1}^{\tau-1}\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+j_1})+\sum_{l=\tau}^{t}\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{k_1})} \\
&=\frac{t-\tau+1}{(\tau-1)\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}(f_{K+j_1}-f_{k_1}))+(t-\tau+1)},
\end{aligned} l = τ ∑ t α tl uc = ∑ l = 1 τ − 1 exp ( e t T W Q K ( 1 ) f K + j 1 ) + ∑ l = τ t exp ( e t T W Q K ( 1 ) f k 1 ) ∑ l = τ t exp ( e t T W Q K ( 1 ) f k 1 ) = ( τ − 1 ) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f k 1 )) + ( t − τ + 1 ) t − τ + 1 ,
where we divide exp ( e t T W Q K ( 1 ) f k 1 ) \exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{k_1}) exp ( e t T W Q K ( 1 ) f k 1 ) from the numerator and denominator. Similarly, using the same technique, we have
∑ l = 1 τ − 1 α t l u c = τ − 1 ( τ − 1 ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) ( f k 1 − f K + j 1 ) ) , \sum_{l=1}^{\tau-1}\alpha_{tl}^{\mathrm{uc}}=\frac{\tau-1}{(\tau-1)+(t-\tau+1)\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}(f_{k_1}-f_{K+j_1}))}, l = 1 ∑ τ − 1 α tl uc = ( τ − 1 ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) ( f k 1 − f K + j 1 )) τ − 1 ,
where we also write the softmax function explicitly, but divide exp ( e t T W Q K ( 1 ) f K + j 1 ) \exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+j_1}) exp ( e t T W Q K ( 1 ) f K + j 1 ) .
From Eqn. (D.4), we know that within τ ≤ t ≤ τ + L − 1 \tau\le t\le\tau+L-1 τ ≤ t ≤ τ + L − 1 , we have n F ( t ) = t − τ + 1 n_F(t)=t-\tau+1 n F ( t ) = t − τ + 1 , so using results in Lemma D.8, we know that
γ ( k , j , t , K + j 1 ) = 1 ( t + 1 ) 2 ( p k q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + t − τ + 1 ( t + 1 ) 2 ( p k q j 1 B k 1 − p k 1 C k 1 ) − t − τ + 2 ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) , \begin{aligned}
\gamma(k,j,t,K+j_1)
&=\frac{1}{(t+1)^2}(p_kq_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1})+\frac{t-\tau+1}{(t+1)^2}(p_kq_{j_1}B_{k_1}-p_{k_1}C_{k_1})\\
&\quad-\frac{t-\tau+2}{(t+1)^2}(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}),
\end{aligned} γ ( k , j , t , K + j 1 ) = ( t + 1 ) 2 1 ( p k q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + ( t + 1 ) 2 t − τ + 1 ( p k q j 1 B k 1 − p k 1 C k 1 ) − ( t + 1 ) 2 t − τ + 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) ,
γ ( k , j , t , k 1 ) = 1 ( t + 1 ) 2 ( p k q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) − τ ( t + 1 ) 2 ( p k q j 1 B k 1 − p k 1 C k 1 ) + τ − 1 ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) , \begin{aligned}
\gamma(k,j,t,k_1)
&=\frac{1}{(t+1)^2}(p_kq_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1})-\frac{\tau}{(t+1)^2}(p_kq_{j_1}B_{k_1}-p_{k_1}C_{k_1})\\
&\quad+\frac{\tau-1}{(t+1)^2}(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}),
\end{aligned} γ ( k , j , t , k 1 ) = ( t + 1 ) 2 1 ( p k q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) − ( t + 1 ) 2 τ ( p k q j 1 B k 1 − p k 1 C k 1 ) + ( t + 1 ) 2 τ − 1 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) ,
γ ( k , j , t , K + J + k 1 ) = − t ( t + 1 ) 2 ( p k q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + t − τ + 1 ( t + 1 ) 2 ( p k q j 1 B k 1 − p k 1 C k 1 ) + τ − 1 ( t + 1 ) 2 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) . \begin{aligned}
\gamma(k,j,t,K+J+k_1)
&=-\frac{t}{(t+1)^2}(p_kq_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1})+\frac{t-\tau+1}{(t+1)^2}(p_kq_{j_1}B_{k_1}-p_{k_1}C_{k_1})\\
&\quad+\frac{\tau-1}{(t+1)^2}(q_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1}).
\end{aligned} γ ( k , j , t , K + J + k 1 ) = − ( t + 1 ) 2 t ( p k q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) + ( t + 1 ) 2 t − τ + 1 ( p k q j 1 B k 1 − p k 1 C k 1 ) + ( t + 1 ) 2 τ − 1 ( q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) .
where we substitute the value of n F ( t ) n_F(t) n F ( t ) explicitly into γ \gamma γ . So from the structure of attention value, we need to compute the value of the different of position-feature correlation. So using the results in Proposition D.9 to compute the position-feature correlation, and substract those with f K + j 1 f_{K+j_1} f K + j 1 and f K + J + k 1 f_{K+J+k_1} f K + J + k 1 , we have
e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) = η Q K ∑ k = 1 K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) − η Q K p k 1 ∑ j = 1 J q j γ ( k 1 , j , t , K + J + k 1 ) + o ( 1 ) = − Θ ( T 1 − β ) , \begin{aligned}
e_t^{\mathsf{T}}W_{Q_K}^{(1)}(f_{K+j_1}-f_{K+J+k_1})
&=\eta_{Q_K}\sum_{k=1}^{K}p_kq_{j_1}(\tau-1)\gamma(k,j_1,t,K+j_1)-\eta_{Q_K}p_{k_1}\sum_{j=1}^{J}q_j\gamma(k_1,j,t,K+J+k_1)+o(1)\\
&=-\Theta(T^{1-\beta}),
\end{aligned} e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) = η Q K k = 1 ∑ K p k q j 1 ( τ − 1 ) γ ( k , j 1 , t , K + j 1 ) − η Q K p k 1 j = 1 ∑ J q j γ ( k 1 , j , t , K + J + k 1 ) + o ( 1 ) = − Θ ( T 1 − β ) ,
where the second equation uses the asymptotic order in Eqn. (D.8) and the assumptions in Theorem D.1 that τ = Θ ( T β ) \tau=\Theta(T^\beta) τ = Θ ( T β ) , q j = Θ ( T − β ) q_j=\Theta(T^{-\beta}) q j = Θ ( T − β ) . With the same technique, we can similarly get
e t T W Q K ( 1 ) ( f K + j 1 − f k 1 ) = − Θ ( ( t − τ + 1 ) T 1 − β ) . e_t^{\mathsf{T}}W_{Q_K}^{(1)}(f_{K+j_1}-f_{k_1})=-\Theta((t-\tau+1)T^{1-\beta}). e t T W Q K ( 1 ) ( f K + j 1 − f k 1 ) = − Θ (( t − τ + 1 ) T 1 − β ) .
However, the computation of e t T W Q K ( 1 ) ( f K + j 1 − f k 1 ) e_t^{\mathsf{T}}W_{Q_K}^{(1)}(f_{K+j_1}-f_{k_1}) e t T W Q K ( 1 ) ( f K + j 1 − f k 1 ) is more difficult, and we should firstly compute a intermediate results
( t − τ + 1 ) γ ( k 1 , j , t , k 1 ) − γ ( k 1 , j , t , K + J + k 1 ) = ( t − τ ) ( τ − 1 ) ( t + 1 ) 2 ( p k q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) + 2 t − τ + 1 ( t + 1 ) 2 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) − ( t − τ + 1 ) ( τ + 1 ) ( t + 1 ) 2 ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) = { Θ ( ( t − τ ) T 1 − 2 β ) , τ < t ≤ τ + L − 2 , O ( ( log T ) 2 T 2 β ) , t = τ , \begin{aligned}
(t-\tau+1)\gamma(k_1,j,t,k_1)-\gamma(k_1,j,t,K+J+k_1)
&=\frac{(t-\tau)(\tau-1)}{(t+1)^2}(p_kq_{j_1}B_{K+j_1}-p_{k_1}q_{j_1}C_{K+j_1})\\
&\quad+\frac{2t-\tau+1}{(t+1)^2}(p_{k_1}q_{j_1}B_{K+J+k_1}-p_{k_1}C_{K+J+k_1})\\
&\quad-\frac{(t-\tau+1)(\tau+1)}{(t+1)^2}(p_{k_1}q_{j_1}B_{k_1}-p_{k_1}C_{k_1})\\
&=\begin{cases}
\Theta((t-\tau)T^{1-2\beta}), & \tau<t\le\tau+L-2,\\
O\left(\dfrac{(\log T)^2}{T^{2\beta}}\right), & t=\tau,
\end{cases}
\end{aligned} ( t − τ + 1 ) γ ( k 1 , j , t , k 1 ) − γ ( k 1 , j , t , K + J + k 1 ) = ( t + 1 ) 2 ( t − τ ) ( τ − 1 ) ( p k q j 1 B K + j 1 − p k 1 q j 1 C K + j 1 ) + ( t + 1 ) 2 2 t − τ + 1 ( p k 1 q j 1 B K + J + k 1 − p k 1 C K + J + k 1 ) − ( t + 1 ) 2 ( t − τ + 1 ) ( τ + 1 ) ( p k 1 q j 1 B k 1 − p k 1 C k 1 ) = ⎩ ⎨ ⎧ Θ (( t − τ ) T 1 − 2 β ) , O ( T 2 β ( log T ) 2 ) , τ < t ≤ τ + L − 2 , t = τ ,
where the first equation comes from direct expansion using previous explicit form of γ \gamma γ , and the second equation uses the asymptotic order in Eqn. (D.8) with the assumptions in Theorem D.1 that τ = Θ ( T β ) \tau=\Theta(T^\beta) τ = Θ ( T β ) , q j = Θ ( T − β ) q_j=\Theta(T^{-\beta}) q j = Θ ( T − β ) . The case when t = τ t=\tau t = τ is special because t = τ t=\tau t = τ will make the dominant term B K + j 1 B_{K+j_1} B K + j 1 disappear. Therefore, expand e t ⊤ W Q K ( 1 ) ( f K + j 1 − f k 1 ) e_t^\top W_{QK}^{(1)}(f_{K+j_1}-f_{k_1}) e t ⊤ W Q K ( 1 ) ( f K + j 1 − f k 1 ) using Proposition D.9 , we have
e t ⊤ W Q K ( 1 ) ( f k 1 − f K + J + k 1 ) = η Q K p k 1 ∑ j = 1 J q j ( ( t − τ + 1 ) γ ( k 1 , j , t , k 1 ) − γ ( k 1 , j , t , K + J + k 1 ) ) + o ( 1 ) = { Θ ( ( t − τ ) T 1 − β ) , τ < t ≤ τ + L − 2 , O ( ( log T ) 2 T β ) , t = τ , e_t^\top W_{QK}^{(1)}(f_{k_1}-f_{K+J+k_1})
= \eta_{QK}p_{k_1}\sum_{j=1}^{J}q_j\left((t-\tau+1)\gamma(k_1,j,t,k_1)-\gamma(k_1,j,t,K+J+k_1)\right)+o(1)
= \begin{cases}
\Theta((t-\tau)T^{1-\beta}), & \tau<t\leq\tau+L-2,\\
O\left(\dfrac{(\log T)^2}{T^{\beta}}\right), & t=\tau,
\end{cases} e t ⊤ W Q K ( 1 ) ( f k 1 − f K + J + k 1 ) = η Q K p k 1 j = 1 ∑ J q j ( ( t − τ + 1 ) γ ( k 1 , j , t , k 1 ) − γ ( k 1 , j , t , K + J + k 1 ) ) + o ( 1 ) = ⎩ ⎨ ⎧ Θ (( t − τ ) T 1 − β ) , O ( T β ( log T ) 2 ) , τ < t ≤ τ + L − 2 , t = τ ,
where the last equation use the assumption in Theorem D.1 that η Q K = Θ ( T β ) \eta_{QK}=\Theta(T^\beta) η Q K = Θ ( T β ) , q j = Θ ( T − β ) q_j=\Theta(T^{-\beta}) q j = Θ ( T − β ) . Next, we discuss different cases.
When τ < t ≤ τ + L − 2 \tau<t\leq\tau+L-2 τ < t ≤ τ + L − 2 : From the assumption in Theorem D.1 that L = Θ ( log T ) L=\Theta(\log T) L = Θ ( log T ) , we know that 0 ≤ t − τ = O ( log T ) 0\leq t-\tau=O(\log T) 0 ≤ t − τ = O ( log T ) . So plug the results of order of the terms back to the attention score computed above, we have
∑ l = τ t α t l u c = 1 + o ( 1 ) , ∑ l = τ t α t l = 1 + o ( 1 ) , α t 0 = o ( 1 ) , \sum_{l=\tau}^{t}\alpha_{tl}^{\mathrm{uc}}=1+o(1),\qquad\sum_{l=\tau}^{t}\alpha_{tl}=1+o(1),\qquad\alpha_{t0}=o(1), l = τ ∑ t α tl uc = 1 + o ( 1 ) , l = τ ∑ t α tl = 1 + o ( 1 ) , α t 0 = o ( 1 ) ,
where we also use the assumption in Theorem D.1 that τ = Θ ( T β ) \tau=\Theta(T^\beta) τ = Θ ( T β ) , and the error o ( 1 ) o(1) o ( 1 ) is exponentially small. Therefore, we can find that the attention score of conditional and unconditional model concentrate on the feature block τ ≤ l ≤ t \tau\leq l\leq t τ ≤ l ≤ t , so from the construction of o t λ o_t^\lambda o t λ , we have o t λ ≈ W V ( 1 ) f k 1 o_t^\lambda\approx W_V^{(1)}f_{k_1} o t λ ≈ W V ( 1 ) f k 1 with exponentially small error, for λ < 1 + o ( 1 ) \lambda<1+o(1) λ < 1 + o ( 1 ) , for sufficiently large T T T . From Lemma D.5 and order in Eqn. (D.8), we only need to compare feature k 1 k_1 k 1 and any background j ∈ [ J ] j\in[J] j ∈ [ J ] , so substract the coefficient of theem and consider the error, we can get the logit
η V − 1 ( logit t λ [ k 1 ] − logit t λ [ K + j ] ) = p k 1 q j B k 1 − p k 1 C k 1 f k 1 + o ( 1 ) > 0 , \eta_V^{-1}\left(\operatorname{logit}_t^\lambda[k_1]-\operatorname{logit}_t^\lambda[K+j]\right)=p_{k_1}q_jB_{k_1}-p_{k_1}C_{k_1}f_{k_1}+o(1)>0, η V − 1 ( logit t λ [ k 1 ] − logit t λ [ K + j ] ) = p k 1 q j B k 1 − p k 1 C k 1 f k 1 + o ( 1 ) > 0 ,
where we use the results of order in Eqn. (D.8) and the assumption in Theorem D.1 that q j = Θ ( T − β ) q_j=\Theta(T^{-\beta}) q j = Θ ( T − β ) . The error o ( 1 ) o(1) o ( 1 ) here is exponentially small.
When t = τ t=\tau t = τ : Because ∑ l = τ t α t l u c \sum_{l=\tau}^{t}\alpha_{tl}^{\mathrm{uc}} ∑ l = τ t α tl uc does not contain e t ⊤ W Q K ( 1 ) ( f k 1 − f K + J + k 1 ) e_t^\top W_{QK}^{(1)}(f_{k_1}-f_{K+J+k_1}) e t ⊤ W Q K ( 1 ) ( f k 1 − f K + J + k 1 ) , we have the same results ∑ l = τ t α t l u c = 1 + o ( 1 ) \sum_{l=\tau}^{t}\alpha_{tl}^{\mathrm{uc}}=1+o(1) ∑ l = τ t α tl uc = 1 + o ( 1 ) . From the assumption in Theorem D.1 that L = Θ ( log T ) L=\Theta(\log T) L = Θ ( log T ) , we know that t = τ = O ( T β ) t=\tau=O(T^\beta) t = τ = O ( T β ) . So plug the results of order of the terms back to the attention score computed above, we have
∑ l = τ t α t l = t − τ + 1 exp ( O ( ( log T ) 2 T 2 β ) ) + ( τ − 1 ) exp ( − Θ ( ( t − τ + 1 ) T 1 − β ) ) + t − τ + 1 = 1 2 + o ( 1 ) , \sum_{l=\tau}^{t}\alpha_{tl}=\frac{t-\tau+1}{\exp\left(O\left(\frac{(\log T)^2}{T^{2\beta}}\right)\right)+(\tau-1)\exp\left(-\Theta((t-\tau+1)T^{1-\beta})\right)+t-\tau+1}=\frac{1}{2}+o(1), l = τ ∑ t α tl = exp ( O ( T 2 β ( l o g T ) 2 ) ) + ( τ − 1 ) exp ( − Θ (( t − τ + 1 ) T 1 − β ) ) + t − τ + 1 t − τ + 1 = 2 1 + o ( 1 ) ,
α t 0 = 1 1 + ( τ − 1 ) exp ( − Θ ( T 1 − β ) ) + ( t − τ + 1 ) exp ( O ( ( log T ) 2 T 2 β ) ) = 1 2 + o ( 1 ) , \alpha_{t0}=\frac{1}{1+(\tau-1)\exp\left(-\Theta(T^{1-\beta})\right)+(t-\tau+1)\exp\left(O\left(\frac{(\log T)^2}{T^{2\beta}}\right)\right)}=\frac{1}{2}+o(1), α t 0 = 1 + ( τ − 1 ) exp ( − Θ ( T 1 − β ) ) + ( t − τ + 1 ) exp ( O ( T 2 β ( l o g T ) 2 ) ) 1 = 2 1 + o ( 1 ) ,
where the error o ( 1 ) o(1) o ( 1 ) is exponentially small. Therefore, at t = τ t=\tau t = τ , the conditional model seperate half of the attention to the text token, and the other half still lies on the feature block. From the construction of o t λ o_t^\lambda o t λ , we have o t λ ≈ ( 1 − ( λ + 1 ) / 2 ) W V ( 1 ) f k 1 + ( ( λ + 1 ) / 2 ) W V ( 1 ) f K + J + k 1 o_t^\lambda\approx(1-(\lambda+1)/2)W_V^{(1)}f_{k_1}+((\lambda+1)/2)W_V^{(1)}f_{K+J+k_1} o t λ ≈ ( 1 − ( λ + 1 ) /2 ) W V ( 1 ) f k 1 + (( λ + 1 ) /2 ) W V ( 1 ) f K + J + k 1 with exponentially small error under finite λ \lambda λ . For sufficiently large T T T , considering results in Lemma D.5 and order in Eqn. (D.8), we only need to compare feature k 1 k_1 k 1 and any background j ∈ [ J ] j\in[J] j ∈ [ J ] , so substract the coefficient of theem and consider the error, we can get the logit
η V − 1 ( logit t λ [ k 1 ] − logit t λ [ K + j ] ) = λ + 1 2 ( p k 1 C K + J + k 1 − p k 1 C k 1 + p k 1 q j B k 1 − p k 1 q j B K + J + k 1 ) + p k 1 C k 1 − p k 1 q j B k 1 + o ( 1 ) , \eta_V^{-1}\left(\operatorname{logit}_t^\lambda[k_1]-\operatorname{logit}_t^\lambda[K+j]\right)=\frac{\lambda+1}{2}\left(p_{k_1}C_{K+J+k_1}-p_{k_1}C_{k_1}+p_{k_1}q_jB_{k_1}-p_{k_1}q_jB_{K+J+k_1}\right)
+p_{k_1}C_{k_1}-p_{k_1}q_jB_{k_1}+o(1), η V − 1 ( logit t λ [ k 1 ] − logit t λ [ K + j ] ) = 2 λ + 1 ( p k 1 C K + J + k 1 − p k 1 C k 1 + p k 1 q j B k 1 − p k 1 q j B K + J + k 1 ) + p k 1 C k 1 − p k 1 q j B k 1 + o ( 1 ) ,
which comes from directly expansion using Lemma D.5 , and the error term is exponentially small. From Proposition D.4 , we know q j B k 1 < C k 1 q_jB_{k_1}<C_{k_1} q j B k 1 < C k 1 , q j B K + J + k 2 > C K + J + k 1 q_jB_{K+J+k_2}>C_{K+J+k_1} q j B K + J + k 2 > C K + J + k 1 . Because η V > 0 \eta_V>0 η V > 0 , to get logit t λ [ k 1 ] − logit t λ [ K + j ] > 0 \operatorname{logit}^{\lambda}_t[k_1]-\operatorname{logit}^{\lambda}_t[K+j]>0 logit t λ [ k 1 ] − logit t λ [ K + j ] > 0 , it should satisfies
λ < 2 ( p k 1 C k 1 − p k 1 q j B k 1 ) p k 1 C k 1 − p k 1 q j B k 1 + p k 1 q j B K + J + k 1 − p k 1 C K + J + k 1 − 1 = 1 + o ( 1 ) , \lambda< \frac{2(p_{k_1}C_{k_1}-p_{k_1}q_jB_{k_1})}{p_{k_1}C_{k_1}-p_{k_1}q_jB_{k_1}+p_{k_1}q_jB_{K+J+k_1}-p_{k_1}C_{K+J+k_1}}-1=1+o(1), λ < p k 1 C k 1 − p k 1 q j B k 1 + p k 1 q j B K + J + k 1 − p k 1 C K + J + k 1 2 ( p k 1 C k 1 − p k 1 q j B k 1 ) − 1 = 1 + o ( 1 ) ,
where the first equality comes from direct computation to make the gap position, and the second equality follows from the asymptotic orders of the coefficients in Eqn. (D.8), noting that B K + j 1 B_{K+j_1} B K + j 1 is the dominant term. The o ( 1 ) o(1) o ( 1 ) here is a positive vanishing term.
In conclusion, at position τ ≤ t < τ + L − 1 \tau\le t<\tau+L-1 τ ≤ t < τ + L − 1 , when λ < 1 + o ( 1 ) \lambda<1+o(1) λ < 1 + o ( 1 ) , with positive vanishing term o ( 1 ) o(1) o ( 1 ) , k 1 = arg max i logit t λ [ i ] k_1=\operatorname*{arg\,max}_i\operatorname{logit}^{\lambda}_t[i] k 1 = arg max i logit t λ [ i ] , so in greedy decoding, the model will predict k 1 k_1 k 1 in the next position, thus successfully predict the feature tokens.
Thus, we conclude the proof of Lemma D.12 .
Lemma D.13 (Post-feature positions: t ≥ τ + L − 1 t\ge\tau+L-1 t ≥ τ + L − 1 ). When t ≥ τ + L − 1 t\ge\tau+L-1 t ≥ τ + L − 1 , suppose the input tokens are ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , k 1 × L , ( K + j 1 ) × ( t − τ − L + 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)},k_1^{\times L},(K+j_1)^{\times(t-\tau-L+1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , k 1 × L , ( K + j 1 ) × ( t − τ − L + 1 ) ) , when λ < 1 + o ( 1 ) \lambda<1+o(1) λ < 1 + o ( 1 ) , the CFG logits satisfies arg max i logit t λ [ i ] = K + j 1 \operatorname*{arg\,max}_i\operatorname{logit}^{\lambda}_t[i]=K+j_1 arg max i logit t λ [ i ] = K + j 1 .
Proof. When t ≥ τ + L − 1 t\ge\tau+L-1 t ≥ τ + L − 1 , the feature block completes, and the target tokens are the background tokens. Suppose the input tokens are ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , k 1 × L , ( K + j 1 ) × ( t − τ − L + 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)},k_1^{\times L},(K+j_1)^{\times(t-\tau-L+1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , k 1 × L , ( K + j 1 ) × ( t − τ − L + 1 ) ) , from the definition of output, we have
o t = α t 0 W V ( 1 ) f K + J + k 1 + ( ∑ l = 1 τ − 1 α t l + ∑ l = τ + L t α t l ) W V ( 1 ) f K + j 1 + ∑ l = τ τ + L − 1 α t l W V ( 1 ) f k 1 , o_t=\alpha_{t0}W_V^{(1)}f_{K+J+k_1}+\left(\sum_{l=1}^{\tau-1}\alpha_{tl}+\sum_{l=\tau+L}^{t}\alpha_{tl}\right)W_V^{(1)}f_{K+j_1}+\sum_{l=\tau}^{\tau+L-1}\alpha_{tl}W_V^{(1)}f_{k_1}, o t = α t 0 W V ( 1 ) f K + J + k 1 + ( l = 1 ∑ τ − 1 α tl + l = τ + L ∑ t α tl ) W V ( 1 ) f K + j 1 + l = τ ∑ τ + L − 1 α tl W V ( 1 ) f k 1 ,
o t u c = ( ∑ l = 1 τ − 1 α t l u c + ∑ l = τ + L t α t l u c ) W V ( 1 ) f K + j 1 + ∑ l = τ τ + L − 1 α t l u c W V ( 1 ) f k 1 , o_t^{\mathrm{uc}}=\left(\sum_{l=1}^{\tau-1}\alpha_{tl}^{\mathrm{uc}}+\sum_{l=\tau+L}^{t}\alpha_{tl}^{\mathrm{uc}}\right)W_V^{(1)}f_{K+j_1}+\sum_{l=\tau}^{\tau+L-1}\alpha_{tl}^{\mathrm{uc}}W_V^{(1)}f_{k_1}, o t uc = ( l = 1 ∑ τ − 1 α tl uc + l = τ + L ∑ t α tl uc ) W V ( 1 ) f K + j 1 + l = τ ∑ τ + L − 1 α tl uc W V ( 1 ) f k 1 ,
where group the terms according to the embeddings for simplification. Therefore, we know that
o t λ = o t + λ ( o t − o t u c ) = ( − λ ( ∑ l = 1 τ − 1 α t l u c + ∑ l = τ + L t α t l u c ) + ( 1 + λ ) ( ∑ l = 1 τ − 1 α t l + ∑ l = τ + L t α t l ) ) W V ( 1 ) f K + j 1 + ( − λ ∑ l = τ τ + L − 1 α t l u c + ( 1 + λ ) ∑ l = τ τ + L − 1 α t l ) W V ( 1 ) f k 1 + ( 1 + λ ) α t 0 W V ( 1 ) f K + J + k 1 . \begin{aligned}
o_t^{\lambda}=o_t+\lambda(o_t-o_t^{\mathrm{uc}}) \\
&=\left(-\lambda\left(\sum_{l=1}^{\tau-1}\alpha_{tl}^{\mathrm{uc}}+\sum_{l=\tau+L}^{t}\alpha_{tl}^{\mathrm{uc}}\right)+(1+\lambda)\left(\sum_{l=1}^{\tau-1}\alpha_{tl}+\sum_{l=\tau+L}^{t}\alpha_{tl}\right)\right)W_V^{(1)}f_{K+j_1} \\
&+\left(-\lambda\sum_{l=\tau}^{\tau+L-1}\alpha_{tl}^{\mathrm{uc}}+(1+\lambda)\sum_{l=\tau}^{\tau+L-1}\alpha_{tl}\right)W_V^{(1)}f_{k_1}+(1+\lambda)\alpha_{t0}W_V^{(1)}f_{K+J+k_1}.
\end{aligned} o t λ = o t + λ ( o t − o t uc ) = ( − λ ( l = 1 ∑ τ − 1 α tl uc + l = τ + L ∑ t α tl uc ) + ( 1 + λ ) ( l = 1 ∑ τ − 1 α tl + l = τ + L ∑ t α tl ) ) W V ( 1 ) f K + j 1 + ( − λ l = τ ∑ τ + L − 1 α tl uc + ( 1 + λ ) l = τ ∑ τ + L − 1 α tl ) W V ( 1 ) f k 1 + ( 1 + λ ) α t 0 W V ( 1 ) f K + J + k 1 .
Apply softmax function on the position-feature correlation on the sequence to compute the attention score, we have
α t 0 = exp ( e t T W Q K ( 1 ) f K + J + k 1 ) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) + ( τ − 1 ) exp ( e t T W Q K ( 1 ) f K + j 1 ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) f k 1 ) = 1 1 + ( τ − 1 ) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) ( f k 1 − f K + J + k 1 ) ) = 1 1 + t ( 1 + o ( 1 ) ) , \begin{aligned}
\alpha_{t0}=\frac{\exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+J+k_1})}{\exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+J+k_1})+(\tau-1)\exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+j_1})+(t-\tau+1)\exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{k_1})} \\
&=\frac{1}{1+(\tau-1)\exp\left(e_t^{\mathsf T}W_{QK}^{(1)}(f_{K+j_1}-f_{K+J+k_1})\right)+(t-\tau+1)\exp\left(e_t^{\mathsf T}W_{QK}^{(1)}(f_{k_1}-f_{K+J+k_1})\right)} \\
&=\frac{1}{1+t}(1+o(1)),
\end{aligned} α t 0 = exp ( e t T W Q K ( 1 ) f K + J + k 1 ) + ( τ − 1 ) exp ( e t T W Q K ( 1 ) f K + j 1 ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) f k 1 ) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) = 1 + ( τ − 1 ) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) ) + ( t − τ + 1 ) exp ( e t T W Q K ( 1 ) ( f k 1 − f K + J + k 1 ) ) 1 = 1 + t 1 ( 1 + o ( 1 )) ,
where the second equation divides exp ( e t T W Q K ( 1 ) f K + J + k 1 ) \exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+J+k_1}) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) from the numerator and denominator, and the third equation comes from the properties in Proposition D.9 that when t ∉ F t\notin\mathcal{F} t ∈ / F , we have exp ( e t T W Q K ( 1 ) f K + J + k 1 ) = o ( 1 ) \exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+J+k_1})=o(1) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) = o ( 1 ) , exp ( e t T W Q K ( 1 ) f K + j 1 ) = o ( 1 ) \exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+j_1})=o(1) exp ( e t T W Q K ( 1 ) f K + j 1 ) = o ( 1 ) , exp ( e t T W Q K ( 1 ) f k 1 ) = o ( 1 ) \exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{k_1})=o(1) exp ( e t T W Q K ( 1 ) f k 1 ) = o ( 1 ) , and the o ( 1 ) o(1) o ( 1 ) is exponentially small. Similarly, applying the same technique to expand softmax function, we have
∑ l = τ τ + L − 1 α t l = L 1 + t ( 1 + o ( 1 ) ) , ∑ l = 1 τ − 1 α t l + ∑ l = τ + L t α t l = t − L 1 + t ( 1 + o ( 1 ) ) . \sum_{l=\tau}^{\tau+L-1}\alpha_{tl}=\frac{L}{1+t}(1+o(1)),\qquad\sum_{l=1}^{\tau-1}\alpha_{tl}+\sum_{l=\tau+L}^{t}\alpha_{tl}=\frac{t-L}{1+t}(1+o(1)). l = τ ∑ τ + L − 1 α tl = 1 + t L ( 1 + o ( 1 )) , l = 1 ∑ τ − 1 α tl + l = τ + L ∑ t α tl = 1 + t t − L ( 1 + o ( 1 )) .
For unconditional model, the only difference is the structure in softmax function, so we can also directly expand them and use the properties in Proposition D.9, and get
∑ l = τ τ + L − 1 α t l u c = L ( t − L ) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f k 1 ) ) + L = L t ( 1 + o ( 1 ) ) , \sum_{l=\tau}^{\tau+L-1}\alpha_{tl}^{\mathrm{uc}}=\frac{L}{(t-L)\exp(e_t^{\mathsf{T}}W_{QK}^{(1)}(f_{K+j_1}-f_{k_1}))+L}=\frac{L}{t}(1+o(1)), l = τ ∑ τ + L − 1 α tl uc = ( t − L ) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f k 1 )) + L L = t L ( 1 + o ( 1 )) ,
where the first equation divides exp ( e t T W Q K ( 1 ) f k 1 ) \exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{k_1}) exp ( e t T W Q K ( 1 ) f k 1 ) from the numerator and denominator, and the second equation apply the fact that exp ( e t T W Q K ( 1 ) f K + j 1 ) = o ( 1 ) \exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{K+j_1})=o(1) exp ( e t T W Q K ( 1 ) f K + j 1 ) = o ( 1 ) and exp ( e t T W Q K ( 1 ) f k 1 ) = o ( 1 ) \exp(e_t^{\mathsf{T}}W_{QK}^{(1)}f_{k_1})=o(1) exp ( e t T W Q K ( 1 ) f k 1 ) = o ( 1 ) . Similarly, we apply the same technique to the background token block, we have
∑ l = 1 τ − 1 α t l u c + ∑ l = τ + L t α t l u c = t − L t ( 1 + o ( 1 ) ) , \sum_{l=1}^{\tau-1}\alpha_{tl}^{\mathrm{uc}}+\sum_{l=\tau+L}^{t}\alpha_{tl}^{\mathrm{uc}}=\frac{t-L}{t}(1+o(1)), l = 1 ∑ τ − 1 α tl uc + l = τ + L ∑ t α tl uc = t t − L ( 1 + o ( 1 )) ,
where the error is exponentially small. Therefore, we can know that the attention pattern is almost uniform. So we can plug in the attention score to the output applied CFG
o t λ = ( − λ t − L t + ( 1 + λ ) t − L t + 1 + o ( 1 ) ) W V ( 1 ) f K + j 1 + ( − λ L t + ( 1 + λ ) L t + 1 + o ( 1 ) ) W V ( 1 ) f k 1 + ( 1 + λ ) 1 t + 1 ( 1 + o ( 1 ) ) W V ( 1 ) f K + J + k 1 . \begin{aligned}
o_t^\lambda=\left(-\lambda\frac{t-L}{t}+(1+\lambda)\frac{t-L}{t+1}+o(1)\right)W_V^{(1)}f_{K+j_1} \\
&+\left(-\lambda\frac{L}{t}+(1+\lambda)\frac{L}{t+1}+o(1)\right)W_V^{(1)}f_{k_1}+(1+\lambda)\frac{1}{t+1}(1+o(1))W_V^{(1)}f_{K+J+k_1}.
\end{aligned} o t λ = ( − λ t t − L + ( 1 + λ ) t + 1 t − L + o ( 1 ) ) W V ( 1 ) f K + j 1 + ( − λ t L + ( 1 + λ ) t + 1 L + o ( 1 ) ) W V ( 1 ) f k 1 + ( 1 + λ ) t + 1 1 ( 1 + o ( 1 )) W V ( 1 ) f K + J + k 1 .
We can further expand W V ( 1 ) f K + j 1 , W V ( 1 ) f K + J + k 1 , W V ( 1 ) f k 1 W_V^{(1)}f_{K+j_1},W_V^{(1)}f_{K+J+k_1},W_V^{(1)}f_{k_1} W V ( 1 ) f K + j 1 , W V ( 1 ) f K + J + k 1 , W V ( 1 ) f k 1 using results in Lemma D.5, which can change o t λ o_t^\lambda o t λ into a linear combination of embeddings. Because we use weight tying language model head W l m W_{\mathrm{lm}} W lm , the coefficient before each embedding in o t λ o_t^\lambda o t λ is the corresponding value in logit t λ \operatorname{logit}_t^\lambda logit t λ . Observe that in Lemma D.5: f K + j 1 f_{K+j_1} f K + j 1 has an additional positive term than other f K + j f_{K+j} f K + j in W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 ; f k 1 f_{k_1} f k 1 has an additional positive term than other f k f_k f k in W V ( 1 ) f K + J + k 1 W_V^{(1)}f_{K+J+k_1} W V ( 1 ) f K + J + k 1 . We can know that logit t λ [ K + j 1 ] > logit t λ [ K + j ] \operatorname{logit}_t^\lambda[K+j_1]>\operatorname{logit}_t^\lambda[K+j] logit t λ [ K + j 1 ] > logit t λ [ K + j ] , j ≠ j 1 j\ne j_1 j = j 1 , logit t λ [ k 1 ] > logit t λ [ k ] \operatorname{logit}_t^\lambda[k_1]>\operatorname{logit}_t^\lambda[k] logit t λ [ k 1 ] > logit t λ [ k ] , k ≠ k 1 k\ne k_1 k = k 1 , so we only need to compare those of f K + j 1 f_{K+j_1} f K + j 1 and f k 1 f_{k_1} f k 1 . By expansion using Lemma D.5 and direct subtraction of the coefficient, we have
η V − 1 ( logit t λ [ K + j 1 ] − logit t λ [ k 1 ] ) = ( ( 1 − λ ) t − L t + λ t − L t + 1 ) q j 1 B K + j 1 + λ 1 t + 1 p k 1 q j 1 B K + J + k 1 + ( ( 1 − λ ) L t + λ L t + 1 ) p k 1 q j 1 B k 1 − ( ( 1 − λ ) t − L t + λ t − L t + 1 ) p k 1 q j 1 C K + j 1 \begin{aligned}
\eta_V^{-1}\left(\operatorname{logit}_t^\lambda[K+j_1]-\operatorname{logit}_t^\lambda[k_1]\right) \\
&=\left((1-\lambda)\frac{t-L}{t}+\lambda\frac{t-L}{t+1}\right)q_{j_1}B_{K+j_1}+\lambda\frac{1}{t+1}p_{k_1}q_{j_1}B_{K+J+k_1} \\
&+\left((1-\lambda)\frac{L}{t}+\lambda\frac{L}{t+1}\right)p_{k_1}q_{j_1}B_{k_1}-\left((1-\lambda)\frac{t-L}{t}+\lambda\frac{t-L}{t+1}\right)p_{k_1}q_{j_1}C_{K+j_1}
\end{aligned} η V − 1 ( logit t λ [ K + j 1 ] − logit t λ [ k 1 ] ) = ( ( 1 − λ ) t t − L + λ t + 1 t − L ) q j 1 B K + j 1 + λ t + 1 1 p k 1 q j 1 B K + J + k 1 + ( ( 1 − λ ) t L + λ t + 1 L ) p k 1 q j 1 B k 1 − ( ( 1 − λ ) t t − L + λ t + 1 t − L ) p k 1 q j 1 C K + j 1
− λ 1 t + 1 p k 1 C K + J + k 1 − ( ( 1 − λ ) L t + λ L t + 1 ) p k 1 C k 1 + o ( 1 ) = ( ( 1 − λ ) t − L t + λ t − L t + 1 ) q j 1 B K + j 1 + o ( T 1 − β ) , \begin{aligned}
-\lambda\frac{1}{t+1}p_{k_1}C_{K+J+k_1}-\left((1-\lambda)\frac{L}{t}+\lambda\frac{L}{t+1}\right)p_{k_1}C_{k_1}+o(1) \\
&=\left((1-\lambda)\frac{t-L}{t}+\lambda\frac{t-L}{t+1}\right)q_{j_1}B_{K+j_1}+o(T^{1-\beta}),
\end{aligned} − λ t + 1 1 p k 1 C K + J + k 1 − ( ( 1 − λ ) t L + λ t + 1 L ) p k 1 C k 1 + o ( 1 ) = ( ( 1 − λ ) t t − L + λ t + 1 t − L ) q j 1 B K + j 1 + o ( T 1 − β ) ,
where the first equation comes from direct expansion using Lemma D.5, and the shared factor in coefficient of f ˉ \bar{f} f ˉ is eliminated. The the second equality holds because of Eqn. (D.8). Because η V > 0 \eta_V>0 η V > 0 , we know that logit t λ [ K + j 1 ] − logit t λ [ k 1 ] < 0 \operatorname{logit}_t^\lambda[K+j_1]-\operatorname{logit}_t^\lambda[k_1]<0 logit t λ [ K + j 1 ] − logit t λ [ k 1 ] < 0 holds for sufficiently large T T T when
− λ t − L t + ( 1 + λ ) t − L t + 1 < 0 , -\lambda\frac{t-L}{t}+(1+\lambda)\frac{t-L}{t+1}<0, − λ t t − L + ( 1 + λ ) t + 1 t − L < 0 ,
which is a direct computation by setting the gap negative. This result is equivalent to λ < t + 1 \lambda< t + 1 λ < t + 1 . Therefore, when λ < 1 + o ( 1 ) < t \lambda< 1 + o(1) < t λ < 1 + o ( 1 ) < t , at t > τ + L − 1 t > \tau+ L - 1 t > τ + L − 1 , k 1 = arg max i logit t [ i ] k_1 = \arg\max_i \operatorname{logit}_t[i] k 1 = arg max i logit t [ i ] , so in greedy decoding, the model will predict k 1 k_1 k 1 in the next position, thus successfully predict the feature tokens.
Thus, we conclude the proof of Lemma D.13 .
Step 9: Loss Bound and Proof of Theorem D.1
Notice that the input prefix discuss in the lemmas of Section D.8 are the prefix of sequences from data distribution. So we can reuse the results in these lemmas to analyze the training loss.
Proposition D.14 (Minimal Training Loss). Under assumption in Theorem D.1, running the conditional model with parameter θ ( 2 ) = ( W V ( 1 ) , W Q K ( 1 ) ) \theta^{(2)} = (W_V^{(1)}, W_{QK}^{(1)}) θ ( 2 ) = ( W V ( 1 ) , W Q K ( 1 ) ) , the per-position losses of the conditional model are:
For t ∉ [ τ − 1 , τ + L − 2 ] t \notin[\tau- 1, \tau+ L - 2] t ∈ / [ τ − 1 , τ + L − 2 ] (background): − log P t [ I t + 1 ] = Θ ( T β e − Θ ( T 1 − β ) ) -\log P_t[I_{t+1}] = \Theta(T^\beta e^{-\Theta(T^{1-\beta})}) − log P t [ I t + 1 ] = Θ ( T β e − Θ ( T 1 − β ) ) .
For t = τ − 1 t = \tau- 1 t = τ − 1 (transition): − log P t [ k 1 ] = Θ ( log T ) -\log P_t[k_1] = \Theta(\log T) − log P t [ k 1 ] = Θ ( log T ) .
For t ∈ [ τ , τ + L − 2 ] t \in[\tau, \tau+ L - 2] t ∈ [ τ , τ + L − 2 ] (feature block): − log P t [ k 1 ] = Θ ( log T ) -\log P_t[k_1] = \Theta(\log T) − log P t [ k 1 ] = Θ ( log T ) .
The population loss of the model is L v i s ( θ ( 2 ) ) = Θ ( ( log T ) 2 / T ) \mathcal{L}_{\mathrm{vis}}(\theta^{(2)}) = \Theta((\log T)^2/T) L vis ( θ ( 2 ) ) = Θ (( log T ) 2 / T ) , which is asymptotically small.
Proof. We firstly consider an input sequence with feature class k 1 k_1 k 1 and background class j 1 j_1 j 1 . Note that in Lemma D.10, Lemma D.11, Lemma D.12 , and Lemma D.13 , the input are prefix of all standard sequence with feature class k 1 k_1 k 1 and background class j 1 j_1 j 1 . So we can directly use these lemma to analyze the loss with sequence from the data distribution. Here we denote P t [ k ] P_t[k] P t [ k ] as the probability of token k k k in probability P t ∈ R K + J P_t \in\mathbb{R}^{K+J} P t ∈ R K + J .
For t ∉ F t \notin\mathcal{F} t ∈ / F : by Lemma D.10 and Lemma D.13 , we know that when t ∉ F t \notin\mathcal{F} t ∈ / F , the attention score is asymptotically uniform, i.e. α t l = 1 / ( t + 1 ) + o ( 1 ) \alpha_{tl} = 1/(t + 1) + o(1) α tl = 1/ ( t + 1 ) + o ( 1 ) , with an exponential error. So the probability the same with those in Lemma D.7 (before the second update) for sufficiently large T T T . So we know that
− log P t [ x t + 1 ] = − log P t [ K + j 1 ] = − log ( 1 − Θ ( T β e − Θ ( T 1 − β ) ) ) = Θ ( T β e − Θ ( T 1 − β ) ) . -\log P_t[x_{t+1}] = -\log P_t[K + j_1] = -\log\left(1 - \Theta\left(T^\beta e^{-\Theta(T^{1-\beta})}\right)\right) = \Theta\left(T^\beta e^{-\Theta(T^{1-\beta})}\right). − log P t [ x t + 1 ] = − log P t [ K + j 1 ] = − log ( 1 − Θ ( T β e − Θ ( T 1 − β ) ) ) = Θ ( T β e − Θ ( T 1 − β ) ) .
where the first equation uses x t + 1 = K + j 1 x_{t+1} = K + j_1 x t + 1 = K + j 1 when t ∈ F t \in\mathcal{F} t ∈ F , the second equation use results in Lemma D.7 because the attention score is asymptotic uniform with exponentially small, and the third equation directly computation use − log ( 1 − x ) = x + O ( x 2 ) -\log(1 - x) = x + O(x^2) − log ( 1 − x ) = x + O ( x 2 ) when x x x is small.
For t ∈ F t \in\mathcal{F} t ∈ F : by Lemma D.12 , we know that when τ < t ≤ τ + L − 2 \tau< t \le\tau+ L - 2 τ < t ≤ τ + L − 2 , the attention concentrates on the feature block, i.e. ∑ l = τ t α t l = 1 + o ( 1 ) \sum_{l=\tau}^{t}\alpha_{tl} = 1 + o(1) ∑ l = τ t α tl = 1 + o ( 1 ) , with exponentially small error, so we have
o t = W V ( 1 ) f k 1 + o ( 1 ) ( W V ( 1 ) f K + J + k 1 + W V ( 1 ) f K + j 1 ) = η V [ − p k 1 A k 1 f ˉ + p k 1 ∑ j q j B k 1 f K + j + p k 1 C k 1 f k 1 ] + o ( 1 ) ( W V ( 1 ) f K + J + k 1 + W V ( 1 ) f K + j 1 ) , \begin{aligned}
o_t = W_V^{(1)} f_{k_1} + o(1)(W_V^{(1)} f_{K+J+k_1} + W_V^{(1)} f_{K+j_1}) \\
&= \eta_V[-p_{k_1}A_{k_1}\bar{f} + p_{k_1}\sum_j q_j B_{k_1}f_{K+j} + p_{k_1}C_{k_1}f_{k_1}] + o(1)(W_V^{(1)} f_{K+J+k_1} + W_V^{(1)} f_{K+j_1}),
\end{aligned} o t = W V ( 1 ) f k 1 + o ( 1 ) ( W V ( 1 ) f K + J + k 1 + W V ( 1 ) f K + j 1 ) = η V [ − p k 1 A k 1 f ˉ + p k 1 j ∑ q j B k 1 f K + j + p k 1 C k 1 f k 1 ] + o ( 1 ) ( W V ( 1 ) f K + J + k 1 + W V ( 1 ) f K + j 1 ) ,
where the second equation is a direct expansion. Use the results in Eqn. (D.8), because f k f_k f k , k ≠ k 1 k \ne k_1 k = k 1 only show up in f ˉ \bar{f} f ˉ , so the logits is logit t [ k ] = − η V p k 1 A k 1 / ( K + J ) + o ( 1 ) \operatorname{logit}_t[k] = -\eta_V p_{k_1} A_{k_1}/(K + J) + o(1) logit t [ k ] = − η V p k 1 A k 1 / ( K + J ) + o ( 1 ) , k ≠ k 1 k \ne k_1 k = k 1 , and this comes from the exponentially small o ( 1 ) o(1) o ( 1 ) . Since the coefficient of f ˉ \bar{f} f ˉ contributes the same to all the embeddings, we have the results of other logits
logit t [ k 1 ] = η V p k 1 A k 1 K + J + Θ ( L ( L − 1 ) 2 τ ) , \operatorname{logit}_t[k_1] = \frac{\eta_V p_{k_1} A_{k_1}}{K + J} + \Theta\left(\frac{L(L - 1)}{2\tau}\right), logit t [ k 1 ] = K + J η V p k 1 A k 1 + Θ ( 2 τ L ( L − 1 ) ) ,
logit t [ K + j ] = η V p k 1 A k 1 K + J + Θ ( c L 2 ( 1 − β ) τ ) , j ∈ [ J ] \operatorname{logit}_t[K + j] = \frac{\eta_V p_{k_1} A_{k_1}}{K + J} + \Theta\left(\frac{cL^2(1 - \beta)}{\tau}\right), \quad j \in[J] logit t [ K + j ] = K + J η V p k 1 A k 1 + Θ ( τ c L 2 ( 1 − β ) ) , j ∈ [ J ]
which are results plug in the asymptotic order in Eqn. (D.8) and the assumption in Theorem D.1 . So we can apply softmax function to compute the probability
P t [ k 1 ] = exp ( logit t [ k 1 ] ) ∑ j = 1 J exp ( logit t [ K + j ] ) + ∑ k = 1 K exp ( logit t [ k ] ) = 1 Θ ( T β ) exp ( Θ ( c L 2 ( 1 − β ) τ ) − Θ ( L ( L − 1 ) 2 τ ) ) + Θ ( exp ( − T − β ( log T ) 2 ) ) + Θ ( 1 ) \begin{aligned}
P_t[k_1] &= \frac{\exp\left(\operatorname{logit}_t[k_1]\right)}{\sum_{j=1}^{J} \exp\left(\operatorname{logit}_t[K+j]\right) + \sum_{k=1}^{K} \exp\left(\operatorname{logit}_t[k]\right)} \\
&= \frac{1}{\Theta(T^\beta)\exp\left(\Theta\left(\frac{cL^2(1-\beta)}{\tau}\right)-\Theta\left(\frac{L(L-1)}{2\tau}\right)\right)+\Theta\left(\exp\left(-T^{-\beta}(\log T)^2\right)\right)+\Theta(1)}
\end{aligned} P t [ k 1 ] = ∑ j = 1 J exp ( logit t [ K + j ] ) + ∑ k = 1 K exp ( logit t [ k ] ) exp ( logit t [ k 1 ] ) = Θ ( T β ) exp ( Θ ( τ c L 2 ( 1 − β ) ) − Θ ( 2 τ L ( L − 1 ) ) ) + Θ ( exp ( − T − β ( log T ) 2 ) ) + Θ ( 1 ) 1
where the second equation divide exp ( logit t [ k 1 ] ) \exp\left(\operatorname{logit}_t[k_1]\right) exp ( logit t [ k 1 ] ) from the numerator and denominator, and then plug in the asymptotic results. Therefore, we can directly compute the log probability, which is − log P t [ k 1 ] = Θ ( log T ) -\log P_t[k_1]=\Theta(\log T) − log P t [ k 1 ] = Θ ( log T ) .
For t = τ t=\tau t = τ , also from Lemma D.11, we know that the conditional model distribute half of attention to the text token, i.e. α t 0 = 1 2 ( 1 + o ( 1 ) ) \alpha_{t0}=\frac{1}{2}(1+o(1)) α t 0 = 2 1 ( 1 + o ( 1 )) and α t τ = 1 2 ( 1 + o ( 1 ) ) \alpha_{t\tau}=\frac{1}{2}(1+o(1)) α t τ = 2 1 ( 1 + o ( 1 )) , with exponentially small error o ( 1 ) o(1) o ( 1 ) , so we have
o t = 1 2 η V [ − p k 1 A k 1 f ˉ + p k 1 ∑ j q j B k 1 f K + j + p k 1 C k 1 f k 1 ] + 1 2 η V [ − p k 1 A K + J + k 1 f ˉ + p k 1 ∑ j q j B K + J + k 1 f K + j + p k 1 C K + J + k 1 f k 1 ] + o ( 1 ) W V ( 1 ) f K + j 1 , \begin{aligned}
o_t={}&\frac{1}{2}\eta V\left[-p_{k_1}A_{k_1}\bar{f}+p_{k_1}\sum_j q_jB_{k_1}f_{K+j}+p_{k_1}C_{k_1}f_{k_1}\right]\\
&+\frac{1}{2}\eta V\left[-p_{k_1}A_{K+J+k_1}\bar{f}+p_{k_1}\sum_j q_jB_{K+J+k_1}f_{K+j}+p_{k_1}C_{K+J+k_1}f_{k_1}\right]+o(1)W_V^{(1)}f_{K+j_1},
\end{aligned} o t = 2 1 η V [ − p k 1 A k 1 f ˉ + p k 1 j ∑ q j B k 1 f K + j + p k 1 C k 1 f k 1 ] + 2 1 η V [ − p k 1 A K + J + k 1 f ˉ + p k 1 j ∑ q j B K + J + k 1 f K + j + p k 1 C K + J + k 1 f k 1 ] + o ( 1 ) W V ( 1 ) f K + j 1 ,
which is a direct results from Lemma D.5 . Similarly, use the results in Eqn. (D.8) and notice that the coefficient of f ˉ \bar{f} f ˉ contribute the same to all the embeddings, we have
logit t [ k 1 ] = − η V ( p k 1 A k 1 + p k 1 A K + J + k 1 ) 2 ( K + J ) + Θ ( L ( L − 1 ) 4 τ ) , \operatorname{logit}_t[k_1]=-\frac{\eta V\left(p_{k_1}A_{k_1}+p_{k_1}A_{K+J+k_1}\right)}{2(K+J)}+\Theta\left(\frac{L(L-1)}{4\tau}\right), logit t [ k 1 ] = − 2 ( K + J ) η V ( p k 1 A k 1 + p k 1 A K + J + k 1 ) + Θ ( 4 τ L ( L − 1 ) ) ,
logit t [ K + j ] = − η V ( p k 1 A k 1 + p k 1 A K + J + k 1 ) 2 ( K + J ) + Θ ( c L 2 ( 1 − β ) 2 τ ) , j ∈ [ J ] , \operatorname{logit}_t[K+j]=-\frac{\eta V\left(p_{k_1}A_{k_1}+p_{k_1}A_{K+J+k_1}\right)}{2(K+J)}+\Theta\left(\frac{cL^2(1-\beta)}{2\tau}\right),\ j\in[J], logit t [ K + j ] = − 2 ( K + J ) η V ( p k 1 A k 1 + p k 1 A K + J + k 1 ) + Θ ( 2 τ c L 2 ( 1 − β ) ) , j ∈ [ J ] ,
logit t [ k ] = − η V ( p k 1 A k 1 + p k 1 A K + J + k 1 ) 2 ( K + J ) + o ( 1 ) , k ∈ [ K ] \operatorname{logit}_t[k]=-\frac{\eta V\left(p_{k_1}A_{k_1}+p_{k_1}A_{K+J+k_1}\right)}{2(K+J)}+o(1),\ k\in[K] logit t [ k ] = − 2 ( K + J ) η V ( p k 1 A k 1 + p k 1 A K + J + k 1 ) + o ( 1 ) , k ∈ [ K ]
which are results plug in the asymptotic order in Eqn. (D.8) and the assumption in Theorem D.1 . So we can apply softmax function to compute the probability
P t [ k 1 ] = 1 Θ ( T β ) exp ( Θ ( c L 2 ( 1 − β ) 2 τ ) − Θ ( L ( L − 1 ) 4 τ ) ) + Θ ( exp ( − T − β ( log T ) 2 ) ) + Θ ( 1 ) P_t[k_1]=\frac{1}{\Theta(T^\beta)\exp\left(\Theta\left(\frac{cL^2(1-\beta)}{2\tau}\right)-\Theta\left(\frac{L(L-1)}{4\tau}\right)\right)+\Theta\left(\exp\left(-T^{-\beta}(\log T)^2\right)\right)+\Theta(1)} P t [ k 1 ] = Θ ( T β ) exp ( Θ ( 2 τ c L 2 ( 1 − β ) ) − Θ ( 4 τ L ( L − 1 ) ) ) + Θ ( exp ( − T − β ( log T ) 2 ) ) + Θ ( 1 ) 1
where we also apply the same technique to divide exp ( logit t [ k 1 ] ) \exp\left(\operatorname{logit}_t[k_1]\right) exp ( logit t [ k 1 ] ) from the numerator and denominator, and then plug in the asymptotic results. Therefore, we can directly compute the log probability, which is − log P t [ k 1 ] = Θ ( log T ) -\log P_t[k_1]=\Theta(\log T) − log P t [ k 1 ] = Θ ( log T ) .
So in conclusion, we know that for t ∈ F t\in\mathcal{F} t ∈ F , i.e. τ ≤ t ≤ τ + L − 2 \tau\leq t\leq\tau+L-2 τ ≤ t ≤ τ + L − 2 , every position contributes to loss with − log P t [ I t + 1 ] = − log P t [ k 1 ] = Θ ( log T ) -\log P_t[I_{t+1}]=-\log P_t[k_1]=\Theta(\log T) − log P t [ I t + 1 ] = − log P t [ k 1 ] = Θ ( log T ) .
For t = τ − 1 t=\tau-1 t = τ − 1 : From Lemma D.11, we know that when t = τ − 1 t=\tau-1 t = τ − 1 , the attention concentrates on the text token, i.e. α t 0 = 1 + o ( 1 ) \alpha_{t0}=1+o(1) α t 0 = 1 + o ( 1 ) , with exponentially small error, so we have
o t = W V ( 1 ) f K + J + k 1 + o ( 1 ) W V ( 1 ) ( f K + J + k 1 + f K + j 1 − f K + J + k 0 ) o_t=W_V^{(1)}f_{K+J+k_1}+o(1)W_V^{(1)}\left(f_{K+J+k_1}+f_{K+j_1}-f_{K+J+k_0}\right) o t = W V ( 1 ) f K + J + k 1 + o ( 1 ) W V ( 1 ) ( f K + J + k 1 + f K + j 1 − f K + J + k 0 )
where the equation comes from direct expansion and the error o ( 1 ) o(1) o ( 1 ) is exponentially samll. Similarly, applying results from Lemma D.5 and using the results in Eqn. (D.8) and notice that the coefficient of f ˉ \bar{f} f ˉ contribute the same to all the embeddings, we have so the logits is
logit t [ k 1 ] = − η V p k 1 A K + J + k 1 K + J + Θ ( L T ) , \operatorname{logit}_t[k_1] = -\frac{\eta V p_{k_1} A_{K+J+k_1}}{K+J} + \Theta\left(\frac{L}{T}\right), logit t [ k 1 ] = − K + J η V p k 1 A K + J + k 1 + Θ ( T L ) ,
logit t [ K + j ] = − η V p k 1 A K + J + k 1 K + J + Θ ( c L T ) , j ∈ [ J ] , \operatorname{logit}_t[K+j] = -\frac{\eta V p_{k_1} A_{K+J+k_1}}{K+J} + \Theta\left(\frac{cL}{T}\right), \quad j \in[J], logit t [ K + j ] = − K + J η V p k 1 A K + J + k 1 + Θ ( T c L ) , j ∈ [ J ] ,
logit t [ k ] = − η V p k 1 A K + J + k 1 K + J + o ( 1 ) , k ∈ [ K ] \operatorname{logit}_t[k] = -\frac{\eta V p_{k_1} A_{K+J+k_1}}{K+J} + o(1), \quad k \in[K] logit t [ k ] = − K + J η V p k 1 A K + J + k 1 + o ( 1 ) , k ∈ [ K ]
which are results plug in the asymptotic order in Eqn. (D.8) and the assumption in Theorem D.1 . So we can apply softmax function to compute the probability
P t [ k 1 ] = 1 Θ ( T β ) exp ( Θ ( ( c − 1 ) T − β log T ) ) + Θ ( exp ( − T − β log T ) ) + Θ ( 1 ) P_t[k_1] = \frac{1}{\Theta(T^\beta)\exp\left(\Theta\left((c-1)T^{-\beta}\log T\right)\right) + \Theta\left(\exp\left(-T^{-\beta}\log T\right)\right) + \Theta(1)} P t [ k 1 ] = Θ ( T β ) exp ( Θ ( ( c − 1 ) T − β log T ) ) + Θ ( exp ( − T − β log T ) ) + Θ ( 1 ) 1
where we also apply the same technique to divide exp ( logit t [ k 1 ] ) \exp(\operatorname{logit}_t[k_1]) exp ( logit t [ k 1 ]) from the numerator and denominator, and then plug in the asymptotic results. Therefore, we can directly compute the log probability, which is
− log P t [ k 1 ] = Θ ( log T ) . -\log P_t[k_1] = \Theta(\log T). − log P t [ k 1 ] = Θ ( log T ) .
In conclusion, we can compute the loss of models on a sequence with feature k 1 k_1 k 1 and background j 1 j_1 j 1
L ( k 1 , j 1 ; θ ( 2 ) ) = − 1 T − 1 ∑ t = 1 T − 1 log P t [ x t + 1 ] = 1 T − 1 ( ( T − L − 1 ) Θ ( T β e − Θ ( T 1 − β ) ) + L Θ ( log T ) ) = Θ ( ( log T ) 2 T ) , \begin{aligned}
\mathcal{L}(k_1,j_1;\theta^{(2)}) = -\frac{1}{T-1}\sum_{t=1}^{T-1}\log P_t[x_{t+1}] \\
&= \frac{1}{T-1}\left((T-L-1)\Theta\left(T^\beta e^{-\Theta(T^{1-\beta})}\right) + L\Theta(\log T)\right) \\
&= \Theta\left(\frac{(\log T)^2}{T}\right),
\end{aligned} L ( k 1 , j 1 ; θ ( 2 ) ) = − T − 1 1 t = 1 ∑ T − 1 log P t [ x t + 1 ] = T − 1 1 ( ( T − L − 1 ) Θ ( T β e − Θ ( T 1 − β ) ) + L Θ ( log T ) ) = Θ ( T ( log T ) 2 ) ,
where these first equations use the definition in Eqn. (C.2), the second equation plug in the previous asymptotic results of the error at every position, and the last one use the assumption in Theorem D.1 to expand. Therefore, compute the population loss use definition in Eqn. (C.3), we have
L v i s ( θ ( 2 ) ) = ∑ k = 1 K p k ∑ j = 1 J q j L ( k 1 , j 1 ; θ ( 2 ) ) = Θ ( ( log T ) 2 T ) . \mathcal{L}_{\mathrm{vis}}(\theta^{(2)}) = \sum_{k=1}^{K}p_k\sum_{j=1}^{J}q_j\mathcal{L}(k_1,j_1;\theta^{(2)}) = \Theta\left(\frac{(\log T)^2}{T}\right). L vis ( θ ( 2 ) ) = k = 1 ∑ K p k j = 1 ∑ J q j L ( k 1 , j 1 ; θ ( 2 ) ) = Θ ( T ( log T ) 2 ) .
Notably, the loss is primarily driven by the errors on the feature block, which scale as Θ ( log T ) \Theta(\log T) Θ ( log T ) at each position. In contrast, the error on the background block is exponentially small, as the model consistently predicts the background tokens with high accuracy.
Thus, we conclude the proof of Proposition D.14.
Step 10: Correctly Generation with CFG
With the analyze of CFG in Section D.8, we can know analyze the correctness of generation using suitable guidance scale. Here, we use I ^ k , j λ [ t 1 : t 2 ] \hat{I}^{\lambda}_{k,j}[t_1:t_2] I ^ k , j λ [ t 1 : t 2 ] to denote the token between position t 1 , t 2 t_1,t_2 t 1 , t 2 in the generated image I ^ k , j λ \hat{I}^{\lambda}_{k,j} I ^ k , j λ with feature class k k k and background j j j .
Lemma D.15 (Correctness of Generation with CFG). With guidance scale o ( 1 ) < λ < 1 + o ( 1 ) o(1)<\lambda<1+o(1) o ( 1 ) < λ < 1 + o ( 1 ) , where o ( 1 ) o(1) o ( 1 ) denotes a positive vanishing term, the trained Transformer generates sequence I ^ k , j λ ( θ ( 2 ) ) = I k , j \hat{I}^{\lambda}_{k,j}(\theta^{(2)})=I_{k,j} I ^ k , j λ ( θ ( 2 ) ) = I k , j , for all k ∈ [ K ] , j ∈ [ J ] k\in[K],j\in[J] k ∈ [ K ] , j ∈ [ J ] .
Proof. Consider feature class k 1 k_1 k 1 and background class j 1 j_1 j 1 , follow the inference procedure defined in § 5 , starting with prefix $(K+J+k_1,K+j_1)`. Before feature: From Lemma D.10, when 1 ≤ t < τ − 1 1 \le t < \tau- 1 1 ≤ t < τ − 1 , we know that with o ( 1 ) < λ < 1 + o ( 1 ) o(1) < \lambda< 1 + o(1) o ( 1 ) < λ < 1 + o ( 1 ) , given input ( K + J + k 1 , ( K + j 1 ) × t ) (K+J+k_1,(K+j_1)^{\times t}) ( K + J + k 1 , ( K + j 1 ) × t ) , the greedy decoding satisfies arg max i logit t [ i ] = K + j 1 \arg\max_i \operatorname{logit}_t[i] = K+j_1 arg max i logit t [ i ] = K + j 1 . So the background feature at t = 2 , ⋯ , τ − 1 t=2,\cdots,\tau-1 t = 2 , ⋯ , τ − 1 can be correctly generated, i.e. the generated image satisfies I ^ k 1 , j 1 λ [ 1 : τ − 1 ] = ( ( K + j 1 ) × ( τ − 1 ) ) \widehat{I}^{\lambda}_{k_1,j_1}[1:\tau-1]=((K+j_1)^{\times(\tau-1)}) I k 1 , j 1 λ [ 1 : τ − 1 ] = (( K + j 1 ) × ( τ − 1 ) ) .
Transition: From Lemma D.11, when t = τ − 1 t=\tau-1 t = τ − 1 , we know that with o ( 1 ) < λ < 1 + o ( 1 ) o(1)<\lambda<1+o(1) o ( 1 ) < λ < 1 + o ( 1 ) , given input ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) ) , the greedy decoding satisfies arg max i logit t [ i ] = k 1 \arg\max_i\operatorname{logit}_t[i]=k_1 arg max i logit t [ i ] = k 1 . So the required feature at t = τ t=\tau t = τ can be correctly generated, i.e. we have I ^ k 1 , j 1 λ [ 1 : τ ] = ( ( K + j 1 ) × ( τ − 1 ) , k 1 ) \widehat{I}^{\lambda}_{k_1,j_1}[1:\tau]=((K+j_1)^{\times(\tau-1)},k_1) I k 1 , j 1 λ [ 1 : τ ] = (( K + j 1 ) × ( τ − 1 ) , k 1 ) .
Feature: From Lemma D.12 , when τ ≤ t ≤ τ + L − 2 \tau\le t\le\tau+L-2 τ ≤ t ≤ τ + L − 2 , we know that with o ( 1 ) < λ < 1 + o ( 1 ) o(1)<\lambda<1+o(1) o ( 1 ) < λ < 1 + o ( 1 ) , given input ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × ( t − τ + 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)},(k_1)^{\times(t-\tau+1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × ( t − τ + 1 ) ) , the greedy decoding will output k 1 k_1 k 1 , i.e. arg max i logit t [ i ] = k 1 \arg\max_i\operatorname{logit}_t[i]=k_1 arg max i logit t [ i ] = k 1 . So the required feature at t = τ + 1 , ⋯ , τ + L − 1 t=\tau+1,\cdots,\tau+L-1 t = τ + 1 , ⋯ , τ + L − 1 can be correctly generated, i.e. the generated image satisfies I ^ k 1 , j 1 λ [ 1 : τ + L − 1 ] = ( ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × L ) \widehat{I}^{\lambda}_{k_1,j_1}[1:\tau+L-1]=((K+j_1)^{\times(\tau-1)},(k_1)^{\times L}) I k 1 , j 1 λ [ 1 : τ + L − 1 ] = (( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × L ) .
After feature: From Lemma D.13 , when τ ≤ t ≤ τ + L − 2 \tau\le t\le\tau+L-2 τ ≤ t ≤ τ + L − 2 , we know that with o ( 1 ) < λ < 1 + o ( 1 ) o(1)<\lambda<1+o(1) o ( 1 ) < λ < 1 + o ( 1 ) , given input ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × ( t − τ + 1 ) , ( K + j 1 ) × ( t − τ − L + 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)},(k_1)^{\times(t-\tau+1)},(K+j_1)^{\times(t-\tau-L+1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × ( t − τ + 1 ) , ( K + j 1 ) × ( t − τ − L + 1 ) ) , the greedy decoding satisfies arg max i logit t [ i ] = K + j 1 \arg\max_i\operatorname{logit}_t[i]=K+j_1 arg max i logit t [ i ] = K + j 1 . So the required feature at t = τ + L , ⋯ , T t=\tau+L,\cdots,T t = τ + L , ⋯ , T can be correctly generated, i.e. we have I ^ k 1 , j 1 λ [ 1 : T ] = ( ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × L , ( K + j 1 ) × ( T − τ − L + 1 ) ) \widehat{I}^{\lambda}_{k_1,j_1}[1:T]=((K+j_1)^{\times(\tau-1)},(k_1)^{\times L},(K+j_1)^{\times(T-\tau-L+1)}) I k 1 , j 1 λ [ 1 : T ] = (( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × L , ( K + j 1 ) × ( T − τ − L + 1 ) ) .
This pattern holds for all k ∈ [ K ] , j ∈ [ J ] k\in[K],j\in[J] k ∈ [ K ] , j ∈ [ J ] because k 1 , j 1 k_1,j_1 k 1 , j 1 in the proof are arbitrary. In conclusion, the final image I ^ k 1 , j 1 λ = I k 1 \widehat{I}^{\lambda}_{k_1,j_1}=I_{k_1} I k 1 , j 1 λ = I k 1 , when o ( 1 ) < λ < 1 + o ( 1 ) o(1)<\lambda<1+o(1) o ( 1 ) < λ < 1 + o ( 1 ) . Thus, we conclude the proof of Lemma D.15 .
Step 11: Incorrectly Generation with Conditional Model
Similarly, we now analyze the incorrectness of generation with conditional model. The intuition is that the conditional model fails to predict correctly at the transition position, triggering a cascade of errors in subsequent feature blocks and causing the generation to collapse into repetitive sequences.
Lemma D.16 (Incorrectness of Generation with Conditional Model). Only with conditional model, i.e. with guidance scale λ = 0 \lambda=0 λ = 0 , the trained Transformer generates invalid sequence that repeats background I ^ k , j 0 ( θ ( 2 ) ) = ( ( K + j ) × T ) ≠ I k , j \widehat{I}^{0}_{k,j}(\theta^{(2)})=((K+j)^{\times T})\ne I_{k,j} I k , j 0 ( θ ( 2 ) ) = (( K + j ) × T ) = I k , j , for all k ∈ [ K ] , j ∈ [ J ] k\in[K],j\in[J] k ∈ [ K ] , j ∈ [ J ] .
Proof. Consider feature class k 1 k_1 k 1 and background class j 1 j_1 j 1 , follow the inference procedure defined in § 5 , starting with prefix [ K + J + k 1 , K + j 1 ] [K+J+k_1,K+j_1] [ K + J + k 1 , K + j 1 ] .
Before feature: From Lemma D.10, when 1 ≤ t < τ − 1 1\le t<\tau-1 1 ≤ t < τ − 1 , given input ( K + J + k 1 , ( K + j 1 ) × t ) (K+J+k_1,(K+j_1)^{\times t}) ( K + J + k 1 , ( K + j 1 ) × t ) , we know that the attention pattern is asymptotic uniform, i.e. α t l = 1 / ( t + 1 ) \alpha_{tl}=1/(t+1) α tl = 1/ ( t + 1 ) , for l ≤ t l\le t l ≤ t , so the output logits is the same with those in Lemma D.7 for sufficiently large T T T . Therefore, we know that arg max i logit t [ i ] = K + j 1 \arg\max_i\operatorname{logit}_t[i]=K+j_1 arg max i logit t [ i ] = K + j 1 . So the background feature at t = 2 , ⋯ , τ − 1 t=2,\cdots,\tau-1 t = 2 , ⋯ , τ − 1 can be correctly generated, i.e. the generated image satisfies I ^ k 1 , j 1 0 [ 1 : τ − 1 ] = ( ( K + j 1 ) × ( τ − 1 ) ) \widehat{I}^{0}_{k_1,j_1}[1:\tau-1]=((K+j_1)^{\times(\tau-1)}) I k 1 , j 1 0 [ 1 : τ − 1 ] = (( K + j 1 ) × ( τ − 1 ) ) .
Transition: From Lemma D.11, when t = τ − 1 t=\tau-1 t = τ − 1 , given input ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) ) , the attention concentrate to f K + J + k 1 f_{K+J+k_1} f K + J + k 1 , i.e. α t 0 = 1 + o ( 1 ) \alpha_{t0}=1+o(1) α t 0 = 1 + o ( 1 ) , ∑ l = 1 τ − 1 α t l = o ( 1 ) \sum_{l=1}^{\tau-1}\alpha_{tl}=o(1) ∑ l = 1 τ − 1 α tl = o ( 1 ) , where the error is exponentially small. With direct expansion, we have o t = W V ( 1 ) f K + J + k 1 + o ( 1 ) W V ( 1 ) ( f K + j 1 − f K + J + k 1 ) o_t=W_V^{(1)}f_{K+J+k_1}+o(1)W_V^{(1)}(f_{K+j_1}-f_{K+J+k_1}) o t = W V ( 1 ) f K + J + k 1 + o ( 1 ) W V ( 1 ) ( f K + j 1 − f K + J + k 1 ) . Use results in Lemma D.5 , and use similar technique in Lemma D.10–Lemma D.13 to compute the logits using the coefficient before each embeddings, we have
logit t [ k 1 ] = − η v p k 1 A K + J + k 1 K + J + η v p k 1 C K + J + k 1 + o ( 1 ) , logit t [ K + j ] = − η v p k 1 A K + J + k 1 K + J + p k 1 q j B K + J + k 1 + o ( 1 ) , j ∈ [ J ] , logit t [ k ] = − η v p k 1 A K + J + k 1 K + J + o ( 1 ) , k ∈ [ K ] . \begin{aligned}
\operatorname{logit}_t[k_1] &= -\frac{\eta v p_{k_1}A_{K+J+k_1}}{K+J}+\eta v p_{k_1}C_{K+J+k_1}+o(1),\\
\operatorname{logit}_t[K+j] &= -\frac{\eta v p_{k_1}A_{K+J+k_1}}{K+J}+p_{k_1}q_jB_{K+J+k_1}+o(1),\quad j\in[J],\\
\operatorname{logit}_t[k] &= -\frac{\eta v p_{k_1}A_{K+J+k_1}}{K+J}+o(1),\quad k\in[K].
\end{aligned} logit t [ k 1 ] logit t [ K + j ] logit t [ k ] = − K + J η v p k 1 A K + J + k 1 + η v p k 1 C K + J + k 1 + o ( 1 ) , = − K + J η v p k 1 A K + J + k 1 + p k 1 q j B K + J + k 1 + o ( 1 ) , j ∈ [ J ] , = − K + J η v p k 1 A K + J + k 1 + o ( 1 ) , k ∈ [ K ] .
where the shared term comes from the coefficient of f ˉ \bar{f} f ˉ . So using Eqn. (D.8) and Proposition D.4 , we know that C K + J + k 1 < q j B K + J + k 1 C_{K+J+k_1}<q_jB_{K+J+k_1} C K + J + k 1 < q j B K + J + k 1 with sufficiently large T T T , so with greedy decoding, we have arg max i logit t [ i ] = K + j 1 \arg\max_i\operatorname{logit}_t[i]=K+j_1 arg max i logit t [ i ] = K + j 1 . Therefore, the required feature token k 1 k_1 k 1 at t = τ t=\tau t = τ cannot be correctly generated. So the generated images is already not valid, i.e. I ^ k 1 , j 1 0 ( θ 2 ) ≠ I k 1 , j 1 \widehat{I}_{k_1,j_1}^{0}(\theta^{2})\ne I_{k_1,j_1} I k 1 , j 1 0 ( θ 2 ) = I k 1 , j 1 .
Feature: Because at t = τ − 1 t=\tau-1 t = τ − 1 , the model predict K + j 1 K+j_1 K + j 1 , the given input at t = τ t=\tau t = τ still only contain text token and background token, i.e. ( K + J + k 1 , ( K + j 1 ) × T ) (K+J+k_1,(K+j_1)^{\times T}) ( K + J + k 1 , ( K + j 1 ) × T ) . Know we use induction to show that the model keep predict K + j 1 K+j_1 K + j 1 using greedy decoding in t = τ , ⋯ , τ + L − 2 t=\tau,\cdots,\tau+L-2 t = τ , ⋯ , τ + L − 2 .
Formally, we should prove: for τ ≤ t ≤ τ + L − 2 \tau\le t\le\tau+L-2 τ ≤ t ≤ τ + L − 2 , a r g m a x i logit t [ i ] = K + j 1 \mathop{\rm arg\,max}_i\operatorname{logit}_t[i]=K+j_1 arg max i logit t [ i ] = K + j 1 and the next input is the input is ( K + J + k 1 , ( K + j 1 ) × ( t + 1 ) ) (K+J+k_1,(K+j_1)^{\times(t+1)}) ( K + J + k 1 , ( K + j 1 ) × ( t + 1 ) ) .
Base Case: At t = τ t=\tau t = τ , directly expand the softmax function with feature-position correlation, we can compute the attention pattern
α t 0 = exp ( e t T W Q K ( 1 ) f K + J + k 1 ) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) + τ exp ( e t T W Q K ( 1 ) f K + j 1 ) = 1 1 + τ exp ( e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) ) = 1 + o ( 1 ) , \begin{aligned}
\alpha_{t0}=\frac{\exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+J+k_1})}{\exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+J+k_1})+\tau\exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+j_1})} \\
&=\frac{1}{1+\tau\exp(e_t^{\mathsf T}W_{QK}^{(1)}(f_{K+j_1}-f_{K+J+k_1}))} \\
&=1+o(1),
\end{aligned} α t 0 = exp ( e t T W Q K ( 1 ) f K + J + k 1 ) + τ exp ( e t T W Q K ( 1 ) f K + j 1 ) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) = 1 + τ exp ( e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 )) 1 = 1 + o ( 1 ) ,
where the second divide exp ( e t T W Q K ( 1 ) f K + J + k 1 ) \exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+J+k_1}) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) from the numerator and denominator, and the last equality using the assumption in Theorem D.1 that τ = Θ ( T β ) \tau=\Theta(T^\beta) τ = Θ ( T β ) and results from Lemma D.12 that at t = τ t=\tau t = τ , e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) = − Θ ( T 1 − β ) e_t^{\mathsf T}W_{QK}^{(1)}(f_{K+j_1}-f_{K+J+k_1})=-\Theta(T^{1-\beta}) e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) = − Θ ( T 1 − β ) . So we know that ∑ l = 1 τ α t l = o ( 1 ) \sum_{l=1}^{\tau}\alpha_{tl}=o(1) ∑ l = 1 τ α tl = o ( 1 ) , where o ( 1 ) o(1) o ( 1 ) is exponentially small. Now this case degenerate to the same case as the transition case above. Similarly, with direct expansion, we have o t = W V ( 1 ) f K + J + k 1 + o ( 1 ) W V ( 1 ) ( f K + j 1 − f K + J + k 1 ) o_t=W_V^{(1)}f_{K+J+k_1}+o(1)W_V^{(1)}(f_{K+j_1}-f_{K+J+k_1}) o t = W V ( 1 ) f K + J + k 1 + o ( 1 ) W V ( 1 ) ( f K + j 1 − f K + J + k 1 ) . Use results in Lemma D.5 , and use similar technique in Lemma D.10–Lemma D.13 to compute the logits using the coefficient before each embeddings, we have
logit t [ k 1 ] = − η V p k 1 A K + J + k 1 K + J + η V p k 1 C K + J + k 1 + o ( 1 ) , \operatorname{logit}_t[k_1]=-\frac{\eta Vp_{k_1}A_{K+J+k_1}}{K+J}+\eta Vp_{k_1}C_{K+J+k_1}+o(1), logit t [ k 1 ] = − K + J η V p k 1 A K + J + k 1 + η V p k 1 C K + J + k 1 + o ( 1 ) ,
logit t [ K + j ] = − η V p k 1 A K + J + k 1 K + J + p k 1 q j B K + J + k 1 + o ( 1 ) , j ∈ [ J ] , \operatorname{logit}_t[K+j]=-\frac{\eta Vp_{k_1}A_{K+J+k_1}}{K+J}+p_{k_1}q_jB_{K+J+k_1}+o(1),\quad j\in[J], logit t [ K + j ] = − K + J η V p k 1 A K + J + k 1 + p k 1 q j B K + J + k 1 + o ( 1 ) , j ∈ [ J ] ,
logit t [ k ] = − η V p k 1 A K + J + k 1 K + J + o ( 1 ) , k ∈ [ K ] , \operatorname{logit}_t[k]=-\frac{\eta Vp_{k_1}A_{K+J+k_1}}{K+J}+o(1),\quad k\in[K], logit t [ k ] = − K + J η V p k 1 A K + J + k 1 + o ( 1 ) , k ∈ [ K ] ,
where the shared term comes from the coefficient of f ˉ \bar{f} f ˉ . So using Eqn. (D.8) and Proposition D.4 , we know that C K + J + k 1 < q j B K + J + k 1 C_{K+J+k_1}<q_jB_{K+J+k_1} C K + J + k 1 < q j B K + J + k 1 with sufficiently large T T T , so with greedy decoding, we have a r g m a x i logit t [ i ] = K + j 1 \mathop{\rm arg\,max}_i\operatorname{logit}_t[i]=K+j_1 arg max i logit t [ i ] = K + j 1 . Therefore, the required feature token k 1 k_1 k 1 at t = τ + 1 t=\tau+1 t = τ + 1 cannot be correctly generated. So the generated images is already not valid, i.e. I ^ k 1 , j 1 0 ( θ 2 ) ≠ I k 1 , j 1 \widehat{I}_{k_1,j_1}^{0}(\theta^{2})\ne I_{k_1,j_1} I k 1 , j 1 0 ( θ 2 ) = I k 1 , j 1 . And the input for next time step is ( K + J + k 1 , ( K + j 1 ) × ( τ + 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau+1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ + 1 ) ) .
Induction: Suppose the induction assumptions holds for τ < s ≤ τ + L − 3 \tau<s\le\tau+L-3 τ < s ≤ τ + L − 3 , we know that at t = s + 1 t=s+1 t = s + 1 , the input is ( K + J + k 1 , ( K + j 1 ) × ( s + 1 ) ) (K+J+k_1,(K+j_1)^{\times(s+1)}) ( K + J + k 1 , ( K + j 1 ) × ( s + 1 ) ) , so by directly expand the softmax function with position-feature correlation, we can compute attention score
α t 0 = exp ( e t T W Q K ( 1 ) f K + J + k 1 ) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) + ( s + 1 ) exp ( e t T W Q K ( 1 ) f K + j 1 ) = 1 + o ( 1 ) , \alpha_{t0}=\frac{\exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+J+k_1})}{\exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+J+k_1})+(s+1)\exp(e_t^{\mathsf T}W_{QK}^{(1)}f_{K+j_1})}=1+o(1), α t 0 = exp ( e t T W Q K ( 1 ) f K + J + k 1 ) + ( s + 1 ) exp ( e t T W Q K ( 1 ) f K + j 1 ) exp ( e t T W Q K ( 1 ) f K + J + k 1 ) = 1 + o ( 1 ) ,
where we use the same technique as the base case, because they are almost the same except there are more terms related to background feature f K + j 1 f_{K+j_1} f K + j 1 , but τ < s ≤ τ + L − 3 \tau<s\le\tau+L-3 τ < s ≤ τ + L − 3 is still small compared to the exponential term exp ( − Θ ( T 1 − β ) ) \exp(-\Theta(T^{1-\beta})) exp ( − Θ ( T 1 − β )) comes from exp ( e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) ) \exp(e_t^{\mathsf T}W_{QK}^{(1)}(f_{K+j_1}-f_{K+J+k_1})) exp ( e t T W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 )) . So the attention pattern is the same as the base case, which concentrates on the text token at t = τ t=\tau t = τ . With the same procedure, using Eqn. (D.8) and Proposition D.4 , when T T T is sufficiently large, we have a r g m a x i logit t [ i ] = K + j 1 \mathop{\rm arg\,max}_i\operatorname{logit}_t[i]=K+j_1 arg max i logit t [ i ] = K + j 1 . So the required feature at t = s + 1 t=s+1 t = s + 1 cannot be correctly generated. And the input for next time step is ( K + J + k 1 , ( K + j 1 ) × ( s + 2 ) ) (K+J+k_1,(K+j_1)^{\times(s+2)}) ( K + J + k 1 , ( K + j 1 ) × ( s + 2 ) ) .
Therefore, we prove that in the generated image, the original position for feature k 1 k_1 k 1 is now all K + j 1 K+j_1 K + j 1 , i.e. I ^ k 1 , j 1 0 [ 1 : τ + L − 1 ] = ( ( K + j 1 ) × ( τ + L − 1 ) ) \widehat{I}_{k_1,j_1}^{0}[1:\tau+L-1]=((K+j_1)^{\times(\tau+L-1)}) I k 1 , j 1 0 [ 1 : τ + L − 1 ] = (( K + j 1 ) × ( τ + L − 1 ) ) .
After feature: Because from previous results, at t = τ + L − 1 t=\tau+L-1 t = τ + L − 1 , the input are all background token, i.e. I ^ k 1 , j 1 0 [ 1 : τ + L − 1 ] = ( ( K + j 1 ) × ( τ + L − 1 ) ) \hat{I}^{0}_{k_{1},j_{1}}[1:\tau+L-1]=((K+j_{1})^{\times(\tau+L-1)}) I ^ k 1 , j 1 0 [ 1 : τ + L − 1 ] = (( K + j 1 ) × ( τ + L − 1 ) ) . Know we use induction to show that the model keep predict K + j 1 K+j_{1} K + j 1 using greedy decoding in τ + L − 1 ≤ t ≤ T − 1 \tau+L-1\leq t\leq T-1 τ + L − 1 ≤ t ≤ T − 1 . Formally, we should prove: for τ + L − 1 ≤ t ≤ T − 1 \tau+L-1\leq t\leq T-1 τ + L − 1 ≤ t ≤ T − 1 , a r g m a x i logit t [ i ] = K + j 1 \mathop{\rm arg\,max}_{i}\operatorname{logit}_{t}[i]=K+j_{1} arg max i logit t [ i ] = K + j 1 and the next input is the input is ( K + J + k 1 , ( K + j 1 ) × ( t + 1 ) ) (K+J+k_{1},(K+j_{1})^{\times(t+1)}) ( K + J + k 1 , ( K + j 1 ) × ( t + 1 ) ) .
Base Case: At t = τ + L − 1 t=\tau+L-1 t = τ + L − 1 , directly expand the softmax function with feature-position correlation, we can compute the attention pattern
α t 0 = exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) + ( τ + L − 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + j 1 ) = 1 τ + L + o ( 1 ) , \alpha_{t0}=\frac{\exp(e_{t}^{\top}W_{QK}^{(1)}f_{K+J+k_{1}})}{\exp(e_{t}^{\top}W_{QK}^{(1)}f_{K+J+k_{1}})+(\tau+L-1)\exp(e_{t}^{\top}W_{QK}^{(1)}f_{K+j_{1}})}=\frac{1}{\tau+L}+o(1), α t 0 = exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) + ( τ + L − 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + j 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) = τ + L 1 + o ( 1 ) ,
where the second divide exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) \exp(e_{t}^{\top}W_{QK}^{(1)}f_{K+J+k_{1}}) exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) from the numerator and denominator, and the last equality using the assumption in Theorem D.1 that τ = Θ ( T β ) \tau=\Theta(T^{\beta}) τ = Θ ( T β ) and results from Proposition D.9 that at t ∉ F t\notin\mathcal{F} t ∈ / F , e t ⊤ W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) = o ( 1 ) e_{t}^{\top}W_{QK}^{(1)}(f_{K+j_{1}}-f_{K+J+k_{1}})=o(1) e t ⊤ W Q K ( 1 ) ( f K + j 1 − f K + J + k 1 ) = o ( 1 ) , which is exponentially small. With similar technique, we know that ∑ l = 1 t α t l = ( τ + L − 1 ) / ( τ + L ) + o ( 1 ) \sum_{l=1}^{t}\alpha_{tl}=(\tau+L-1)/(\tau+L)+o(1) ∑ l = 1 t α tl = ( τ + L − 1 ) / ( τ + L ) + o ( 1 ) . Therefore, the attention is asymptotically uniform, and using results from Lemma D.5 , and similar technique above to compute the logits by the coefficient before each embeddings, we have
logit t [ k ] = A ~ ( t ) + η V ( τ + L − 1 ) τ + L p k q j 1 C K + j 1 + o ( 1 ) , k ∈ [ K ] , k ≠ k 1 , \operatorname{logit}_{t}[k]=\widetilde{A}(t)+\frac{\eta_{V}(\tau+L-1)}{\tau+L}p_{k}q_{j_{1}}C_{K+j_{1}}+o(1),\qquad k\in[K],k\ne k_{1}, logit t [ k ] = A ( t ) + τ + L η V ( τ + L − 1 ) p k q j 1 C K + j 1 + o ( 1 ) , k ∈ [ K ] , k = k 1 ,
logit t [ k 1 ] = A ~ ( t ) + η V τ + L p k 1 ( ( τ + L − 1 ) q j 1 C K + j 1 + C K + J + k 1 ) + o ( 1 ) , \operatorname{logit}_{t}[k_{1}]=\widetilde{A}(t)+\frac{\eta_{V}}{\tau+L}p_{k_{1}}\left((\tau+L-1)q_{j_{1}}C_{K+j_{1}}+C_{K+J+k_{1}}\right)+o(1), logit t [ k 1 ] = A ( t ) + τ + L η V p k 1 ( ( τ + L − 1 ) q j 1 C K + j 1 + C K + J + k 1 ) + o ( 1 ) ,
logit t [ K + j ] = A ~ ( t ) + η V t + 1 q j p k 1 B K + J + k 1 + o ( 1 ) , j ∈ [ J ] , j ≠ j 1 , \operatorname{logit}_{t}[K+j]=\widetilde{A}(t)+\frac{\eta_{V}}{t+1}q_{j}p_{k_{1}}B_{K+J+k_{1}}+o(1),\qquad j\in[J],j\ne j_{1}, logit t [ K + j ] = A ( t ) + t + 1 η V q j p k 1 B K + J + k 1 + o ( 1 ) , j ∈ [ J ] , j = j 1 ,
logit t [ K + j 1 ] = A ~ ( t ) + η V t + 1 q j 1 p k 1 B K + J + k 1 + η V t + 1 ( τ + L − 1 ) q j 1 B K + j 1 + o ( 1 ) , \operatorname{logit}_{t}[K+j_{1}]=\widetilde{A}(t)+\frac{\eta_{V}}{t+1}q_{j_{1}}p_{k_{1}}B_{K+J+k_{1}}+\frac{\eta_{V}}{t+1}(\tau+L-1)q_{j_{1}}B_{K+j_{1}}+o(1), logit t [ K + j 1 ] = A ( t ) + t + 1 η V q j 1 p k 1 B K + J + k 1 + t + 1 η V ( τ + L − 1 ) q j 1 B K + j 1 + o ( 1 ) ,
where the A ~ ( t ) \widetilde{A}(t) A ( t ) is the shared factor in Lemma D.6 , because this case is asymptotic the same as the uniform case. So using the asymptotic order in Eqn. D.8, with sufficiently large T T T , B K + j 1 B_{K+j_{1}} B K + j 1 dominates, we have greedy decoding a r g m a x i logit t [ i ] = K + j 1 \mathop{\rm arg\,max}_{i}\operatorname{logit}_{t}[i]=K+j_{1} arg max i logit t [ i ] = K + j 1 . And the input for next time step is ( K + J + k 1 , ( K + j 1 ) × ( τ + 1 ) ) (K+J+k_{1},(K+j_{1})^{\times(\tau+1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ + 1 ) ) .
Induction: Suppose the induction assumptions holds for τ + L − 1 < s ≤ T − 2 \tau+L-1<s\leq T-2 τ + L − 1 < s ≤ T − 2 , we know that at t = s + 1 t=s+1 t = s + 1 , the input is ( K + J + k 1 , ( K + j 1 ) × ( s + 1 ) ) (K+J+k_{1},(K+j_{1})^{\times(s+1)}) ( K + J + k 1 , ( K + j 1 ) × ( s + 1 ) ) , so attention pattern is
α t 0 = exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) + ( s + 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + j 1 ) = 1 s + 2 + o ( 1 ) , \alpha_{t0}=\frac{\exp(e_{t}^{\top}W_{QK}^{(1)}f_{K+J+k_{1}})}{\exp(e_{t}^{\top}W_{QK}^{(1)}f_{K+J+k_{1}})+(s+1)\exp(e_{t}^{\top}W_{QK}^{(1)}f_{K+j_{1}})}=\frac{1}{s+2}+o(1), α t 0 = exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) + ( s + 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + j 1 ) exp ( e t ⊤ W Q K ( 1 ) f K + J + k 1 ) = s + 2 1 + o ( 1 ) ,
where we use the same technique as the base case, because they are almost the same except there are more terms related to background feature f K + j 1 f_{K+j_{1}} f K + j 1 , and in this area, t ∉ F t\notin\mathcal{F} t ∈ / F , so we still have e t ⊤ W Q K ( 1 ) f K + j 1 = o ( 1 ) , e t ⊤ W Q K ( 1 ) f k 1 = o ( 1 ) e_{t}^{\top}W_{QK}^{(1)}f_{K+j_{1}}=o(1),e_{t}^{\top}W_{QK}^{(1)}f_{k_{1}}=o(1) e t ⊤ W Q K ( 1 ) f K + j 1 = o ( 1 ) , e t ⊤ W Q K ( 1 ) f k 1 = o ( 1 ) . And we have ∑ l = 1 t α t l = ( s + 1 ) / ( s + 2 ) + o ( 1 ) \sum_{l=1}^{t}\alpha_{tl}=(s+1)/(s+2)+o(1) ∑ l = 1 t α tl = ( s + 1 ) / ( s + 2 ) + o ( 1 ) . So the attention pattern is the same as the base case, which is asymptotically uniform. With the same procedure, using Eqn. (D.8) and Proposition D.4 , when T T T is sufficiently large, we have a r g m a x i logit t [ i ] = K + j 1 \mathop{\rm arg\,max}_{i}\operatorname{logit}_{t}[i]=K+j_{1} arg max i logit t [ i ] = K + j 1 . And the input for next time step is ( K + J + k 1 , ( K + j 1 ) × ( s + 1 ) ) (K+J+k_{1},(K+j_{1})^{\times(s+1)}) ( K + J + k 1 , ( K + j 1 ) × ( s + 1 ) ) .
Therefore, we finish the induction. And we know that, with greedy decoding, the predictions will repeat K + j 1 K+j_{1} K + j 1 at every position. This pattern holds for all k ∈ [ K ] , j ∈ [ J ] k\in[K],j\in[J] k ∈ [ K ] , j ∈ [ J ] because k 1 , j 1 k_{1},j_{1} k 1 , j 1 in the proof are arbitrary. In conclusion, T k , j 0 ( θ ( 2 ) ) = ( ( K + j ) × T ) ≠ I k , j T^{0}_{k,j}(\theta^{(2)})=((K+j)^{\times T})\ne I_{k,j} T k , j 0 ( θ ( 2 ) ) = (( K + j ) × T ) = I k , j . Thus, we conclude the proof of Lemma D.16 .
Step 12: Alignment of Conditional Model and Unconditional Model
Now we prove that during successful generation, the conditional model and unconditional model have the same prediction with greedy decoding.
Lemma D.17 (Alignment of Conditional Model and Unconditional Model). With guidance scale o ( 1 ) < λ < 1 + o ( 1 ) o(1)<\lambda<1+o(1) o ( 1 ) < λ < 1 + o ( 1 ) , where o ( 1 ) o(1) o ( 1 ) denotes a positive vanishing term, during the generation, the conditional model and unconditional model has the same prediction, which means
arg max i logit t [ i ] = arg max i logit t u c [ i ] . \underset{i}{\arg\max}\ \operatorname{logit}_{t}[i]=\underset{i}{\arg\max}\ \operatorname{logit}_{t}^{uc}[i]. i arg max logit t [ i ] = i arg max logit t u c [ i ] .
Proof. Because we are now considering the unconditional model and conditional model seperately, without CFG operation. From Lemma D.10–Lemma D.13 , we know that the attention pattern are concentrate on some tokens, with exponentially small error. So we firstly analyze the dominant embedding in W V ( 1 ) f K + J + k 1 W_{V}^{(1)}f_{K+J+k_1} W V ( 1 ) f K + J + k 1 , W V ( 1 ) f K + j 1 W_{V}^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 or W V ( 1 ) f k 1 W_{V}^{(1)}f_{k_1} W V ( 1 ) f k 1 , and then discuss for different time regime.
Dominant embedding of W V ( 1 ) f K + J + k 1 , W V ( 1 ) f K + j 1 , W V ( 1 ) f k 1 W_{V}^{(1)}f_{K+J+k_1},W_{V}^{(1)}f_{K+j_1},W_{V}^{(1)}f_{k_1} W V ( 1 ) f K + J + k 1 , W V ( 1 ) f K + j 1 , W V ( 1 ) f k 1 : From Lemma D.5 , we know that after projection through W V ( 1 ) W_{V}^{(1)} W V ( 1 ) , the value vector is a linear combination of embeddings
W V ( 1 ) f K + j 1 = η V [ − q j 1 A K + j 1 f ˉ + q j 1 B K + j 1 f K + j 1 + q j 1 C K + j 1 ∑ k p k f k ] , W_{V}^{(1)}f_{K+j_1}=\eta_V\left[-q_{j_1}A_{K+j_1}\bar{f}+q_{j_1}B_{K+j_1}f_{K+j_1}+q_{j_1}C_{K+j_1}\sum_k p_kf_k\right], W V ( 1 ) f K + j 1 = η V [ − q j 1 A K + j 1 f ˉ + q j 1 B K + j 1 f K + j 1 + q j 1 C K + j 1 k ∑ p k f k ] ,
W V ( 1 ) f k 1 = η V [ − p k 1 A k 1 f ˉ + p k 1 ∑ j q j B k 1 f K + j + p k 1 C k 1 f k 1 ] , W_{V}^{(1)}f_{k_1}=\eta_V\left[-p_{k_1}A_{k_1}\bar{f}+p_{k_1}\sum_jq_jB_{k_1}f_{K+j}+p_{k_1}C_{k_1}f_{k_1}\right], W V ( 1 ) f k 1 = η V [ − p k 1 A k 1 f ˉ + p k 1 j ∑ q j B k 1 f K + j + p k 1 C k 1 f k 1 ] ,
W V ( 1 ) f K + J + k 1 = η V [ − p k 1 A K + J + k 1 f ˉ + p k 1 ∑ j q j B K + J + k 1 f K + j + p k 1 C K + J + k 1 f k 1 ] . W_{V}^{(1)}f_{K+J+k_1}=\eta_V\left[-p_{k_1}A_{K+J+k_1}\bar{f}+p_{k_1}\sum_jq_jB_{K+J+k_1}f_{K+j}+p_{k_1}C_{K+J+k_1}f_{k_1}\right]. W V ( 1 ) f K + J + k 1 = η V [ − p k 1 A K + J + k 1 f ˉ + p k 1 j ∑ q j B K + J + k 1 f K + j + p k 1 C K + J + k 1 f k 1 ] .
Further applying results in Eqn. (D.8), we know that: For W V ( 1 ) f K + j 1 W_{V}^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 , because q j 1 B K + j 1 q_{j_1}B_{K+j_1} q j 1 B K + j 1 dominates, the dominant embedding is f K + j 1 f_{K+j_1} f K + j 1 ; for W V ( 1 ) f k 1 W_{V}^{(1)}f_{k_1} W V ( 1 ) f k 1 , from Proposition D.4 , we know that q j B k 1 < C k 1 q_jB_{k_1}<C_{k_1} q j B k 1 < C k 1 , so the dominant embedding is f k 1 f_{k_1} f k 1 ; for W V ( 1 ) f K + J + k 1 W_{V}^{(1)}f_{K+J+k_1} W V ( 1 ) f K + J + k 1 , also from Proposition D.4 , we know that q j B K + J + k 1 < C K + J + k 1 q_jB_{K+J+k_1}<C_{K+J+k_1} q j B K + J + k 1 < C K + J + k 1 , so the dominant embedding is f K + J + k 1 f_{K+J+k_1} f K + J + k 1 . In the above analysis, we ignore the coefficient for f ˉ \bar{f} f ˉ , because they are the same for every embeddings.
We follow the same structure of proof of Lemma D.15 , and we already knows that the generation is correct. Consider feature class k 1 k_1 k 1 and background class j 1 j_1 j 1 , follow the inference procedure stated in § 5 , starting with prefix ( K + J + k 1 , K + j 1 ) (K+J+k_1,K+j_1) ( K + J + k 1 , K + j 1 ) .
Before feature: From Lemma D.10, when 1 ≤ t < τ − 1 1\leq t<\tau-1 1 ≤ t < τ − 1 , we know that, we know that with suitable guidance scale, o ( 1 ) < λ < 1 + o ( 1 ) o(1)<\lambda<1+o(1) o ( 1 ) < λ < 1 + o ( 1 ) , given input ( K + J + k 1 , ( K + j 1 ) × t ) (K+J+k_1,(K+j_1)^{\times t}) ( K + J + k 1 , ( K + j 1 ) × t ) , the attention of conditional model is asymptotically uniform, i.e. α t l = ( 1 + o ( 1 ) ) / ( t + 1 ) \alpha_{tl}=(1+o(1))/(t+1) α tl = ( 1 + o ( 1 )) / ( t + 1 ) for 0 ≤ l ≤ t 0\leq l\leq t 0 ≤ l ≤ t , with exponentially small o ( 1 ) o(1) o ( 1 ) . Because the dominant embedding of W V ( 1 ) f K + J + k 1 , W V ( 1 ) f K + j 1 W_{V}^{(1)}f_{K+J+k_1},W_{V}^{(1)}f_{K+j_1} W V ( 1 ) f K + J + k 1 , W V ( 1 ) f K + j 1 are all f K + j 1 f_{K+j_1} f K + j 1 , the dominant embedding of o t o_t o t is also f K + j 1 f_{K+j_1} f K + j 1 . Because of weight typing, we can know that arg max i logit t [ i ] = K + j 1 \underset{i}{\arg\max}\ \operatorname{logit}_{t}[i]=K+j_1 i arg max logit t [ i ] = K + j 1 .
For unconditional model, all the prefix are f K + j 1 f_{K+j_1} f K + j 1 , so the output is o t u c = W V ( 1 ) f K + j 1 o_{t}^{uc}=W_{V}^{(1)}f_{K+j_1} o t u c = W V ( 1 ) f K + j 1 . Because the dominant embedding in W V ( 1 ) f K + j 1 W_{V}^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 is f K + j 1 f_{K+j_1} f K + j 1 and weight tying, we know that arg max i logit t u c [ i ] = K + j 1 \underset{i}{\arg\max}\ \operatorname{logit}_{t}^{uc}[i]=K+j_1 i arg max logit t u c [ i ] = K + j 1 .
So when 1 ≤ t < τ − 1 1\leq t<\tau-1 1 ≤ t < τ − 1 , we know that arg max i logit t [ i ] = arg max i logit t u c [ i ] = K + j 1 \underset{i}{\arg\max}\ \operatorname{logit}_{t}[i]=\underset{i}{\arg\max}\ \operatorname{logit}_{t}^{uc}[i]=K+j_1 i arg max logit t [ i ] = i arg max logit t u c [ i ] = K + j 1 , the conditional model aligns with the unconditional model.
Transition: From Lemma D.11, when t = τ − 1 t=\tau-1 t = τ − 1 , we know that with o ( 1 ) < λ < 1 + o ( 1 ) o(1)<\lambda<1+o(1) o ( 1 ) < λ < 1 + o ( 1 ) , given input ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) ) , the attention of conditional model concentrate on text token at t = 0 t=0 t = 0 , i.e. α t 0 = 1 + o ( 1 ) \alpha_{t0}=1+o(1) α t 0 = 1 + o ( 1 ) , with exponentially small error. Because the dominant embedding of W V ( 1 ) f K + J + k 1 , W V ( 1 ) f K + j 1 W_{V}^{(1)}f_{K+J+k_1},W_{V}^{(1)}f_{K+j_1} W V ( 1 ) f K + J + k 1 , W V ( 1 ) f K + j 1 are all f K + j 1 f_{K+j_1} f K + j 1 , the dominant embedding of o t o_t o t is also f K + j 1 f_{K+j_1} f K + j 1 . Because of weight typing, we can know that arg max i logit t [ i ] = K + j 1 \underset{i}{\arg\max}\ \operatorname{logit}_{t}[i]=K+j_1 i arg max logit t [ i ] = K + j 1 .
For unconditional model, all the prefix are f K + j 1 f_{K+j_1} f K + j 1 , so the output is o t u c = W V ( 1 ) f K + j 1 o_{t}^{uc}=W_{V}^{(1)}f_{K+j_1} o t u c = W V ( 1 ) f K + j 1 . Because the dominant embedding in W V ( 1 ) f K + j 1 W_{V}^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 is f K + j 1 f_{K+j_1} f K + j 1 and weight tying, we know that the maximum is still K + j 1 K+j_1 K + j 1 , i.e. arg max i logit t u c [ i ] = K + j 1 \underset{i}{\arg\max}\ \operatorname{logit}_{t}^{uc}[i]=K+j_1 i arg max logit t u c [ i ] = K + j 1 .
So when t = τ − 1 t=\tau-1 t = τ − 1 , we know that arg max i logit t [ i ] = arg max i logit t u c [ i ] = K + j 1 \underset{i}{\arg\max}\ \operatorname{logit}_{t}[i]=\underset{i}{\arg\max}\ \operatorname{logit}_{t}^{uc}[i]=K+j_1 i arg max logit t [ i ] = i arg max logit t u c [ i ] = K + j 1 , the conditional model aligns with the unconditional model. Feature: From Lemma D.12 , we know that with suitable guidance scale o ( 1 ) < λ < 1 + o ( 1 ) o(1)<\lambda<1+o(1) o ( 1 ) < λ < 1 + o ( 1 ) , given input ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × ( t − τ + 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)},(k_1)^{\times(t-\tau+1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × ( t − τ + 1 ) ) , we need to discuss two cases: t = τ t=\tau t = τ and τ < t ≤ τ + L − 2 \tau<t\leq\tau+L-2 τ < t ≤ τ + L − 2 .
When t = τ t=\tau t = τ , from the proof of Lemma D.12 , the conditional model half the attention score on text token at t = 0 t=0 t = 0 and the seen feature block, i.e. α t 0 = ( 1 + o ( 1 ) ) / 2 \alpha_{t0}=(1+o(1))/2 α t 0 = ( 1 + o ( 1 )) /2 , α t τ = ( 1 + o ( 1 ) ) / 2 \alpha_{t\tau}=(1+o(1))/2 α t τ = ( 1 + o ( 1 )) /2 , with exponential small error. For sufficiently large T T T , we only need to find the dominant embedding for ( W V ( 1 ) f K + J + k 1 + W V ( 1 ) f k 1 ) / 2 (W_V^{(1)}f_{K+J+k_1}+W_V^{(1)}f_{k_1})/2 ( W V ( 1 ) f K + J + k 1 + W V ( 1 ) f k 1 ) /2 .
Use Lemma D.5 to expand, we know that we need to compare the coefficient for f K + J + k 1 , f k 1 f_{K+J+k_1},f_{k_1} f K + J + k 1 , f k 1 , which are q j ( B K + J + k 1 + B k 1 ) / 2 q_j(B_{K+J+k_1}+B_{k_1})/2 q j ( B K + J + k 1 + B k 1 ) /2 and ( C K + J + k 1 + C k 1 ) / 2 (C_{K+J+k_1}+C_{k_1})/2 ( C K + J + k 1 + C k 1 ) /2 . From the results in Proposition D.4 , we have
C K + J + k 1 + C k 1 B K + J + k 1 + B k 1 = L ( 1 + o ( 1 ) ) / τ + L ( L − 1 ) / ( 2 τ ) + O ( L 3 / τ 2 ) log T + O ( 1 ) + L ( 1 − β ) log T + O ( 1 ) = L − 1 2 ( 1 − β ) τ log T + o ( 1 ) , \frac{C_{K+J+k_1}+C_{k_1}}{B_{K+J+k_1}+B_{k_1}}
=
\frac{L(1+o(1))/\tau+L(L-1)/(2\tau)+O(L^3/\tau^2)}{\log T+O(1)+L(1-\beta)\log T+O(1)}
=
\frac{L-1}{2(1-\beta)\tau\log T}+o(1), B K + J + k 1 + B k 1 C K + J + k 1 + C k 1 = log T + O ( 1 ) + L ( 1 − β ) log T + O ( 1 ) L ( 1 + o ( 1 )) / τ + L ( L − 1 ) / ( 2 τ ) + O ( L 3 / τ 2 ) = 2 ( 1 − β ) τ log T L − 1 + o ( 1 ) ,
where the first equation is direct expansion using exact expression in Proposition D.3 , the second asymptotic equivalence and the last inequality use the assumption in Theorem D.1 . So use the Eqn. (D.9) and proof in Proposition D.3 , we know that for sufficiently large T T T , ( C K + J + k 1 + C k 1 ) / ( B K + J + k 1 + B k 1 ) < q j (C_{K+J+k_1}+C_{k_1})/(B_{K+J+k_1}+B_{k_1})<q_j ( C K + J + k 1 + C k 1 ) / ( B K + J + k 1 + B k 1 ) < q j . With direct computation, we know that q j ( B K + J + k 1 + B k 1 ) / 2 < ( C K + J + k 1 + C k 1 ) / 2 q_j(B_{K+J+k_1}+B_{k_1})/2<(C_{K+J+k_1}+C_{k_1})/2 q j ( B K + J + k 1 + B k 1 ) /2 < ( C K + J + k 1 + C k 1 ) /2 , so the dominant embedding in o t o_t o t is f k 1 f_{k_1} f k 1 . Because of weight tying, we know that arg max i logit t u c [ i ] = k 1 \arg\max_i\operatorname{logit}^{\mathrm{uc}}_t[i]=k_1 arg max i logit t uc [ i ] = k 1 .
For unconditional model, from Lemma D.12 , the attention concentrate on the feature block, so the output is o t u c = W V ( 1 ) f K + j 1 + o ( 1 ) W V ( 1 ) ( f k 1 − f K + j 1 ) o_t^{\mathrm{uc}}=W_V^{(1)}f_{K+j_1}+o(1)W_V^{(1)}(f_{k_1}-f_{K+j_1}) o t uc = W V ( 1 ) f K + j 1 + o ( 1 ) W V ( 1 ) ( f k 1 − f K + j 1 ) , with exponentially small o ( 1 ) o(1) o ( 1 ) . For sufficiently large T T T , because the dominant embedding in W V ( 1 ) f k 1 W_V^{(1)}f_{k_1} W V ( 1 ) f k 1 and weight tying, we know that the maximum logit is at k 1 k_1 k 1 , i.e. arg max i logit t u c [ i ] = k 1 \arg\max_i\operatorname{logit}^{\mathrm{uc}}_t[i]=k_1 arg max i logit t uc [ i ] = k 1 , which is the same as unconditional model.
When τ < t < τ + L − 2 \tau<t<\tau+L-2 τ < t < τ + L − 2 , from the proof of Lemma D.12 , the conditional model and unconditional model concentrate the attention score on the feature block, i.e. ∑ l = τ t α t l = 1 + o ( 1 ) \sum_{l=\tau}^{t}\alpha_{tl}=1+o(1) ∑ l = τ t α tl = 1 + o ( 1 ) , ∑ l = τ t α t l u c = 1 + o ( 1 ) \sum_{l=\tau}^{t}\alpha^{\mathrm{uc}}_{tl}=1+o(1) ∑ l = τ t α tl uc = 1 + o ( 1 ) , with exponentially small error term o ( 1 ) o(1) o ( 1 ) . For sufficiently large T T T , because the dominant embedding in W V ( 1 ) f k 1 W_V^{(1)}f_{k_1} W V ( 1 ) f k 1 and weight tying, we know that arg max i logit t [ i ] = arg max i logit t u c [ i ] = k 1 \arg\max_i\operatorname{logit}_t[i]=\arg\max_i\operatorname{logit}^{\mathrm{uc}}_t[i]=k_1 arg max i logit t [ i ] = arg max i logit t uc [ i ] = k 1 , which is the same as unconditional model.
In conclusion, for feature block τ ≤ t ≤ τ + L − 2 \tau\leq t\leq\tau+L-2 τ ≤ t ≤ τ + L − 2 , the conditional model and unconditional model aligns in the prediction, i.e. arg max i logit t [ i ] = arg max i logit t u c [ i ] \arg\max_i\operatorname{logit}_t[i]=\arg\max_i\operatorname{logit}^{\mathrm{uc}}_t[i] arg max i logit t [ i ] = arg max i logit t uc [ i ] .
After feature: From Lemma D.13 , when τ ≤ t ≤ τ + L − 2 \tau\leq t\leq\tau+L-2 τ ≤ t ≤ τ + L − 2 , we know that with o ( 1 ) < λ < 1 + o ( 1 ) o(1)<\lambda<1+o(1) o ( 1 ) < λ < 1 + o ( 1 ) , given input ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × ( t − τ + 1 ) , ( K + j 1 ) × ( t − τ − L + 1 ) ) (K+J+k_1,(K+j_1)^{\times(\tau-1)},(k_1)^{\times(t-\tau+1)},(K+j_1)^{\times(t-\tau-L+1)}) ( K + J + k 1 , ( K + j 1 ) × ( τ − 1 ) , ( k 1 ) × ( t − τ + 1 ) , ( K + j 1 ) × ( t − τ − L + 1 ) ) , the attention of conditional model and unconditional model are asymptotically uniform, i.e. α t l = ( 1 + o ( 1 ) ) / ( t + 1 ) \alpha_{tl}=(1+o(1))/(t+1) α tl = ( 1 + o ( 1 )) / ( t + 1 ) for 0 ≤ l ≤ t 0\leq l\leq t 0 ≤ l ≤ t , with exponentially small o ( 1 ) o(1) o ( 1 ) . From assumption in Theorem D.1 , we know that τ = Θ ( T β ) , L = Θ ( log T ) \tau=\Theta(T^\beta),L=\Theta(\log T) τ = Θ ( T β ) , L = Θ ( log T ) , so the dominant part is W V ( 1 ) f K + j 1 W_V^{(1)}f_{K+j_1} W V ( 1 ) f K + j 1 for sufficiently large T T T , because the number of fake token K + j 1 K+j_1 K + j 1 is the most. Because the dominant embedding of W V f K + j 1 W_Vf_{K+j_1} W V f K + j 1 are all f K + j 1 f_{K+j_1} f K + j 1 , the dominant embedding of o t o_t o t is also f K + j 1 f_{K+j_1} f K + j 1 . Because of weight tying, we can know that arg max i logit t [ i ] = arg max i logit t u c [ i ] = K + j 1 \arg\max_i\operatorname{logit}_t[i]=\arg\max_i\operatorname{logit}^{\mathrm{uc}}_t[i]=K+j_1 arg max i logit t [ i ] = arg max i logit t uc [ i ] = K + j 1 .
In conclusion, we know that the conditional model and unconditional model has the same prediction, i.e. arg max i logit t [ i ] = arg max i logit t u c [ i ] \arg\max_i\operatorname{logit}_t[i]=\arg\max_i\operatorname{logit}^{\mathrm{uc}}_t[i] arg max i logit t [ i ] = arg max i logit t uc [ i ] . Thus, we conclude the proof of Lemma D.17 . □
Step 13: Proof of Theorem D.1
Proof of Theorem D.1. The three parts of Theorem D.1 can be proved with previous results.
Part I (Loss): From Proposition D.14, the population loss of the trained model is L v i s ( θ ( 2 ) ) = Θ ( ( log T ) 2 / T ) \mathcal{L}_{\mathrm{vis}}(\theta^{(2)})=\Theta((\log T)^2/T) L vis ( θ ( 2 ) ) = Θ (( log T ) 2 / T ) .
Part II (Correctness of Generation with CFG): From Lemma D.15 , we know that with suitable guidance scale λ ∗ ∈ ( o ( 1 ) , 1 + o ( 1 ) ) \lambda^*\in(o(1),1+o(1)) λ ∗ ∈ ( o ( 1 ) , 1 + o ( 1 )) , where o ( 1 ) o(1) o ( 1 ) is positive vanishing term, the generated images is valid, i.e. I ^ k , j = I k , j \widehat{I}_{k,j}=I_{k,j} I k , j = I k , j for k ∈ [ K ] , j ∈ [ J ] k\in[K],j\in[J] k ∈ [ K ] , j ∈ [ J ] .
Part III (Incorrectness of Generation with CFG): From Lemma D.16 , we know that only with conditional models, i.e. λ = 0 \lambda=0 λ = 0 , it generates invalid images that repeats backgrounds, i.e. I ^ k , j ( 2 ) = ( K + j ) × T ≠ I k , j \widehat{I}^{(2)}_{k,j}=(K+j)^{\times T}\neq I_{k,j} I k , j ( 2 ) = ( K + j ) × T = I k , j , for all k ∈ [ K ] , j ∈ [ J ] k\in[K],j\in[J] k ∈ [ K ] , j ∈ [ J ] .
Part IV (Alignment of Conditional and Unconditional Model): From Lemma D.17 , we know that with λ ∗ ∈ ( 1 + o ( 1 ) ) \lambda^{*} \in(1 + o(1)) λ ∗ ∈ ( 1 + o ( 1 )) , the conditional model and unconditional model has the same prediction (with greedy decoding), which means, arg max i logit t [ i ] = arg max i logit t u c [ i ] \operatorname*{arg\,max}_{i} \operatorname{logit}_{t}[i] = \operatorname*{arg\,max}_{i} \operatorname{logit}_{t}^{\mathrm{uc}}[i] arg max i logit t [ i ] = arg max i logit t uc [ i ] .
Thus, we conclude the proof of Theorem D.1 .
Algorithm 1 Attention Weight Reuse (AttnReuse) for AR models
Require: Text-token length T t x t T_{\mathrm{txt}} T txt ; current sequence length t t t ; reuse-layer set L r e u s e \mathcal{L}_{\mathrm{reuse}} L reuse ; CFG scale λ \lambda λ .
Ensure: Guided logits logit t λ \operatorname{logit}^{\lambda}_{t} logit t λ .
for each decoding step t t t do
Run the conditional branch and cache the conditional attention weights { A ℓ c o n d } ℓ ∈ L r e u s e \{A_{\ell}^{\mathrm{cond}}\}_{\ell\in\mathcal{L}_{\mathrm{reuse}}} { A ℓ cond } ℓ ∈ L reuse .
for each layer ℓ \ell ℓ do
if ℓ ∈ L r e u s e \ell\in\mathcal{L}_{\mathrm{reuse}} ℓ ∈ L reuse then
Construct a binary key mask M ∈ { 0 , 1 } t M \in\{0,1\}^{t} M ∈ { 0 , 1 } t :
M j = { 0 , j ≤ T t x t , 1 , T t x t < j ≤ t . M_j =
\begin{cases}
0, & j \le T_{\mathrm{txt}},\\
1, & T_{\mathrm{txt}} < j \le t.
\end{cases} M j = { 0 , 1 , j ≤ T txt , T txt < j ≤ t .
Remove the text-token contribution from the conditional attention weights:
A ~ ℓ r e u s e = A ℓ c o n d ⊙ M . \widetilde{A}_{\ell}^{\mathrm{reuse}} = A_{\ell}^{\mathrm{cond}} \odot M. A ℓ reuse = A ℓ cond ⊙ M .
Renormalize over the key dimension:
A ℓ r e u s e = A ~ ℓ r e u s e ∑ j = 1 t A ~ ℓ , : , j r e u s e + ϵ . A_{\ell}^{\mathrm{reuse}} = \frac{\widetilde{A}_{\ell}^{\mathrm{reuse}}}{\sum_{j=1}^{t}\widetilde{A}_{\ell,:,j}^{\mathrm{reuse}}+\epsilon}. A ℓ reuse = ∑ j = 1 t A ℓ , : , j reuse + ϵ A ℓ reuse .
Approximate the unconditional attention output:
O ℓ r e u s e = A ℓ r e u s e V ℓ c o n d . O_{\ell}^{\mathrm{reuse}} = A_{\ell}^{\mathrm{reuse}}V_{\ell}^{\mathrm{cond}}. O ℓ reuse = A ℓ reuse V ℓ cond .
Replace the unconditional attention output at layer ℓ \ell ℓ with O ℓ r e u s e O_{\ell}^{\mathrm{reuse}} O ℓ reuse .
else
Compute the unconditional attention output with standard attention:
O ℓ u n c o n d = Attn ( Q ℓ u n c o n d , K ℓ u n c o n d , V ℓ u n c o n d ) . O_{\ell}^{\mathrm{uncond}} = \operatorname{Attn}\left(Q_{\ell}^{\mathrm{uncond}}, K_{\ell}^{\mathrm{uncond}}, V_{\ell}^{\mathrm{uncond}}\right). O ℓ uncond = Attn ( Q ℓ uncond , K ℓ uncond , V ℓ uncond ) .
end if
end for
Obtain logit t c o n d \operatorname{logit}_{t}^{\mathrm{cond}} logit t cond from the conditional branch and approximate logit ^ t u n c o n d \widehat{\operatorname{logit}}_{t}^{\mathrm{uncond}} logit t uncond from the resulting unconditional branch.
Compute the guided logits:
logit t λ = logit ^ t u n c o n d + λ ( logit t c o n d − logit ^ t u n c o n d ) . \operatorname{logit}_{t}^{\lambda} = \widehat{\operatorname{logit}}_{t}^{\mathrm{uncond}} + \lambda\left(\operatorname{logit}_{t}^{\mathrm{cond}}-\widehat{\operatorname{logit}}_{t}^{\mathrm{uncond}}\right). logit t λ = logit t uncond + λ ( logit t cond − logit t uncond ) .
Decode the next visual token from logit t λ \operatorname{logit}_{t}^{\lambda} logit t λ .
end for