Linear Algebra
Linear algebra는 vector, matrix, embedding, projection, learned representation을 다루는 언어입니다.
이 식은 linear layer, 많은 classifier, 더 큰 architecture 안의 local transformation 뒤에 있는 기본 형태입니다.
Route Map
| Question | Start | Use for |
|---|---|---|
| 기본 vector/matrix object는 무엇인가? | Linear algebra, Linear layer | affine transform, projection, classifier, feature mixing |
| similarity를 어떻게 측정하는가? | Vector norm and similarity, Embedding | retrieval, clustering, representation diagnostics |
| 어떤 방향이 variance나 dynamics를 설명하는가? | Eigenvalue and eigenvector, SVD | PCA, low-rank structure, spectral view |
| feature들이 함께 어떻게 변하는가? | Covariance and correlation | normalization, redundancy, representation analysis |
Shape Discipline
AI에서 쓰는 linear algebra는 대부분 tensor linear algebra입니다. 같은 operation도 어떤 axis를 섞는지에 따라 의미가 달라집니다.
흔한 shape는 아래와 같습니다.
여기서 는 batch size, 는 sequence length, 은 node, atom, residue 수, 는 feature dimension입니다.
핵심 질문은 어떤 axis가 섞이는가입니다.
- Feature mixing: linear layer와 MLP는 dimension을 섞습니다.
- Token mixing: attention은 attention matrix를 통해 position을 섞습니다.
- Node mixing: graph model은 edge나 adjacency를 통해 neighborhood를 섞습니다.
- Coordinate transform: rotation은 3D coordinate axis에 작용합니다.
Common Operations
| Operation | Formula | AI use |
|---|---|---|
| Matrix-vector product | linear layer, classifier, projection | |
| Matrix-matrix product | batched feature mixing | |
| Dot product | similarity, attention score | |
| Norm | distance, normalization, regularization | |
| Outer product | covariance, attention-style pair matrix | |
| Trace | matrix identities, covariance, loss simplification |
Projection
Projection은 object를 유용한 subspace로 보냅니다. Linear projection은 아래와 같습니다.
여기서 는 representation basis 또는 dimension을 바꿉니다. AI에서 projection은 아래 형태로 자주 등장합니다.
- embedding projection
- query, key, and value projection in Attention
- PCA projection for analysis
- low-dimensional bottlenecks
- task heads and linear probes
Basis matrix 가 있는 subspace로의 orthogonal projection은 아래처럼 쓸 수 있습니다.
의 column이 orthonormal일 때 성립합니다.
Rank and Low-Rank Structure
Matrix rank는 해당 matrix가 표현할 수 있는 independent direction 수를 측정합니다.
Low-rank structure는 아래에서 등장합니다.
- PCA and SVD diagnostics
- embedding compression
- low-rank adapters such as LoRA-style updates
- representation collapse checks
- protein or molecule similarity matrices with redundant structure
Low-rank factorization은 큰 matrix를 두 개의 작은 matrix로 대체합니다.
이 방식은 parameter를 줄이지만, 표현 가능한 transformation도 제한합니다.
Attention as Linear Algebra
Self-attention은 대부분 matrix multiplication과 softmax로 볼 수 있습니다.
여기서 는 element 사이의 similarity matrix입니다. 단순한 수식 세부 사항이 아니라 어떤 token, residue, atom, retrieved chunk가 정보를 교환할 수 있는지를 정의합니다.
Structure-Based Coordinate Matrices
Structure-based modeling은 coordinate를 보통 아래처럼 표현합니다.
A rigid transform is:
여기서 는 rotation matrix, 는 translation vector입니다.
이 관점은 linear algebra를 Geometry and symmetry, Equivariance, structure evaluation과 연결합니다.
AI Connections
- Embedding similarity는 dot product, cosine similarity, vector norm을 사용합니다.
- Attention score는 softmax 전에 matrix product를 사용합니다.
- PCA, low-rank structure, representation diagnostic은 eigenvector와 SVD를 사용합니다.
- Linear probe는 representation이 task-relevant information을 이미 담고 있는지 test합니다.
- Coordinate model은 position, rotation, rigid transform, distance geometry에 matrix를 사용합니다.
- GPU bottleneck은 큰 matrix multiplication과 memory layout에서 자주 생깁니다.
Checks
- vector와 matrix의 shape가 무엇인가?
- transformation이 feature, token, node, channel 중 무엇을 섞는가?
- projection이 dimension reduction, basis change, Q/K/V feature 생성 중 무엇을 하는가?
- similarity가 normalized되어 있는가, scale-sensitive한가?
- low-rank approximation이 model assumption인가, analysis tool인가?
- coordinate transform이 distance와 angle을 보존하는가?
- matrix multiplication이 compute-bound, memory-bound, communication-bound 중 무엇인가?