Part 2Math for LLMs

Vectors and Spaces: Part 2 - High Dimensional Geometry To References

Linear Algebra Basics / Vectors and Spaces

Private notes
0/8000

Notes stay private to your browser until account sync is configured.

Part 2
23 min read18 headingsSplit lesson page

Lesson overview | Previous part | Lesson overview

Vectors and Spaces: Part 9: High-Dimensional Geometry to References

9. High-Dimensional Geometry

9.1 The Curse of Dimensionality

Low-dimensional intuition is unreliable in high dimensions. This broad phenomenon is often called the curse of dimensionality.

One form is volume concentration. For a dd-dimensional ball of radius rr, the fraction of volume inside the inner ball of radius rεr-\varepsilon is

(1εr)d.\left(1 - \frac{\varepsilon}{r}\right)^d.

As dd grows, this shrinks rapidly. Most of the volume moves near the boundary.

Another form is distance concentration. Random points in high-dimensional spaces tend to be at similar distances from each other, so nearest-neighbor structure becomes less contrastive unless data has meaningful low-dimensional structure.

For embeddings, this means random vectors in high dimension are usually nearly orthogonal. Meaningful similarity is therefore a signal against a strong null background of near-right angles.

Volume concentration intuition

low dimension:            high dimension:

[ core | shell ]          [tiny core | shell shell shell shell]

As dimension grows, most volume moves into the shell.

9.2 Concentration of Measure

Concentration of measure says that in high-dimensional spaces, many reasonably smooth functions vary much less than low-dimensional intuition suggests. Informally: a Lipschitz function on a high-dimensional sphere is almost constant on most of the sphere.

One representative result is that if x\mathbf{x} is random on the unit sphere Sd1S^{d-1} and u\mathbf{u} is a fixed unit vector, then the inner product x,u\langle \mathbf{x}, \mathbf{u} \rangle is sharply concentrated near 0 as dd grows.

Consequences:

  • random directions are almost orthogonal
  • norms and averages become more stable than naive geometric pictures suggest
  • random projections preserve more structure than one might expect

These ideas are central to modern high-dimensional probability (Vershynin, 2018) and are one reason random features and approximate nearest neighbor methods work surprisingly well.

9.3 Johnson-Lindenstrauss Lemma

The Johnson-Lindenstrauss lemma formalizes dimension reduction with bounded distortion (Johnson and Lindenstrauss, 1984; Dasgupta and Gupta, 2003).

Given nn points in a high-dimensional Euclidean space and an accuracy parameter ε(0,1)\varepsilon \in (0,1), there exists a linear map

f:RdRkf: \mathbb{R}^d \to \mathbb{R}^k

with

k=O ⁣(lognε2)k = O\!\left(\frac{\log n}{\varepsilon^2}\right)

such that all pairwise distances are preserved up to multiplicative error (1±ε)(1 \pm \varepsilon):

(1ε)vivj22f(vi)f(vj)22(1+ε)vivj22.(1-\varepsilon)\|\mathbf{v}_i - \mathbf{v}_j\|_2^2 \leq \|f(\mathbf{v}_i) - f(\mathbf{v}_j)\|_2^2 \leq (1+\varepsilon)\|\mathbf{v}_i - \mathbf{v}_j\|_2^2.

Remarkably, the target dimension depends logarithmically on the number of points, not on the original ambient dimension.

Practical message for ML:

  • random projections can compress data while preserving geometry
  • retrieval systems can work in reduced spaces
  • head dimension can be much smaller than model dimension without destroying all pairwise structure

9.4 Random Vectors in High Dimensions

If x\mathbf{x} and y\mathbf{y} are independent random unit vectors in Rd\mathbb{R}^d, then for large dd,

E[x,y]=0,Var(x,y)1d.\mathbb{E}[\langle \mathbf{x}, \mathbf{y} \rangle] = 0, \qquad \mathrm{Var}(\langle \mathbf{x}, \mathbf{y} \rangle) \approx \frac{1}{d}.

So the inner product typically has size about 1/d1/\sqrt{d}, which goes to zero with dimension.

A related fact is

xy22=x22+y222x,y2.\|\mathbf{x} - \mathbf{y}\|_2^2 = \|\mathbf{x}\|_2^2 + \|\mathbf{y}\|_2^2 - 2\langle \mathbf{x}, \mathbf{y} \rangle \approx 2.

Thus random unit vectors are not only almost orthogonal; they are also all about the same Euclidean distance apart.

