Eigenvalues, Trace, and PCA on Embeddings

Which directions does a matrix refuse to rotate?

Vishnu Boddeti

Example 1

PCA reveals dominant directions in embedding spaces

What does PCA see in an embedding cloud?

greatest centered variance
  • Embedding clouds are rarely isotropic: frequency, style, or formatting effects can dominate a few directions.
  • PCA finds the orthogonal axes with the most centered variance before we decide what to retain, visualize, or remove.

Covariance eigenvectors are PCA directions

v Cv = λv same direction, different length
  • $C=\frac{1}{n}\sum_i(x_i-\bar{x})(x_i-\bar{x})^\top$ is symmetric and positive semidefinite.
  • $Cv_i=\lambda_i v_i$ means covariance stretches principal direction $v_i$ without rotating it.
  • $\lambda_i$ is the variance along $v_i$; the leading eigenvectors give the principal coordinates.

Change the covariance and identify the first PCA direction

When the two eigenvalues are equal, every direction is principal and the first component is not uniquely defined.

Example 2

Hessian spectra summarize local training curvature

How can training estimate curvature without forming the Hessian?

z autodiff H z zᵀHz average random probes no full Hessian is stored
  • A foundation-model Hessian is far too large to form or store.
  • Automatic differentiation can compute a Hessian-vector product $Hz$ without materializing $H$.
  • Averaging $z^\top Hz$ over random probes estimates total curvature.

Trace is the sum of curvature eigenvalues

H₁₁ H₂₂ = λ₁ + λ₂ tr(H) = H₁₁ + H₂₂ = λ₁ + λ₂ E[zᵀHz] = tr(H)
  • $\operatorname{tr}(H)=\sum_i H_{ii}=\sum_i\lambda_i$ for a Hessian $H$.
  • If $\mathbb{E}[zz^\top]=I$, then $\mathbb{E}[z^\top Hz]=\operatorname{tr}(H)$: the Hutchinson identity.
  • Trace summarizes signed total curvature; leading eigenvalues separately expose sharp directions.

Change a symmetric Hessian and verify its trace two ways

The trace fixes the sum of eigenvalues, not how curvature is distributed between directions.

Example 3

Correlated agent failures reveal a common mode

Which failure pattern dominates an agent evaluation?

retrieval error unsupported claim failed recovery common mode v₁ ∝ (1,1,1) largest variance
  • Standardize the three failure indicators for each agent trace and form $\Sigma=\operatorname{Cov}(f)$.
  • The top eigenvector is the failure combination with the most shared variation.
  • A common mode is diagnostic evidence, not a causal explanation; inspect tasks and traces before intervening.

Increase cross-failure correlation and watch the common mode

Move the control to compare shared and residual variation.
As correlation rises, the shared $(1,1,1)$ direction dominates; residual modes shrink, but the eigenvector still does not identify a cause.

Example 4

Generalized eigenvectors trade utility against invariance

Why does invariant representation learning need two matrices?

target utility Dep(Z,Y) ↑ sensitive leakage Dep(Z,S) ↓ Aλw = τBγw choose the largest τ directions ordinary eigenvectors are the special case B = I
  • $C_Y=\Sigma_{YX}^*\Sigma_{YX}$ measures target dependence; $C_S=\Sigma_{SX}^*\Sigma_{SX}$ measures sensitive dependence.
  • $A_\lambda=(1-\lambda)C_Y-\lambda C_S$ rewards the first and penalizes the second.
  • The positive-definite matrix $B_\gamma=C_X+\gamma I$ defines scale and the constraint $w^\top B_\gamma w=1$.
  • The leading generalized eigenvectors maximize the trade-off Rayleigh quotient $\frac{w^\top A_\lambda w}{w^\top B_\gamma w}$.

Move the trade-off and watch the representation rotate

Increasing $\lambda$ rotates $w$ away from the sensitive direction, but can also reduce target alignment: invariance is not free when $Y$ and $S$ are statistically coupled.

Practice problems

Each scenario hides a mathematical structure from this lecture. Identify the structure, justify it, and work through the resulting problem.

Problem 1 Recurrent and state-space models

Will a recurrent representation explode?

A recurrent block applies the same transition at every token. One component of its state may fade while another grows, so running a thousand steps just to see what happens is a poor debugging strategy. Can the spectrum predict the long-run behavior immediately?

Model evidence

$h_{t+1}=Wh_t$ with $W=\begin{bmatrix}1.1&0\\0&0.7\end{bmatrix}$ and $h_0=(a,b)^\top$.

  1. Write $h_t$ in closed form. Which initial states remain bounded?
  2. For a typical initial state with nonzero $a$, which direction eventually dominates?
  3. What spectral condition would make every trajectory decay to zero?
Problem 2 Graph neural networks

Diagnose oversmoothing from two summary statistics

A graph network is oversmoothing, but the logs saved only two numbers about its propagation matrix: the trace and determinant. Is that enough to discover which mode survives repeated message passing?

Model evidence

The operator is $2\times2$, with $\operatorname{tr}(A)=1.2$ and $\det(A)=0.2$.

  1. What eigenvalues are consistent with the two logged statistics?
  2. Which spectral mode will dominate after many layers?
  3. What additional information would reveal the corresponding direction in the original feature coordinates?
Problem 3 Self-supervised learning

Which feature survives a consistency update?

A self-supervised update is supposed to preserve one semantic feature while washing away nuisance disagreement. Repeating the update provides a simple test: the useful feature should stay put and the nuisance direction should shrink.

Model evidence

$A=\begin{bmatrix}0.8&0.2\\0.1&0.9\end{bmatrix}$ is the local update on two-dimensional embeddings.

  1. How do you express “preserved exactly” as an eigenvector equation, and which eigenvalue does it require?
  2. Which direction is preserved, and which direction contracts?
  3. For a generic starting vector $x$, where does $A^t x$ go as $t$ grows?