Skip to content
PLACE

The KL bound

How jointly minimizing the reconstruction loss and the Gram-matrix alignment loss bounds the KL divergence of a downstream linear classifier.


Let A∈RN×d\mathbf{A} \in \mathbb{R}^{N \times d} be the patch-token activations at layer ℓ\ell and A^=UW⊤\hat{\mathbf{A}} = \mathbf{U}\mathbf{W}^{\top} their Semi-NMF6Convex and Semi-Nonnegative Matrix Factorizations
Chris H.Q. Ding, Tao Li, Michael I. Jordan
IEEE TPAMI, 2010
reconstruction, with Gram matrices G=AA⊤\mathbf{G} = \mathbf{A}\mathbf{A}^{\top} and G^=A^A^⊤\hat{\mathbf{G}} = \hat{\mathbf{A}}\hat{\mathbf{A}}^{\top}. The two error terms controlled by the objective are

δrec=∥A−A^∥F,δgram=Lgram=∥G−G^∥F∥G∥F.\delta_{\text{rec}} = \|\mathbf{A} - \hat{\mathbf{A}}\|_F, \qquad \delta_{\text{gram}} = \sqrt{\mathcal{L}_{\text{gram}}} = \frac{\|\mathbf{G} - \hat{\mathbf{G}}\|_F}{\|\mathbf{G}\|_F}.
Theorem (Appendix C, Eq. 35). Let h(z)=Wcz+bh(z) = W_c z + b be any linear classifier on the CLS token, applied after the remaining Lsuf=L−ℓL_{\text{suf}} = L - \ell transformer blocks g>ℓg_{>\ell}. Then
DKL(σ(h∘g>ℓ(A)) ∥ σ(h∘g>ℓ(A^)))≤12∥Wc∥op2 Lblock2Lsuf(N δrec+α ∥G∥F⋅δgram)2,\begin{aligned} &D_{\mathrm{KL}}\big(\sigma(h \circ g_{>\ell}(\mathbf{A})) \,\big\|\, \sigma(h \circ g_{>\ell}(\hat{\mathbf{A}}))\big) \\ &\quad \le \frac{1}{2} \|W_c\|_{\text{op}}^2\, L_{\text{block}}^{2L_{\text{suf}}} \big( \sqrt{N}\, \delta_{\text{rec}} + \alpha\, \|\mathbf{G}\|_F \cdot \delta_{\text{gram}} \big)^2, \end{aligned}
where LblockL_{\text{block}} is the per-block Lipschitz constant and α\alpha collects attention-projection constants.

How the proof goes

  1. Reconstruction controls the Gram matrix only indirectly. A lemma gives ∥G−G^∥F≤2∥A∥F δrec+δrec2\|\mathbf{G} - \hat{\mathbf{G}}\|_F \le 2\|\mathbf{A}\|_F\, \delta_{\text{rec}} + \delta_{\text{rec}}^2, a bound that grows with the activation scale ∥A∥F\|\mathbf{A}\|_F.
  2. Attention logits. Splitting the query-key product as WQWK⊤=I+(WQWK⊤−I)W_Q W_K^{\top} = I + (W_Q W_K^{\top} - I) shows the Gram error controls the identity part of the logit deviation directly, and reconstruction controls the rest.
  3. One block. Softmax is 1-Lipschitz, and LayerNorm and the FFN are Lipschitz, so each block amplifies the error by at most LblockL_{\text{block}}.
  4. All suffix blocks. Composing over the LsufL_{\text{suf}} blocks bounds the CLS-token deviation by LblockLsuf(N δrec+α∥G∥F δgram)L_{\text{block}}^{L_{\text{suf}}} (\sqrt{N}\, \delta_{\text{rec}} + \alpha \|\mathbf{G}\|_F\, \delta_{\text{gram}}).
  5. To KL. The KL divergence between softmax outputs is a Bregman divergence of the log-partition function, whose Hessian has spectral norm at most 1, so DKL≤12∥u−u^∥22D_{\mathrm{KL}} \le \tfrac{1}{2}\|\mathbf{u} - \hat{\mathbf{u}}\|_2^2 for logits u\mathbf{u}.

What it means

The two losses play complementary roles. Lgram\mathcal{L}_{\text{gram}} constrains the attention-logit deviation directly and independently of scale, which reconstruction does only through ∥A∥F⋅δrec\|\mathbf{A}\|_F \cdot \delta_{\text{rec}}. Lrec\mathcal{L}_{\text{rec}} supplies pointwise fidelity, which the Gram loss cannot constrain because it is invariant to orthogonal transformations of A\mathbf{A}. Neither needs a forward or backward pass through g>ℓg_{>\ell} or hh.

The bound is worst-case and compounds across suffix blocks, so its numerical value is loose. It tightens as ℓ\ell approaches the last layer. It identifies the two quantities whose joint minimization is sufficient to control predictive consistency. The agreement with classifier-supervised concepts is measured on the results page.

References