This helps explain why high-dimensional spaces can pack many nearly independent directions. It also explains why cosine similarity is a more informative baseline than raw Euclidean distance in many embedding applications.

9.5 Geometry of Embedding Spaces

Learned embeddings are not random vectors, but high-dimensional geometry strongly shapes how they behave.

Important empirical observations:

  • simple semantic relations can appear as approximately linear directions (Mikolov et al., 2013)
  • contextual embedding spaces are often anisotropic rather than uniformly spread on a sphere (Ethayarajh, 2019)
  • nominal dimension may be large while intrinsic dimension is much smaller
  • singular values of embedding or feature matrices often decay quickly, indicating effective low-rank structure

Anisotropy matters because cosine similarity becomes biased if almost all vectors occupy a narrow cone. Various centering, whitening, and contrastive training methods attempt to improve isotropy for retrieval and representation quality.

The lesson is subtle: high-dimensional space provides enormous capacity, but learned models do not use that capacity uniformly. They carve out structured manifolds, cones, and low-rank directions inside the ambient space.

Embedding geometry: isotropic vs anisotropic

roughly isotropic              anisotropic / narrow cone

     .   .                           . .
   .   o   .                          . .
     .   .                            . .
   .       .                           . .

spread in many directions         packed into a small angular region

9.6 Softmax Temperature and Simplex Geometry

Softmax maps a logit vector zRn\mathbf{z} \in \mathbb{R}^n to a probability vector:

pi=exp(zi/τ)jexp(zj/τ),p_i = \frac{\exp(z_i / \tau)}{\sum_j \exp(z_j / \tau)},

where τ>0\tau > 0 is temperature.

Geometrically:

  • as τ0\tau \to 0, the distribution concentrates near a vertex of the simplex
  • as τ\tau \to \infty, the distribution approaches the center of the simplex

So temperature controls how close the output lies to an extreme point versus the interior of the simplex.

This is not just a sampling trick. It is a geometric control knob for how sharply a model commits to one direction in probability space.

Temperature moves probability inside the simplex

high tau                         low tau

   more uniform                   more peaked

   [0.33 0.33 0.34]  ------->     [0.97 0.02 0.01]
        near center                    near a vertex

10. Linear Maps Between Spaces

10.1 Definition and Properties

A map T:VWT: V \to W is linear if for all vectors u,v\mathbf{u}, \mathbf{v} and scalars α,β\alpha, \beta,

T(αu+βv)=αT(u)+βT(v).T(\alpha \mathbf{u} + \beta \mathbf{v}) = \alpha T(\mathbf{u}) + \beta T(\mathbf{v}).

Equivalently, it preserves addition and scalar multiplication separately.

Immediate consequences:

  • T(0)=0T(\mathbf{0}) = \mathbf{0}
  • T(v)=T(v)T(-\mathbf{v}) = -T(\mathbf{v})
  • TT is determined completely by its action on a basis

For finite-dimensional spaces, every linear map RnRm\mathbb{R}^n \to \mathbb{R}^m is represented by a unique matrix ARm×nA \in \mathbb{R}^{m \times n} such that

T(x)=Ax.T(\mathbf{x}) = A\mathbf{x}.

Composition of linear maps corresponds to matrix multiplication.

10.2 Kernel and Image

The kernel of a linear map is

ker(T)={vV:T(v)=0}.\ker(T) = \{\mathbf{v} \in V : T(\mathbf{v}) = \mathbf{0}\}.

The image is

im(T)={T(v):vV}.\mathrm{im}(T) = \{T(\mathbf{v}) : \mathbf{v} \in V\}.

Both are subspaces.

Interpretation:

  • the kernel contains directions completely ignored by the map
  • the image contains all outputs the map can possibly produce

Injectivity and surjectivity are controlled by these spaces:

  • TT is injective iff ker(T)={0}\ker(T) = \{\mathbf{0}\}
  • TT is surjective iff im(T)=W\mathrm{im}(T) = W

This is a simple but powerful way to reason about architecture. If a projection matrix has a large kernel, then many input directions are guaranteed to be invisible downstream.

10.3 The Four Fundamental Subspaces

For a matrix ARm×nA \in \mathbb{R}^{m \times n}, the four fundamental subspaces are:

  1. column space col(A)Rm\mathrm{col}(A) \subseteq \mathbb{R}^m
  2. null space null(A)Rn\mathrm{null}(A) \subseteq \mathbb{R}^n
  3. row space row(A)=col(A)Rn\mathrm{row}(A) = \mathrm{col}(A^\top) \subseteq \mathbb{R}^n
  4. left null space null(A)Rm\mathrm{null}(A^\top) \subseteq \mathbb{R}^m

They satisfy the orthogonal decompositions

Rn=row(A)null(A),\mathbb{R}^n = \mathrm{row}(A) \oplus \mathrm{null}(A), Rm=col(A)null(A).\mathbb{R}^m = \mathrm{col}(A) \oplus \mathrm{null}(A^\top).

Dimensional relations:

  • dim(col(A))=dim(row(A))=rank(A)\dim(\mathrm{col}(A)) = \dim(\mathrm{row}(A)) = \mathrm{rank}(A)
  • dim(null(A))=nrank(A)\dim(\mathrm{null}(A)) = n - \mathrm{rank}(A)
  • dim(null(A))=mrank(A)\dim(\mathrm{null}(A^\top)) = m - \mathrm{rank}(A)

These decompositions provide a precise vocabulary for information flow:

  • the row space describes which input combinations matter
  • the null space describes which input directions are lost
  • the column space describes what outputs are expressible
  • the left null space describes output directions orthogonal to everything the map can produce
Four fundamental subspaces

Domain R^n                          Codomain R^m

[ row(A) | null(A) ] --A--> [ col(A) | 0 ]
                               ^
                               |
                     left-null directions live here,
                     orthogonal to every reachable output

10.4 Isomorphisms

A linear map T:VWT: V \to W is an isomorphism if it is bijective. Then VV and WW are isomorphic vector spaces.

For finite-dimensional real spaces, the classification is simple:

VWdim(V)=dim(W).V \cong W \quad \Longleftrightarrow \quad \dim(V) = \dim(W).

So all nn-dimensional real vector spaces are structurally equivalent to Rn\mathbb{R}^n, even if their elements look different.

Important caution: isomorphic does not mean equal. The space of quadratic polynomials and R3\mathbb{R}^3 are not the same set, but they are isomorphic because both have dimension 3.

This is why linear algebra can move freely between concrete coordinates and abstract objects. Once a basis is chosen, every finite-dimensional space looks like ordinary Euclidean coordinate space.

10.5 Dual Spaces

The dual space of VV is the space of linear functionals on VV:

V={f:VRf is linear}.V^* = \{f: V \to \mathbb{R} \mid f \text{ is linear}\}.

Elements of the dual space eat vectors and return scalars.

If VV is finite-dimensional, then

dim(V)=dim(V).\dim(V^*) = \dim(V).

With an inner product, every linear functional can be represented as an inner product against a fixed vector:

f(x)=x,v.f(\mathbf{x}) = \langle \mathbf{x}, \mathbf{v} \rangle.

This is the finite-dimensional form of the Riesz representation idea.

In coordinates, row vectors behave like dual vectors:

ax\mathbf{a}^\top \mathbf{x}

is a linear functional of x\mathbf{x}.

This perspective is useful in attention. A query can be viewed as defining a linear functional on key space: it "asks" how much each key aligns with a certain direction. The score qkq^\top k is then the action of a dual vector on a primal vector.


11. Special Vector Spaces in AI

11.1 Embedding Space Geometry

Let ERV×dE \in \mathbb{R}^{|V| \times d} be a token embedding matrix. Each row EtE_t is the embedding of token tt.

This space is where discrete symbols become continuous geometry. The hope is that semantically or syntactically related tokens occupy nearby or meaningfully aligned regions. Word2vec made this idea famous by showing that certain analogical relations behave approximately linearly (Mikolov et al., 2013).

Several geometric questions matter in practice:

  • local similarity: are related tokens close under cosine or Euclidean distance?
  • directional structure: do directions correspond to interpretable relations?
  • isotropy: are embeddings spread broadly or collapsed into a narrow cone?
  • intrinsic dimension: how many effective degrees of freedom are really used?

Modern contextual embeddings complicate the picture because a token does not have a single representation; it acquires one through context-dependent computation. Even so, the geometric language remains the same. Probing methods ask whether a property is linearly readable from a representation, which is a question about whether a suitable separating hyperplane exists in the embedding space.

11.2 Representation Space Through Layers

In a Transformer, each layer maps a sequence representation

X()Rn×dX^{(\ell)} \in \mathbb{R}^{n \times d}

to a new one

X(+1)=X()+f()(X()).X^{(\ell+1)} = X^{(\ell)} + f^{(\ell)}(X^{(\ell)}).

The residual connection means layers do not overwrite the representation from scratch. They add a vector-valued update inside a shared ambient space.

This suggests a productive geometric picture:

  • the residual stream is a shared communication space
  • attention heads read from and write to particular directions or subspaces
  • MLP blocks add structured nonlinear updates in that same space
  • representation learning is partly the art of organizing information so it can be linearly extracted or manipulated later

Mechanistic interpretability often phrases model behavior in exactly these terms: directions, features, subspaces, superposition, and read/write operations into a shared residual stream.

Residual stream picture

X^(l) --------> [ layer computes update f^(l)(X^(l)) ] ----+
  |                                                        |
  +-------------------------- add --------------------------+
                                                           |
                                                           v
                                                        X^(l+1)

11.3 Attention Subspaces

Attention projections are linear maps

WQ,WKRd×dk,WVRd×dv.W_Q, W_K \in \mathbb{R}^{d \times d_k}, \qquad W_V \in \mathbb{R}^{d \times d_v}.

For token representations x,yRd\mathbf{x}, \mathbf{y} \in \mathbb{R}^d,

q=WQx,k=WKy,v=WVy.q = W_Q^\top \mathbf{x}, \qquad k = W_K^\top \mathbf{y}, \qquad v = W_V^\top \mathbf{y}.

The raw attention score is

qk=xWQWKy.q^\top k = \mathbf{x}^\top W_Q W_K^\top \mathbf{y}.

So each head defines a bilinear form on the original embedding space. Because WQWKW_Q W_K^\top has rank at most dkd_k, each head uses a low-rank interaction relative to the full d×dd \times d ambient space.

This is one of the cleanest examples of linear-algebraic structure in a large model:

  • attention does not compare full vectors directly
  • it compares them after moving them into learned low-dimensional subspaces
  • different heads can be understood as different learned geometric lenses
Attention subspace flow

x ----W_Q^T----> q
                  \
                   \   score = q^T k
                    \
y ----W_K^T----> k
|
----W_V^T----> v

output = weighted sum of v vectors

11.4 The Probability Simplex

The probability simplex in Rn\mathbb{R}^n is

Δn1={pRn:pi0,  i=1npi=1}.\Delta^{n-1} = \left\{ \mathbf{p} \in \mathbb{R}^n : p_i \geq 0,\; \sum_{i=1}^{n} p_i = 1 \right\}.

It is not a vector space, but it is a highly structured convex set:

  • its vertices are the one-hot vectors
  • its center is the uniform distribution
  • it lies in an affine hyperplane defined by ipi=1\sum_i p_i = 1

Softmax maps logits from Rn\mathbb{R}^n into the interior of this simplex. Sampling, calibration, entropy, KL divergence, and decoding strategies all live on this geometric object.

A deeper geometric view uses the Fisher information metric, which turns the simplex into a curved statistical manifold. That perspective becomes important in information geometry and natural-gradient methods.

Probability simplex in 3 classes

          e2
         /\
        /  \
       / p  \
      /      \
     /________\
   e1          e3

vertices = one-hot distributions
center = uniform distribution

11.5 Parameter Space

If a model has pp trainable parameters, then its parameter space is

Θ=Rp.\Theta = \mathbb{R}^p.

For contemporary language models, pp can be enormous. A 7B model has roughly 7×1097 \times 10^9 coordinates, and frontier open models reach hundreds of billions (Dubey et al., 2024).

Key objects in parameter space:

  • parameter vector θ\theta
  • loss function L(θ)L(\theta)
  • gradient L(θ)\nabla L(\theta)
  • Hessian 2L(θ)\nabla^2 L(\theta)

This space is flat as a Euclidean manifold, but the loss defined on it can be highly nonconvex. Optimization therefore studies geometry not of the ambient space alone, but of the scalar field drawn on top of it.

Mode connectivity, low-loss valleys, and flat-versus-sharp minima are all geometric statements about subsets of parameter space.

11.6 Function Spaces and the Neural Tangent Kernel

A neural network with parameters θ\theta defines a function

fθ:XY.f_\theta : \mathcal{X} \to \mathcal{Y}.

As θ\theta varies, the model traces a family of functions inside a function space. Locally, infinitesimal parameter changes move the model through the tangent directions

fθθj.\frac{\partial f_\theta}{\partial \theta_j}.

The neural tangent kernel (NTK) is

K(x,x)=j=1pfθ(x)θjfθ(x)θj=θfθ(x),θfθ(x).K(x, x') = \sum_{j=1}^{p} \frac{\partial f_\theta(x)}{\partial \theta_j} \frac{\partial f_\theta(x')}{\partial \theta_j} = \left\langle \nabla_\theta f_\theta(x), \nabla_\theta f_\theta(x') \right\rangle.

So the NTK is an inner product in parameter-gradient space. Jacot et al. (2018) showed that in the infinite-width limit, gradient descent can be analyzed using this kernel viewpoint, making neural network training resemble kernel regression.

This is a good example of why abstract vector spaces matter. The relevant geometry is no longer primarily in input space or parameter space, but in a function space whose coordinates are themselves derivatives.


12. Direct Sums and Quotient Spaces

12.1 Direct Sum

If W1W_1 and W2W_2 are subspaces of VV, then

V=W1W2V = W_1 \oplus W_2

means:

  1. every vector in VV can be written as w1+w2\mathbf{w}_1 + \mathbf{w}_2
  2. the decomposition is unique

Equivalently:

  • W1+W2=VW_1 + W_2 = V
  • W1W2={0}W_1 \cap W_2 = \{\mathbf{0}\}

Dimensions add:

dim(W1W2)=dim(W1)+dim(W2).\dim(W_1 \oplus W_2) = \dim(W_1) + \dim(W_2).

The most important example in inner-product spaces is

V=WW.V = W \oplus W^\perp.

Direct sums say that a space can be assembled from independent coordinate subsystems.

Direct sum intuition

      w2
      ^
      |
O---->*
  w1   \
        \
         v = w1 + w2

Two independent pieces add to one vector.

12.2 Decomposing R^n

For a matrix AA, one fundamental decomposition is

Rn=row(A)null(A).\mathbb{R}^n = \mathrm{row}(A) \oplus \mathrm{null}(A).

Likewise,

Rm=col(A)null(A).\mathbb{R}^m = \mathrm{col}(A) \oplus \mathrm{null}(A^\top).

For symmetric matrices, eigenspaces corresponding to distinct eigenvalues are orthogonal, allowing spectral decompositions of the form

Rn=Eλ1Eλk.\mathbb{R}^n = E_{\lambda_1} \oplus \cdots \oplus E_{\lambda_k}.

In AI, decompositions of hidden spaces into feature subspaces, head subspaces, or signal-versus-noise components are often informal versions of direct-sum thinking.

12.3 Quotient Spaces

Given a subspace WVW \subseteq V, the quotient space V/WV/W identifies vectors that differ by an element of WW:

v1v2v1v2W.\mathbf{v}_1 \sim \mathbf{v}_2 \quad \Longleftrightarrow \quad \mathbf{v}_1 - \mathbf{v}_2 \in W.

The elements of the quotient are cosets

v+W={v+w:wW}.\mathbf{v} + W = \{\mathbf{v} + \mathbf{w} : \mathbf{w} \in W\}.

Dimension behaves cleanly:

dim(V/W)=dim(V)dim(W).\dim(V/W) = \dim(V) - \dim(W).

Conceptually, quotienting collapses all directions in WW to zero. If a model is invariant to a set of directions, the meaningful representation can often be thought of as living in a quotient space.

This is the right abstraction for "ignore all variation of type X." It appears in invariant learning, symmetry reduction, and representation factorization.

Quotient-space intuition

Before quotient by W:          After collapsing W-directions:

*----*----*                    [o]   [o]   [o]
*----*----*        ---->          each class = one coset
*----*----*

Points that differ only along W become the same object.

12.4 Tensor Product

The tensor product VWV \otimes W is the vector space generated by formal bilinear pairs vwv \otimes w subject to bilinearity rules. For finite-dimensional spaces,

dim(VW)=dim(V)dim(W).\dim(V \otimes W) = \dim(V)\dim(W).

If {ei}\{\mathbf{e}_i\} is a basis for VV and {fj}\{\mathbf{f}_j\} is a basis for WW, then {eifj}\{\mathbf{e}_i \otimes \mathbf{f}_j\} is a basis for VWV \otimes W.

In coordinates, matrices can be viewed as tensor-product objects:

Rm×nRmRn.\mathbb{R}^{m \times n} \cong \mathbb{R}^m \otimes \mathbb{R}^n.

A rank-1 matrix is a simple tensor:

uvuv.\mathbf{u}\mathbf{v}^\top \leftrightarrow \mathbf{u} \otimes \mathbf{v}.

This is relevant for model compression and LoRA. A low-rank update

ΔW=BA\Delta W = BA

is a sum of a small number of rank-1 outer products, so it lives in a low-dimensional tensorially structured subset of matrix space.

Outer product / simple tensor

column u           row v^T            matrix u v^T

[u1]               [v1 v2 v3]         [u1v1 u1v2 u1v3]
[u2]       x                          [u2v1 u2v2 u2v3]

One column times one row creates a rank-1 matrix.

13. Norms, Regularization, and Geometry

13.1 L2 Regularization as a Geometric Constraint

L2 regularization adds a penalty

λθ22\lambda \|\theta\|_2^2

to the loss. Geometrically, this prefers solutions near the origin and can be viewed through the constrained problem

minθL(θ)subject toθ2r.\min_\theta L(\theta) \quad \text{subject to} \quad \|\theta\|_2 \leq r.

The L2 ball is smooth and rotationally symmetric. As a result, L2 regularization shrinks parameters continuously rather than forcing exact zeros.

This is the modern descendant of ridge regression (Hoerl and Kennard, 1970). In neural networks it appears as weight decay.

L2 constraint set in 2D

      ____
    /      \
   |   .    |
    \______/

smooth boundary -> shrink smoothly

13.2 L1 Regularization and Sparsity

L1 regularization uses

λθ1.\lambda \|\theta\|_1.

Its geometry is different. The L1 ball has corners along coordinate axes, so when an objective first touches the constraint boundary, it is disproportionately likely to do so at a sparse point.

That geometric fact explains why L1 promotes sparsity (Tibshirani, 1996). The corresponding proximal operator is soft thresholding:

proxλ1(xi)=sign(xi)max(0,xiλ).\mathrm{prox}_{\lambda \|\cdot\|_1}(x_i) = \mathrm{sign}(x_i)\max(0, |x_i| - \lambda).

Small coordinates are driven exactly to zero.

This matters for:

  • feature selection
  • sparse coding
  • pruning
  • sparse MoE routing and sparse attention variants
L1 constraint set in 2D

        /\
       /  \
       \  /
        \/

corners on coordinate axes -> sparse solutions are favored

13.3 Spectral Regularization

For a matrix-valued parameter WW, several geometry-aware penalties are common.

Frobenius penalty

WF2\|W\|_F^2

which is entrywise L2 regularization.

Spectral norm control

W2=σmax(W)\|W\|_2 = \sigma_{\max}(W)

which bounds the largest one-step amplification of the layer.

Nuclear norm

W\|W\|_*

which promotes low rank.

Spectral normalization rescales a weight matrix by an estimate of its top singular value so that the layer has bounded operator norm (Miyato et al., 2018). This is a geometric way of controlling Lipschitz constants and stabilizing training.

What spectral control means geometrically

unit ball              after W                after spectral normalization

   ()                    (------)                  (----)
                         long axis = sigma_max     longest stretch capped

Spectral norm controls the biggest stretching direction.

13.4 The Geometry of Gradient Descent

The gradient

L(θ)\nabla L(\theta)

is a vector in parameter space pointing in the direction of steepest increase of the loss under the Euclidean metric. Gradient descent updates by

θt+1=θtηL(θt).\theta_{t+1} = \theta_t - \eta \nabla L(\theta_t).

Several geometric facts follow:

  • the gradient is orthogonal to level sets of LL
  • ill-conditioned curvature creates narrow valleys and zig-zagging updates
  • preconditioning changes the metric of parameter space to make descent more isotropic

If the Hessian has eigenvalues λmax\lambda_{\max} and λmin\lambda_{\min} with large ratio

κ=λmaxλmin,\kappa = \frac{\lambda_{\max}}{\lambda_{\min}},

then the local landscape is elongated and naive gradient descent is inefficient.

Adaptive methods and natural gradient can be understood as changes of geometry. Natural gradient replaces the Euclidean metric with the Fisher information metric, aligning steepest descent with the geometry of the model's predictive distribution (Amari, 1998).

This is the right mental model: optimization is not just arithmetic on parameters; it is motion through a geometric space whose metric determines what "steepest" even means.

Gradient descent in a narrow valley

\                /
 \   x ->      /
  \           /
  /   <- x   \
 /           \
/_____________\

Poor conditioning makes updates zig-zag.

14. Common Mistakes

MistakeWhy it is wrongBetter statement
"A set closed under addition is automatically a subspace."It must also contain the zero vector and be closed under scalar multiplication.Check all subspace conditions, not just one.
"Independent vectors are orthogonal."Orthogonality implies independence for nonzero vectors, but independence does not imply orthogonality.Use Gram-Schmidt when you want orthogonality.
"The zero vector is not in a proper subspace."Every subspace must contain the zero vector.If 0W\mathbf{0} \notin W, then WW is not a subspace.
"Cosine similarity tells you Euclidean closeness."High cosine can coexist with large Euclidean distance when norms differ a lot.Cosine measures angle; Euclidean distance also depends on magnitude.
"All vectors in high dimension are similar."Random high-dimensional vectors are typically nearly orthogonal, not highly aligned.Meaningful similarity is rare relative to the random baseline.
"A spanning set has as many vectors as the dimension."Spanning sets can be redundant. Dimension counts basis vectors, not all listed vectors.Reduce to a linearly independent spanning set to find dimension.
"The simplex is a vector space because it contains vectors."It is not closed under arbitrary scaling or addition.The simplex is a convex subset of a vector space.
"Projection leaves every vector unchanged."It leaves only vectors already in the target subspace unchanged.Projection keeps the in-subspace component and removes the orthogonal remainder.
"Two spaces of the same dimension are equal."They are isomorphic, not literally the same set.Same dimension means same linear structure up to coordinate relabeling.
"Null(A)(A) and Null(A)(A^\top) are the same thing."They live in different ambient spaces unless AA is square and special.Right null space and left null space are distinct objects.

15. Exercises

These are designed to force both symbolic fluency and geometric interpretation.

  1. Vector space verification. Determine whether each set is a vector space under the stated operations. If it is, justify all axioms; if not, identify a failing axiom.

    • (a)(a) {(x,y)R2:x0}\{(x,y) \in \mathbb{R}^2 : x \geq 0\} with standard operations
    • (b)(b) {f:RR:f(0)=0}\{f:\mathbb{R}\to\mathbb{R} : f(0)=0\} with pointwise operations
    • (c)(c) {AR2×2:det(A)=1}\{A \in \mathbb{R}^{2 \times 2} : \det(A)=1\} with matrix addition
    • (d)(d) {pR3:p1+p2+p3=1}\{\mathbf{p} \in \mathbb{R}^3 : p_1+p_2+p_3=1\} with componentwise addition
  2. Subspaces and dimension.

    • (a)(a) Show that {(x,y,z)R3:x+2yz=0}\{(x,y,z)\in\mathbb{R}^3 : x+2y-z=0\} is a subspace, find a basis, and compute its dimension.
    • (b)(b) Find the dimension of the intersection of the planes x+y+z=0x+y+z=0 and xy+2z=0x-y+2z=0.
    • (c)(c) Let W=span{(1,1,0),(1,0,1),(0,1,1)}W=\mathrm{span}\{(1,1,0),(1,0,1),(0,1,-1)\}. Find a basis for WW and determine whether W=R3W=\mathbb{R}^3.
  3. Inner products and orthogonality. Let u=(1,2,1)\mathbf{u}=(1,2,-1) and v=(3,0,1)\mathbf{v}=(3,0,1).

    • (a)(a) Compute u,v\langle \mathbf{u}, \mathbf{v} \rangle.
    • (b)(b) Compute u2\|\mathbf{u}\|_2 and v2\|\mathbf{v}\|_2.
    • (c)(c) Find the angle between the vectors.
    • (d)(d) Compute the projection of u\mathbf{u} onto v\mathbf{v}.
    • (e)(e) Verify the Pythagorean decomposition.
    • (f)(f) Apply Gram-Schmidt to produce an orthonormal basis for span{u,v}\mathrm{span}\{\mathbf{u}, \mathbf{v}\}.
  4. Rank-nullity. For

A=(123246112),A = \begin{pmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \\ 1 & 1 & 2 \end{pmatrix},

find:

(a)(a) a basis for null(A)\mathrm{null}(A) (b)(b) a basis for col(A)\mathrm{col}(A) (c)(c) a basis for row(A)\mathrm{row}(A) (d)(d) the rank and nullity, verifying rank-nullity (e)(e) a nonzero vector in null(A)\mathrm{null}(A^\top)

  1. Projection matrices.
    • (a)(a) Compute the orthogonal projector onto the line spanned by (1,2,2)(1,2,2)^\top.
    • (b)(b) Verify P2=PP^2=P and P=PP^\top=P.
    • (c)(c) Compute IPI-P and identify its target subspace.
    • (d)(d) For
A=(100111),A = \begin{pmatrix} 1 & 0 \\ 0 & 1 \\ 1 & 1 \end{pmatrix},

compute PA=A(AA)1AP_A = A(A^\top A)^{-1}A^\top and interpret the result geometrically.

  1. High-dimensional geometry.

    • (a)(a) Suppose x,y\mathbf{x}, \mathbf{y} are independent random unit vectors in R100\mathbb{R}^{100}. What are the expected value and approximate variance of x,y\langle \mathbf{x}, \mathbf{y} \rangle?
    • (b)(b) For 500 points and ε=0.1\varepsilon=0.1, estimate a Johnson-Lindenstrauss target dimension kk up to constants.
    • (c)(c) Show that all distinct standard basis vectors in Rd\mathbb{R}^d are at Euclidean distance 2\sqrt{2} from one another.
  2. Attention geometry. Let WQR512×64W_Q \in \mathbb{R}^{512 \times 64}.

    • (a)(a) What is the maximum possible rank of WQW_Q?
    • (b)(b) What is the dimension of its null space if the rank is maximal?
    • (c)(c) What kinds of input directions are lost under this projection?
    • (d)(d) Why is WQWKW_Q W_K^\top low rank?
  3. Norms and distances.

    • (a)(a) For v=(3,4,0,1)\mathbf{v}=(3,-4,0,1)^\top, compute v1\|\mathbf{v}\|_1, v2\|\mathbf{v}\|_2, and v\|\mathbf{v}\|_\infty.
    • (b)(b) Verify vv2v1\|\mathbf{v}\|_\infty \leq \|\mathbf{v}\|_2 \leq \|\mathbf{v}\|_1.
    • (c)(c) For
A=(2112),A = \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix},

compute AF\|A\|_F and A2\|A\|_2.

  1. Quotient-space thinking. Suppose a representation is unchanged when you add any vector from a subspace WW. Explain why the meaningful information lives in V/WV/W rather than in VV itself.

  2. Regularization geometry. Sketch or describe the L1 and L2 unit balls in R2\mathbb{R}^2, then explain geometrically why L1 tends to produce sparse solutions and L2 typically does not.


16. Why This Matters for AI

AspectWhy vectors and spaces matter
EmbeddingsEvery token, position, and feature is represented as a vector in a learned space.
AttentionAttention is built from inner products, low-rank projections, and weighted sums.
Representation learningFeatures live in subspaces, not just in scalar coordinates.
CompressionLow-rank methods, adapters, and LoRA rely on dimension, span, and rank.
OptimizationGradients are vectors in parameter space, and regularization is geometric constraint design.
Generalization theoryRKHS, NTK, margin bounds, and norm-based complexity all use vector-space language.
Numerical stabilityOrthogonality, conditioning, and norm control determine whether training remains stable.
InterpretabilityLinear probes, concept vectors, activation steering, and superposition are all geometric analyses.
Retrieval and searchSimilarity search depends on metrics, angle, and concentration in high dimensions.
Probabilistic modelingLogits live in vector spaces and probabilities live in simplices embedded in them.

The short version is that vectors and spaces are not one topic among many. They are the common substrate of model architecture, learning dynamics, representation quality, and theoretical analysis.


17. Conceptual Bridge

Scalars are the atoms of computation. Vectors are organized collections of scalars. Vector spaces tell us which collections can be added and scaled consistently. Norms and inner products add geometry. Linear maps move us between spaces. Convexity constrains what combinations are allowed. High-dimensional geometry tells us why intuition breaks and why large models can still work.

That is the bridge to the next chapters:

sets and functions
  -> vectors and spaces
  -> matrices and linear maps
  -> orthogonality, eigenvalues, and SVD
  -> optimization, probability, and information
  -> neural networks and transformers

If this chapter gives you one durable mental model, let it be this: deep learning is geometry performed by linear maps inside structured high-dimensional spaces, with nonlinearities deciding which geometric regions remain active.


References

Core Linear Algebra and Geometry

AI and Representation Geometry

Low Rank, Kernels, and Optimization Geometry

Regularization and Information Geometry


Back to Home | Next: Matrix Operations

Skill Check

Test this lesson

Answer 4 quick questions to lock in the lesson and feed your adaptive practice queue.

--
Score
0/4
Answered
Not attempted
Status
1

Which module does this lesson belong to?

2

Which section is covered in this lesson content?

3

Which term is most central to this lesson?

4

What is the best way to use this lesson for real learning?

Your answers save locally first, then sync when account storage is available.
Practice queue