math-skill 3.0.1 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/README.en-US.md +72 -47
  2. package/README.md +40 -15
  3. package/agents/math-critic.en.md +6 -6
  4. package/agents/math-critic.md +6 -6
  5. package/commands/ask.en.md +6 -1
  6. package/commands/ask.md +6 -1
  7. package/design-patterns/attention/equivariant-attention.en.md +8 -2
  8. package/design-patterns/attention/equivariant-attention.md +7 -1
  9. package/design-patterns/attention/geometry-aware-attention.en.md +2 -2
  10. package/design-patterns/attention/geometry-aware-attention.md +1 -1
  11. package/design-patterns/attention/information-bottleneck-attention.en.md +32 -12
  12. package/design-patterns/attention/information-bottleneck-attention.md +32 -12
  13. package/design-patterns/attention/projection-attention.en.md +3 -3
  14. package/design-patterns/attention/projection-attention.md +2 -2
  15. package/design-patterns/attention/spectral-attention.en.md +19 -5
  16. package/design-patterns/attention/spectral-attention.md +18 -4
  17. package/design-patterns/compression/leverage-score-selection.en.md +13 -13
  18. package/design-patterns/compression/leverage-score-selection.md +13 -13
  19. package/design-patterns/compression/low-rank-kv-cache.en.md +39 -12
  20. package/design-patterns/compression/low-rank-kv-cache.md +38 -12
  21. package/design-patterns/compression/spectral-token-pruning.en.md +16 -14
  22. package/design-patterns/compression/spectral-token-pruning.md +16 -14
  23. package/design-patterns/compression/topology-preserving-compression.en.md +10 -10
  24. package/design-patterns/compression/topology-preserving-compression.md +10 -10
  25. package/design-patterns/loss/constraint-penalty.en.md +8 -4
  26. package/design-patterns/loss/constraint-penalty.md +9 -6
  27. package/design-patterns/loss/contrastive-loss.en.md +37 -11
  28. package/design-patterns/loss/contrastive-loss.md +38 -12
  29. package/design-patterns/loss/information-bottleneck-loss.en.md +5 -5
  30. package/design-patterns/loss/information-bottleneck-loss.md +6 -6
  31. package/design-patterns/loss/orthogonality-loss.en.md +24 -17
  32. package/design-patterns/loss/orthogonality-loss.md +24 -18
  33. package/design-patterns/loss/variational-loss.en.md +4 -4
  34. package/design-patterns/loss/variational-loss.md +5 -5
  35. package/design-patterns/overview.en.md +36 -0
  36. package/design-patterns/overview.md +36 -0
  37. package/design-patterns/representation/equivariant-split.en.md +4 -4
  38. package/design-patterns/representation/equivariant-split.md +4 -5
  39. package/design-patterns/representation/manifold-representation.en.md +12 -12
  40. package/design-patterns/representation/manifold-representation.md +13 -14
  41. package/design-patterns/representation/shared-private-decomposition.en.md +12 -7
  42. package/design-patterns/representation/shared-private-decomposition.md +12 -9
  43. package/design-patterns/representation/subspace-alignment.en.md +12 -12
  44. package/design-patterns/representation/subspace-alignment.md +12 -12
  45. package/design-patterns/routing/graph-routing.en.md +11 -11
  46. package/design-patterns/routing/graph-routing.md +11 -11
  47. package/design-patterns/routing/moe-routing.en.md +12 -12
  48. package/design-patterns/routing/moe-routing.md +12 -14
  49. package/design-patterns/routing/optimal-transport-routing.en.md +5 -5
  50. package/design-patterns/routing/optimal-transport-routing.md +6 -6
  51. package/design-patterns/routing/spectral-clustering-routing.en.md +26 -15
  52. package/design-patterns/routing/spectral-clustering-routing.md +26 -17
  53. package/knowledge-base/differential-geometry/connection.en.md +17 -2
  54. package/knowledge-base/differential-geometry/connection.md +17 -2
  55. package/knowledge-base/differential-geometry/curvature.en.md +14 -1
  56. package/knowledge-base/differential-geometry/curvature.md +14 -1
  57. package/knowledge-base/differential-geometry/geodesic.en.md +16 -2
  58. package/knowledge-base/differential-geometry/geodesic.md +16 -2
  59. package/knowledge-base/differential-geometry/index.en.md +52 -0
  60. package/knowledge-base/differential-geometry/index.md +52 -0
  61. package/knowledge-base/differential-geometry/manifold.en.md +15 -2
  62. package/knowledge-base/differential-geometry/manifold.md +15 -2
  63. package/knowledge-base/differential-geometry/metric-tensor.en.md +16 -2
  64. package/knowledge-base/differential-geometry/metric-tensor.md +16 -2
  65. package/knowledge-base/differential-geometry/tangent-space.en.md +17 -3
  66. package/knowledge-base/differential-geometry/tangent-space.md +17 -3
  67. package/knowledge-base/information-geometry/fisher-metric.en.md +24 -5
  68. package/knowledge-base/information-geometry/fisher-metric.md +24 -5
  69. package/knowledge-base/information-geometry/index.en.md +45 -0
  70. package/knowledge-base/information-geometry/index.md +45 -0
  71. package/knowledge-base/information-geometry/natural-gradient.en.md +17 -3
  72. package/knowledge-base/information-geometry/natural-gradient.md +17 -3
  73. package/knowledge-base/lie-theory/equivariance.en.md +18 -3
  74. package/knowledge-base/lie-theory/equivariance.md +18 -3
  75. package/knowledge-base/lie-theory/group-action.en.md +16 -2
  76. package/knowledge-base/lie-theory/group-action.md +16 -2
  77. package/knowledge-base/lie-theory/index.en.md +52 -0
  78. package/knowledge-base/lie-theory/index.md +52 -0
  79. package/knowledge-base/lie-theory/lie-algebra.en.md +17 -2
  80. package/knowledge-base/lie-theory/lie-algebra.md +17 -2
  81. package/knowledge-base/lie-theory/lie-group.en.md +17 -3
  82. package/knowledge-base/lie-theory/lie-group.md +17 -3
  83. package/knowledge-base/lie-theory/representation.en.md +17 -2
  84. package/knowledge-base/lie-theory/representation.md +17 -2
  85. package/knowledge-base/matrix-analysis/index.en.md +49 -0
  86. package/knowledge-base/matrix-analysis/index.md +49 -0
  87. package/knowledge-base/matrix-analysis/low-rank-approximation.en.md +20 -7
  88. package/knowledge-base/matrix-analysis/low-rank-approximation.md +20 -7
  89. package/knowledge-base/matrix-analysis/matrix-perturbation.en.md +13 -1
  90. package/knowledge-base/matrix-analysis/matrix-perturbation.md +13 -1
  91. package/knowledge-base/matrix-analysis/positive-semidefinite.en.md +20 -6
  92. package/knowledge-base/matrix-analysis/positive-semidefinite.md +20 -6
  93. package/knowledge-base/matrix-analysis/projection.en.md +14 -1
  94. package/knowledge-base/matrix-analysis/projection.md +14 -1
  95. package/knowledge-base/matrix-analysis/spectral-decomposition.en.md +14 -1
  96. package/knowledge-base/matrix-analysis/spectral-decomposition.md +14 -1
  97. package/knowledge-base/optimization/constrained-optimization.en.md +17 -3
  98. package/knowledge-base/optimization/constrained-optimization.md +17 -3
  99. package/knowledge-base/optimization/convex-optimization.en.md +15 -2
  100. package/knowledge-base/optimization/convex-optimization.md +15 -2
  101. package/knowledge-base/optimization/index.en.md +50 -0
  102. package/knowledge-base/optimization/index.md +50 -0
  103. package/knowledge-base/optimization/lagrangian-duality.en.md +18 -4
  104. package/knowledge-base/optimization/lagrangian-duality.md +18 -4
  105. package/knowledge-base/optimization/proximal-method.en.md +15 -1
  106. package/knowledge-base/optimization/proximal-method.md +15 -1
  107. package/knowledge-base/optimization/riemannian-optimization.en.md +18 -4
  108. package/knowledge-base/optimization/riemannian-optimization.md +18 -4
  109. package/knowledge-base/overview.en.md +20 -8
  110. package/knowledge-base/overview.md +20 -8
  111. package/knowledge-base/probability/concentration-inequality.en.md +16 -2
  112. package/knowledge-base/probability/concentration-inequality.md +16 -2
  113. package/knowledge-base/probability/entropy.en.md +19 -3
  114. package/knowledge-base/probability/entropy.md +18 -2
  115. package/knowledge-base/probability/fisher-information.en.md +17 -3
  116. package/knowledge-base/probability/fisher-information.md +17 -3
  117. package/knowledge-base/probability/index.en.md +51 -0
  118. package/knowledge-base/probability/index.md +51 -0
  119. package/knowledge-base/probability/information-bottleneck.en.md +18 -2
  120. package/knowledge-base/probability/information-bottleneck.md +18 -2
  121. package/knowledge-base/probability/kl-divergence.en.md +15 -2
  122. package/knowledge-base/probability/kl-divergence.md +15 -2
  123. package/knowledge-base/topology/euler-characteristic.en.md +15 -2
  124. package/knowledge-base/topology/euler-characteristic.md +15 -2
  125. package/knowledge-base/topology/fundamental-group.en.md +16 -2
  126. package/knowledge-base/topology/fundamental-group.md +16 -2
  127. package/knowledge-base/topology/index.en.md +48 -0
  128. package/knowledge-base/topology/index.md +48 -0
  129. package/knowledge-base/topology/persistent-homology.en.md +17 -2
  130. package/knowledge-base/topology/persistent-homology.md +17 -2
  131. package/lenses/spectral.en.md +1 -1
  132. package/lenses/spectral.md +1 -1
  133. package/lenses/topological.en.md +1 -1
  134. package/lenses/topological.md +1 -1
  135. package/package.json +6 -6
  136. package/references/agentic-workflow.en.md +2 -2
  137. package/references/books/abstract-algebra.en.md +12 -12
  138. package/references/books/abstract-algebra.md +9 -9
  139. package/references/books/algebraic-geometry-rising-sea.en.md +2 -2
  140. package/references/books/differential-geometry.en.md +16 -16
  141. package/references/books/differential-geometry.md +14 -14
  142. package/references/books/matrix-analysis.en.md +3 -3
  143. package/references/books/matrix-analysis.md +24 -24
  144. package/references/books/micro-lie-theory.en.md +1 -1
  145. package/references/books/optimization-ml.en.md +15 -15
  146. package/references/books/optimization-ml.md +14 -14
  147. package/references/books/smooth-manifolds.en.md +3 -3
  148. package/references/books/smooth-manifolds.md +6 -6
  149. package/references/gpu-friendly-math.en.md +21 -8
  150. package/references/gpu-friendly-math.md +19 -4
  151. package/references/skill-index.en.md +106 -0
  152. package/references/skill-index.md +106 -0
  153. package/skills/math-research-activator/SKILL.en.md +76 -118
  154. package/skills/math-research-activator/SKILL.md +69 -109
@@ -5,8 +5,8 @@
5
5
  When a representation $Z$ must achieve an optimal balance between "retaining task-relevant information" and "compressing input redundancy." Typical scenarios: (1) Shared representations should retain only cross-task common information, discarding task-specific noise; (2) Private representations should retain only single-task unique information; (3) Routing features should maximize expert-task matching information. Core objective: **optimal information compression -- nothing more, nothing less, retaining only what is useful**.
6
6
 
7
7
  ## Mathematical Inspiration
8
- - Lenses: lenses/probabilistic.md (information bottleneck principle, mutual information variational), lenses/variational.md (Lagrangian duality)
9
- - Knowledge: knowledge-base/probability/kl-divergence.md (IB theory, rate-distortion function), knowledge-base/probability/entropy.md (mutual information and conditional entropy)
8
+ - Lenses: ../../lenses/probabilistic.en.md (information bottleneck principle, mutual information variational), ../../lenses/variational.en.md (Lagrangian duality)
9
+ - Knowledge: ../../knowledge-base/probability/kl-divergence.en.md (IB theory, rate-distortion function), ../../knowledge-base/probability/entropy.en.md (mutual information and conditional entropy)
10
10
 
11
11
  ## Required Mathematical Knowledge
12
12
  - **Information Bottleneck Objective**: $\min I(X;Z) - \beta \cdot I(Z;Y)$, compressing $X \to Z$ while preserving the predictive power of $Z$ for $Y$
@@ -15,7 +15,7 @@ When a representation $Z$ must achieve an optimal balance between "retaining tas
15
15
  $I(Z;Y) \geq \mathbb{E}_{p(z,y)}[\log q(y|z)] + H(Y)$ (lower bound for prediction term)
16
16
  - **CPC (Contrastive Predictive Coding)**: InfoNCE lower bound on $I(Z_t; Z_{t+k})$
17
17
  - **MINE (Mutual Information Neural Estimation)**:
18
- $I(X;Z) = \sup_\theta \{ \mathbb{E}[\log T_\theta(x,z)] - \log \mathbb{E}[T_\theta(x,z')] \}$
18
+ $I(X;Z) = \sup_\phi \{ \mathbb{E}_{p(x,z)}[T_\phi(x,z)] - \log \mathbb{E}_{p(x)p(z)}[\exp(T_\phi(x,z))] \}$ (Donsker-Varadhan representation, $T_\phi$ is a neural network critic)
19
19
 
20
20
  ## AI Module Form
21
21
  ```
@@ -32,7 +32,7 @@ Method 1 - VIB (Variational Information Bottleneck):
32
32
 
33
33
  Method 2 - Contrastive Mutual Information Estimation (no distributional assumptions):
34
34
  // NWJ estimator instead of KL
35
- I_nwj(x;z) = E[f(x,z)] - exp(E[f(x,z')] - 1) // f is a discriminator network
35
+ I_nwj(x;z) = E_{p(x,z)}[f(x,z)] - e^{-1} * E_{p(x)p(z)}[exp(f(x,z))] // f is a discriminator network, expectations over joint and product of marginals respectively
36
36
  L_IB_contrast = I_nwj(x;z) - beta * InfoNCE(z, y) // both terms differentiable
37
37
 
38
38
  Method 3 - Shared/Private IB Decomposition:
@@ -60,7 +60,7 @@ Method 3 - Shared/Private IB Decomposition:
60
60
  - **Operator Fusion**: Encoder forward + KL computation + discriminator forward can be partially fused
61
61
 
62
62
  ## Paper Phrasing
63
- "Based on information bottleneck theory, we formalize Shared/Private decomposition as $\min I(X;Z_s) + I(X;Z_p) - \beta_1 I(Z_s;Y_c) - \beta_2 I(Z_p;Y_s)$, replacing mutual information terms with variational upper and lower bounds for end-to-end variational, theoretically guaranteeing beta-optimality on the compression-prediction Pareto frontier."
63
+ "Based on information bottleneck theory, we formalize Shared/Private decomposition as $\min I(X;Z_s) + I(X;Z_p) - \beta_1 I(Z_s;Y_c) - \beta_2 I(Z_p;Y_s)$, replacing mutual information terms with variational upper and lower bounds for end-to-end optimization. IB theory provides upper bounds on generalization error, but actual generalization also depends on optimization dynamics, data distribution, and model capacity."
64
64
 
65
65
  ## Risks
66
66
  - Mutual information estimators (MINE/NWJ) have high variance, causing training instability; large batches or moving averages are needed
@@ -8,9 +8,9 @@
8
8
  核心诉求:**信息最优压缩——不多不少,只保留有用的**。
9
9
 
10
10
  ## 数学思想来源
11
- - 透镜:lenses/probabilistic.md(信息瓶颈原理、互信息优化)、lenses/variational.md(拉格朗日对偶)
12
- - 知识:knowledge-base/probability/kl-divergence.md(IB 理论、率失真函数)、
13
- knowledge-base/probability/entropy.md(互信息与条件熵)
11
+ - 透镜:../../lenses/probabilistic.md(信息瓶颈原理、互信息优化)、../../lenses/variational.md(拉格朗日对偶)
12
+ - 知识:../../knowledge-base/probability/kl-divergence.md(IB 理论、率失真函数)、
13
+ ../../knowledge-base/probability/entropy.md(互信息与条件熵)
14
14
 
15
15
  ## 需要的数学知识
16
16
  - **信息瓶颈目标**:min I(X;Z) - β·I(Z;Y),压缩 X→Z 同时保留 Z 对 Y 的预测力
@@ -19,7 +19,7 @@
19
19
  I(Z;Y) ≥ E_{p(z,y)}[log q(y|z)] + H(Y) (用下界估计预测项)
20
20
  - **CPC (Contrastive Predictive Coding)**:I(Z_t; Z_{t+k}) 的 InfoNCE 下界
21
21
  - **MINE (Mutual Information Neural Estimation)**:
22
- I(X;Z) = sup_θ { E[log T_θ(x,z)] - log E[T_θ(x,z')] }
22
+ I(X;Z) = sup_φ { E_{p(x,z)}[T_φ(x,z)] - log E_{p(x)p(z)}[exp(T_φ(x,z))] } (Donsker-Varadhan 表示,T_φ 为神经网络 critic)
23
23
 
24
24
  ## AI 模块形式
25
25
  ```
@@ -36,7 +36,7 @@
36
36
 
37
37
  方法2 - 对比式互信息估计(无需分布假设):
38
38
  // 用 NWJ 估计器替代 KL
39
- I_nwj(x;z) = E[f(x,z)] - exp(E[f(x,z')] - 1) // f 为判别网络
39
+ I_nwj(x;z) = E_{p(x,z)}[f(x,z)] - e^{-1} · E_{p(x)p(z)}[exp(f(x,z))] // f 为判别网络,期望分别取 joint 和 product of marginals
40
40
  L_IB_contrast = I_nwj(x;z) - β · InfoNCE(z, y) // 两项均可微
41
41
 
42
42
  方法3 - Shared/Private IB 分解:
@@ -65,7 +65,7 @@
65
65
 
66
66
  ## 论文表述方式
67
67
  "基于信息瓶颈理论,将 Shared/Private 分解形式化为 min I(X;Z_s)+I(X;Z_p)-β₁I(Z_s;Y_c)-β₂I(Z_p;Y_s),
68
- 通过变分上下界替代互信息项实现端到端优化,理论上保证压缩-预测 Pareto 前沿的 β-最优性。"
68
+ 通过变分上下界替代互信息项实现端到端优化。IB 理论给出泛化误差的上界,但实际泛化还依赖于优化动态、数据分布、模型容量等因素。"
69
69
 
70
70
  ## 风险
71
71
  - 互信息估计(MINE/NWJ)方差大,训练不稳定,需要大 batch 或 moving average
@@ -5,8 +5,8 @@
5
5
  In multi-expert / multi-task settings, representations learned by submodules are highly overlapping and redundant, leading to poor parameter utilization. This loss is used when the $d$-dimensional feature space needs to be partitioned into $K$ non-interfering subspaces -- such as Shared-Private separation, MoE expert differentiation, and multi-task head decorrelation. Core objective: **ensure different modules see different things**.
6
6
 
7
7
  ## Mathematical Inspiration
8
- - Lenses: lenses/projection.md (orthogonal projection and subspace decomposition), lenses/variational.md (regularization and saddle points)
9
- - Knowledge: knowledge-base/matrix-analysis/projection.md (spectral theorem, SVD, Schur decomposition), knowledge-base/probability/kl-divergence.md (redundancy and mutual information)
8
+ - Lenses: ../../lenses/projection.en.md (orthogonal projection and subspace decomposition), ../../lenses/variational.en.md (regularization and saddle points)
9
+ - Knowledge: ../../knowledge-base/matrix-analysis/projection.en.md (spectral theorem, SVD, Schur decomposition), ../../knowledge-base/probability/kl-divergence.en.md (redundancy and mutual information)
10
10
 
11
11
  ## Required Mathematical Knowledge
12
12
  - **Frobenius Inner Product and Orthogonality**: $\langle A, B \rangle_F = \text{tr}(A^T B)$; when $\langle A, B \rangle_F = 0$, $A \perp B$
@@ -18,17 +18,24 @@ In multi-expert / multi-task settings, representations learned by submodules are
18
18
  ```
19
19
  Module: OrthogonalDiversityLoss
20
20
  Input: K feature matrices {W_k in R^{d x r}}_{k=1}^K (weights or features of K submodules)
21
+ // Note: Grassmann distance requires QR decomposition of W_i first to obtain orthonormal bases Q_i
21
22
 
22
23
  Method 1 - Frobenius Orthogonal Regularization:
23
24
  L_orth = Sum_{i<j} ||W_i^T W_j||_F^2
24
25
  // Computation: O(K^2 * d * r^2), K typically <16 so cost is manageable
25
26
 
26
- Method 2 - Grassmann Distance (based on principal angles):
27
- sigma_k = singular values of SVD(W_i^T W_j)
28
- L_grass = Sum_{i<j} Sum_k sigma_k^2 * (1 - sigma_k^2) // penalizes singular values that are neither 0 nor 1
29
-
30
- Method 3 - Efficient Cosine Decorrelation:
31
- G = concat([W_1,...,W_K])^T * concat([W_1,...,W_K]) // single GEMM
27
+ Method 2 - Subspace-overlap log barrier (based on principal angles):
28
+ sigma_k = singular values of SVD(Q_i^T Q_j) (= cos(theta_k), theta_k are principal angles)
29
+ // Must first orthonormalize W_i, W_j: Q_i = qr(W_i).Q, Q_j = qr(W_j).Q
30
+ // Otherwise singular values may exceed 1, making -log(1-sigma^2+eps) undefined
31
+ // Original formula sigma^2*(1-sigma^2) is wrong: penalty is 0 at BOTH sigma=0 (orthogonal) AND sigma=1 (complete overlap)!
32
+ // Fully overlapping subspaces receive zero penalty, defeating the orthogonality objective.
33
+ // Correct formula: log-barrier, 0 at sigma=0 and → +∞ as sigma→1
34
+ L_grass = Sum_{i<j} Sum_k -log(1 - sigma_k^2 + eps) // = -Sum log(sin^2(theta_k)), 0 when orthogonal (theta=pi/2), →∞ when overlapping (theta→0)
35
+
36
+ Method 3 - Efficient Normalized-Gram Decorrelation:
37
+ W_norm = column_normalize(concat([W_1,...,W_K])) // without normalization this also penalizes norms, not only angles
38
+ G = W_norm^T * W_norm // single GEMM
32
39
  L_corr = ||G * (1 - I)||_F^2 // mask out diagonal, penalize off-diagonal elements
33
40
  ```
34
41
 
@@ -38,17 +45,17 @@ Method 3 - Efficient Cosine Decorrelation:
38
45
  - **Block Computation**: When $K$ is large, perform mini-batch sampling over $(i,j)$ pairs, computing only $B$ out of $\binom{K}{2}$ pairs per step
39
46
 
40
47
  ## GPU Feasibility
41
- - **Tensorization**: Core operation is matmul ($W^T W$) -- standard GEMM, perfectly mapped to Tensor Cores
42
- - **GEMM-mappability**: Method 3 requires only 1 GEMM + 1 element-wise mask + Frobenius norm
43
- - **Complexity**: $O(K \cdot d \cdot r)$ storage + $O(d \cdot r^2 \cdot K)$ or $O(K^2 \cdot d \cdot r^2)$ computation; negligible when $K < 16$
44
- - **Memory & KV-Cache**: Intermediate matrices are on the order of $d \times r \cdot K$, adding no KV-Cache overhead
45
- - **Low Precision Stability**: Frobenius norm is a sum of squares, safe under fp16; Grassmann SVD is recommended in fp32
46
- - **Parallelism & Communication**: The $K$ pairs are embarrassingly parallel; can be distributed across GPUs with all-reduce
47
- - **Sparse Structure**: If $W_k$ is itself sparse (e.g., MoE gate), masking further increases sparsity
48
- - **Operator Fusion**: matmul -> mask -> square -> sum can be fused into a single CUDA kernel
48
+ - **D1[v]**: Core operation is matmul ($W^T W$) -- standard GEMM, perfectly mapped to Tensor Cores
49
+ - **D2[v]**: Method 3 requires only 1 GEMM + 1 element-wise mask + Frobenius norm
50
+ - **D3[v]**: $O(K \cdot d \cdot r)$ storage + $O(d \cdot r^2 \cdot K)$ or $O(K^2 \cdot d \cdot r^2)$ computation; negligible when $K < 16$
51
+ - **D4[v]**: Intermediate matrices are on the order of $d \times r \cdot K$, adding no KV-Cache overhead
52
+ - **D5[v]**: Frobenius norm is a sum of squares, safe under fp16; Grassmann SVD is recommended in fp32
53
+ - **D6[v]**: The $K$ pairs are embarrassingly parallel; can be distributed across GPUs with all-reduce
54
+ - **D7[v]**: If $W_k$ is itself sparse (e.g., MoE gate), masking further increases sparsity
55
+ - **D8[v]**: matmul -> mask -> square -> sum can be fused into a single CUDA kernel
49
56
 
50
57
  ## Paper Phrasing
51
- "We introduce an orthogonality regularizer L_orth = Sum_{i<j} ||W_i^T W_j||_F^2 that constrains the feature spaces of submodules to the approximately orthogonal Grassmann sub-manifold, theoretically guaranteeing that redundancy across $K$ subspaces decays as $O(1/\sqrt{d})$."
58
+ "We introduce an orthogonality regularizer L_orth = Sum_{i<j} ||Q_i^T Q_j||_F^2, where Q_i is an orthonormal basis for W_i, to penalize overlap between feature subspaces of different submodules. This can reduce linear redundancy, but any redundancy-decay rate requires random-subspace or data-distribution assumptions and should be reported through principal angles, mutual-information estimates, or downstream ablations."
52
59
 
53
60
  ## Risks
54
61
  - Excessively large lambda causes variational difficulties (orthogonal constraint conflicts with task objective); requires careful tuning or adaptive lambda
@@ -7,9 +7,9 @@
7
7
  MoE 专家差异化、多任务 head 去相关。核心诉求:**让不同模块看到不同的东西**。
8
8
 
9
9
  ## 数学思想来源
10
- - 透镜:lenses/projection.md(正交投影与子空间分解)、lenses/variational.md(正则化与鞍点)
11
- - 知识:knowledge-base/matrix-analysis/projection.md(谱定理、SVD、Schur 分解)、
12
- knowledge-base/probability/kl-divergence.md(冗余度与互信息)
10
+ - 透镜:../../lenses/projection.md(正交投影与子空间分解)、../../lenses/variational.md(正则化与鞍点)
11
+ - 知识:../../knowledge-base/matrix-analysis/projection.md(谱定理、SVD、Schur 分解)、
12
+ ../../knowledge-base/probability/kl-divergence.md(冗余度与互信息)
13
13
 
14
14
  ## 需要的数学知识
15
15
  - **Frobenius 内积与正交性**:⟨A, B⟩_F = tr(A^T B),当 ⟨A, B⟩_F = 0 时 A⊥B
@@ -21,17 +21,24 @@ MoE 专家差异化、多任务 head 去相关。核心诉求:**让不同模
21
21
  ```
22
22
  模块:OrthogonalDiversityLoss
23
23
  输入:K 个特征矩阵 {W_k ∈ R^{d×r}}_{k=1}^K(K 个子模块的权重或特征)
24
+ // 注意:Grassmann 距离需先对 W_i 做 QR 分解取正交基 Q_i
24
25
 
25
26
  方法1 - Frobenius 正交正则:
26
27
  L_orth = Σ_{i<j} ‖W_i^T W_j‖_F²
27
28
  // 计算量:O(K² · d · r²),K 一般 <16 所以可控
28
29
 
29
- 方法2 - Grassmann 距离(基于主角度):
30
- σ_k = SVD(W_i^T W_j) 的奇异值
31
- L_grass = Σ_{i<j} Σ_k σ_k²(1 - σ_k²) // 惩罚非 0 非 1 的奇异值
30
+ 方法2 - 子空间重叠对数障碍(基于主角度):
31
+ σ_k = SVD(Q_i^T Q_j) 的奇异值(= cos(θ_k),θ_k 为主角度)
32
+ // 必须先将 W_i, W_j 正交归一化:Q_i = qr(W_i).Q, Q_j = qr(W_j).Q
33
+ // 否则奇异值可能 > 1,导致 -log(1-σ²+ε) 未定义
34
+ // ⚠ 原公式 σ²(1-σ²) 错误:σ=0(正交)和 σ=1(完全重叠)时惩罚均为 0!
35
+ // 完全重叠的子空间获得零惩罚,违背正交性目标。
36
+ // 正确公式:对数障碍,σ=0 时为 0,σ→1 时 → +∞
37
+ L_grass = Σ_{i<j} Σ_k -log(1 - σ_k² + ε) // = -Σ log(sin²θ_k),正交时 θ=π/2 → 0,重叠时 θ→0 → ∞
32
38
 
33
- 方法3 - 高效 cosine 去相关:
34
- G = concat([W_1,...,W_K])^T · concat([W_1,...,W_K]) // 一次 GEMM
39
+ 方法3 - 高效归一化 Gram 去相关:
40
+ W_norm = column_normalize(concat([W_1,...,W_K])) // 若不归一化,会同时惩罚范数而非只惩罚角度
41
+ G = W_norm^T · W_norm // 一次 GEMM
35
42
  L_corr = ‖G ⊙ (1 - I)‖_F² // mask 掉对角线,惩罚非对角元素
36
43
  ```
37
44
 
@@ -41,18 +48,17 @@ MoE 专家差异化、多任务 head 去相关。核心诉求:**让不同模
41
48
  - **分块计算**:当 K 很大时,对 (i,j) 对做 mini-batch 采样,每步只算 C(K,2) 中的 B 对
42
49
 
43
50
  ## GPU 可行性
44
- - **张量化**:核心操作为 matmul(W^T W)→ 标准 GEMM,完美映射 Tensor Core
45
- - **GEMM 可映射**:方法3 只需 1 次 GEMM + 1 次 element-wise mask + Frobenius 范数
46
- - **复杂度**:O(K·d·r) 存储 + O(d·r²·K) 或 O(K²·d·r²) 计算,K<16 时 negligible
47
- - **显存与 KV-Cache**:中间矩阵 d×r·K 量级,不增加 KV-Cache 负担
48
- - **低精度稳定**:Frobenius 范数为平方和,fp16 下 OK;Grassmann SVD 建议 fp32
49
- - **并行与通信**:K 对之间 embarrassingly parallel,可分 GPU 计算后 all-reduce
50
- - **稀疏结构**:若 W_k 本身稀疏(如 MoE gate),mask 后稀疏度进一步提升
51
- - **算子融合**:matmul → mask → square → sum 可融合为单个 CUDA kernel
51
+ - **D1[v]**:核心操作为 matmul(W^T W)→ 标准 GEMM,完美映射 Tensor Core
52
+ - **D2[v]**:方法3 只需 1 次 GEMM + 1 次 element-wise mask + Frobenius 范数
53
+ - **D3[v]**:O(K·d·r) 存储 + O(d·r²·K) 或 O(K²·d·r²) 计算,K<16 时 negligible
54
+ - **D4[v]**:中间矩阵 d×r·K 量级,不增加 KV-Cache 负担
55
+ - **D5[v]**:Frobenius 范数为平方和,fp16 下 OK;Grassmann SVD 建议 fp32
56
+ - **D6[v]**:K 对之间 embarrassingly parallel,可分 GPU 计算后 all-reduce
57
+ - **D7[v]**:若 W_k 本身稀疏(如 MoE gate),mask 后稀疏度进一步提升
58
+ - **D8[v]**:matmul → mask → square → sum 可融合为单个 CUDA kernel
52
59
 
53
60
  ## 论文表述方式
54
- "我们引入正交性正则项 L_orth = Σ_{i<j}‖W_i^T W_j‖_F²,将各子模块的特征空间约束
55
- 到近似正交的 Grassmann 子流形上,理论上保证 K 个子空间的冗余度以 O(1/√d) 衰减。"
61
+ "我们引入正交性正则项 L_orth = Σ_{i<j}‖Q_i^T Q_j‖_F²(其中 Q_i 为 W_i 的正交基),惩罚不同子模块特征子空间的重叠。该项可降低线性相关冗余,但冗余衰减速率需要随机子空间或数据分布假设支撑,应通过主角度、互信息估计或下游消融实测报告。"
56
62
 
57
63
  ## 风险
58
64
  - λ 过大导致优化困难(正交约束与任务目标冲突),需 careful tuning 或 adaptive λ
@@ -5,8 +5,8 @@
5
5
  When sampling from latent variable distributions is required to generate diverse outputs. Typical scenarios: (1) Expert selection introduces discrete latent variables $z$ that need end-to-end variational; (2) Representation spaces need to model uncertainty; (3) Generative routing requires sampling from posterior distributions $p(z|x)$; (4) Bayesian mixture of experts. Core objective: **model distributions rather than point estimates in latent space, enabling uncertainty awareness and diversity**.
6
6
 
7
7
  ## Mathematical Inspiration
8
- - Lenses: lenses/probabilistic.md (variational inference and ELBO), lenses/probabilistic.md (posterior and prior)
9
- - Knowledge: knowledge-base/probability/entropy.md (KL divergence, variational families), knowledge-base/probability/kl-divergence.md (ELBO derivation)
8
+ - Lenses: ../../lenses/probabilistic.en.md (variational inference and ELBO), ../../lenses/probabilistic.en.md (posterior and prior)
9
+ - Knowledge: ../../knowledge-base/probability/entropy.en.md (KL divergence, variational families), ../../knowledge-base/probability/kl-divergence.en.md (ELBO derivation)
10
10
 
11
11
  ## Required Mathematical Knowledge
12
12
  - **ELBO (Evidence Lower Bound)**: $\log p(x) \geq \mathbb{E}_{q(z|x)}[\log p(x|z)] - \text{KL}(q(z|x) \| p(z))$ -- the first term is reconstruction likelihood, the second regularizes the posterior toward the prior
@@ -31,8 +31,8 @@ Method 2 - Gumbel-Softmax (discrete expert selection):
31
31
  L_gumbel = CE(task_head(z_soft * features), y) // straight-through estimator backprop
32
32
 
33
33
  Method 3 - Variational Information Bottleneck:
34
- L_IB = -I(X; Z) + beta * I(Z; Y) // maximize MI between Z and X, minimize redundancy between Z and Y
35
- ~ E[-log q(x|z)] + beta * KL(q(z|x) || p(z)) // variational approximation
34
+ L_IB = I(X; Z) - beta * I(Z; Y) // minimize information redundancy of Z about X, maximize predictive power of Z about Y
35
+ ~ E[-log q(y|z)] + beta * KL(q(z|x) || p(z)) // variational approximation (first term is prediction loss, second is compression penalty)
36
36
  ```
37
37
 
38
38
  ## Implementable Architectures
@@ -8,9 +8,9 @@
8
8
  核心诉求:**在潜空间中建模分布而非点估计,获得不确定性感知与多样性**。
9
9
 
10
10
  ## 数学思想来源
11
- - 透镜:lenses/probabilistic.md(变分推断与 ELBO)、lenses/probabilistic.md(后验与先验)
12
- - 知识:knowledge-base/probability/entropy.md(KL 散度、变分族)、
13
- knowledge-base/probability/kl-divergence.md(ELBO 推导)
11
+ - 透镜:../../lenses/probabilistic.md(变分推断与 ELBO)、../../lenses/probabilistic.md(后验与先验)
12
+ - 知识:../../knowledge-base/probability/entropy.md(KL 散度、变分族)、
13
+ ../../knowledge-base/probability/kl-divergence.md(ELBO 推导)
14
14
 
15
15
  ## 需要的数学知识
16
16
  - **ELBO(证据下界)**:log p(x) ≥ E_{q(z|x)}[log p(x|z)] - KL(q(z|x) ‖ p(z))
@@ -39,8 +39,8 @@
39
39
  L_gumbel = CE(task_head(z_soft ⊙ features), y) // 直通估计器反向传播
40
40
 
41
41
  方法3 - 信息瓶颈变分:
42
- L_IB = -I(X; Z) + β · I(Z; Y) // 最大化 Z X 的互信息,最小化 Z Y 的冗余
43
- ≈ E[-log q(x|z)] + β · KL(q(z|x) ‖ p(z)) // 变分近似
42
+ L_IB = I(X; Z) - β · I(Z; Y) // 最小化 Z X 的信息冗余,最大化 Z Y 的预测能力
43
+ ≈ E[-log q(y|z)] + β · KL(q(z|x) ‖ p(z)) // 变分近似(第一项为预测损失,第二项为压缩惩罚)
44
44
  ```
45
45
 
46
46
  ## 可实现结构
@@ -0,0 +1,36 @@
1
+ # Design Translation Pattern Library
2
+
3
+ > The design pattern library is not a complete model repository but a collection of "math → AI design" translation prototypes.
4
+ > When existing patterns are insufficient, generate a temporary design candidate from the mathematical source and label it as a temporary design pattern, rather than refusing or force-fitting existing patterns.
5
+ > Rigor convention: claims about complexity, memory, FlashAttention / Tensor Core / KV-Cache, and other engineering properties should be marked [v]/[~]/[x]; unmarked claims are theoretical possibilities requiring engineering validation.
6
+
7
+ ## Translation Paradigms
8
+
9
+ | Mathematical Structure | AI Design Direction |
10
+ |----------------------|-------------------|
11
+ | Projection / Decomposition | subspace split / conflict removal / low-rank attention |
12
+ | Spectral structure | token pruning / stability monitor / spectral filter |
13
+ | Information theory | bottleneck loss / entropy gate / uncertainty routing |
14
+ | Geometry / Metric | manifold representation / metric-aware update |
15
+ | Topology | topology-preserving compression / obstruction loss |
16
+ | Duality | constrained optimization / primal-dual training |
17
+ | Symmetry / Group | equivariant features / weight sharing / orbit aggregation |
18
+ | Variational | energy minimization / variational regularization |
19
+
20
+ ## Relationship to Activation Anchors
21
+
22
+ ```
23
+ Activation anchors provide math tools → Design patterns translate into AI modules
24
+ ```
25
+
26
+ When an activation anchor triggers the Knowledge Gap Protocol to generate a temporary knowledge card, a corresponding temporary design candidate should also be generated here.
27
+
28
+ ## By Component Type
29
+
30
+ | Component | Directory | Count |
31
+ |-----------|-----------|-------|
32
+ | Attention | `attention/` | 5 |
33
+ | Loss Functions | `loss/` | 5 |
34
+ | Routing | `routing/` | 4 |
35
+ | Representation | `representation/` | 4 |
36
+ | Compression | `compression/` | 4 |
@@ -0,0 +1,36 @@
1
+ # 设计翻译原型库 / Design Translation Pattern Library
2
+
3
+ > 设计模式库不是完整模型仓库,而是"数学 → AI 设计"的翻译原型集合。
4
+ > 当现有模式不足时,应根据数学来源生成临时设计草案,并标记为 temporary design pattern,而不是拒绝或强行套用已有模式。
5
+ > 严谨性约定:复杂度、显存、FlashAttention/Tensor Core/KV-Cache 等工程结论需用 [v]/[~]/[x] 标注;未标注结论视为理论可行但需工程验证。
6
+
7
+ ## 翻译范式
8
+
9
+ | 数学结构 | AI 设计方向 |
10
+ |---------|-----------|
11
+ | 投影/分解 | subspace split / conflict removal / low-rank attention |
12
+ | 谱结构 | token pruning / stability monitor / spectral filter |
13
+ | 信息论 | bottleneck loss / entropy gate / uncertainty routing |
14
+ | 几何/度量 | manifold representation / metric-aware update |
15
+ | 拓扑 | topology-preserving compression / obstruction loss |
16
+ | 对偶 | constrained optimization / primal-dual training |
17
+ | 对称/群 | equivariant features / weight sharing / orbit aggregation |
18
+ | 变分 | energy minimization / variational regularization |
19
+
20
+ ## 与知识锚点的关系
21
+
22
+ ```
23
+ 知识锚点提供数学工具 → 设计模式翻译成 AI 模块
24
+ ```
25
+
26
+ 当知识锚点触发 Knowledge Gap Protocol 生成临时知识卡时,此处也应生成对应的临时设计草案。
27
+
28
+ ## 按组件类型
29
+
30
+ | 组件 | 目录 | 模式数 |
31
+ |------|------|--------|
32
+ | 注意力 | `attention/` | 5 |
33
+ | 损失函数 | `loss/` | 5 |
34
+ | 路由 | `routing/` | 4 |
35
+ | 表示 | `representation/` | 4 |
36
+ | 压缩 | `compression/` | 4 |
@@ -10,9 +10,9 @@ Typical scenarios: (1) Token permutation equivariance -- representation should c
10
10
  Core requirement: **encode symmetry priors into network architecture to reduce learning burden and improve generalization**.
11
11
 
12
12
  ## Mathematical Inspiration
13
- - Lenses: lenses/geometric.md (group actions, invariant/equivariant maps), lenses/probabilistic.md (symmetry and information redundancy)
14
- - Knowledge: knowledge-base/matrix-analysis/projection.md (group representation theory, irreducible representations),
15
- knowledge-base/differential-geometry/manifold.md (Lie groups, homogeneous spaces)
13
+ - Lenses: ../../lenses/geometric.en.md (group actions, invariant/equivariant maps), ../../lenses/probabilistic.en.md (symmetry and information redundancy)
14
+ - Knowledge: ../../knowledge-base/matrix-analysis/projection.en.md (group representation theory, irreducible representations),
15
+ ../../knowledge-base/differential-geometry/manifold.en.md (Lie groups, homogeneous spaces)
16
16
 
17
17
  ## Required Mathematical Background
18
18
  - **Group Action and Equivariance**: A map f is equivariant with respect to group G if and only if f(g * x) = g * f(x) for all g in G
@@ -78,7 +78,7 @@ Method 3 - Group convolution / group pooling:
78
78
  - **Operator fusion**: Split -> batched matmul -> concat can be fused; group pooling scatter + reduce can be fused
79
79
 
80
80
  ## Paper-Worthy Formulation
81
- "Leveraging Schur's lemma from group representation theory, we decompose the d-dimensional feature space into a direct sum of irreducible representations of symmetry group G, with each component independently processed by equivariance-constrained linear layers. This achieves a |G| / sum(m_i^2) improvement in parameter efficiency while guaranteeing network equivariance under group actions, reducing generalization error by O(1/sqrt(|G|)) on symmetric data."
81
+ "Leveraging Schur's lemma from group representation theory, we decompose the d-dimensional feature space into a direct sum of irreducible representations of the symmetry group G, with each component processed by equivariance-constrained linear layers. Under the assumed group action this enforces equivariance and reduces learnable degrees of freedom; the exact parameter savings depend on the representation decomposition and channel multiplicities. Generalization gains must be measured on tasks with the corresponding symmetry and should not be stated as an unconditional O(1/sqrt(|G|)) rate."
82
82
 
83
83
  ## Risks
84
84
  - Improper group selection (too large constrains cause underfitting, too small fails to capture symmetries)
@@ -10,9 +10,9 @@
10
10
  核心诉求:**让网络结构编码对称性先验,减少学习负担,提升泛化**。
11
11
 
12
12
  ## 数学思想来源
13
- - 透镜:lenses/geometric.md(群作用、不变/等变映射)、lenses/probabilistic.md(对称性与信息冗余)
14
- - 知识:knowledge-base/matrix-analysis/projection.md(群表示论、不可约表示)、
15
- knowledge-base/differential-geometry/manifold.md(李群、齐性空间)
13
+ - 透镜:../../lenses/geometric.md(群作用、不变/等变映射)、../../lenses/probabilistic.md(对称性与信息冗余)
14
+ - 知识:../../knowledge-base/matrix-analysis/projection.md(群表示论、不可约表示)、
15
+ ../../knowledge-base/differential-geometry/manifold.md(李群、齐性空间)
16
16
 
17
17
  ## 需要的数学知识
18
18
  - **群作用与等变性**:映射 f 对群 G 等变 ⟺ f(g·x) = g·f(x), ∀g∈G
@@ -79,8 +79,7 @@
79
79
 
80
80
  ## 论文表述方式
81
81
  "利用群表示论的 Schur 引理,将 d 维特征空间按对称群 G 的不可约表示分解为直和 ⊕mᵢVᵢ,
82
- 每个分量使用受等变约束的线性层独立处理,参数效率提升 |G|/Σmᵢ² 倍,
83
- 同时保证网络对群作用的等变性,在对称数据上泛化误差降低 O(1/√|G|)。"
82
+ 每个分量使用受等变约束的线性层独立处理,从而在满足群作用假设时严格保持等变性并减少可学习自由度。参数节省量取决于具体表示分解与通道重数;泛化收益需在具有相应对称性的任务上实测,不能无条件写成 O(1/√|G|)。"
84
83
 
85
84
  ## 风险
86
85
  - 群的选择不当(过大约束导致欠拟合,过小无法捕获对称性)
@@ -10,9 +10,9 @@ Use when input data resides in a high-dimensional space but is actually distribu
10
10
  Core requirement: **leverage the low-dimensional manifold structure of data to improve representation efficiency and generalization**.
11
11
 
12
12
  ## Mathematical Inspiration
13
- - Lenses: lenses/geometric.md (Riemannian geometry, geodesics, curvature), lenses/probabilistic.md (intrinsic dimensionality)
14
- - Knowledge: knowledge-base/differential-geometry/manifold.md (manifolds, tangent spaces, exponential maps),
15
- knowledge-base/matrix-analysis/projection.md (SVD, low-rank approximation, PCA)
13
+ - Lenses: ../../lenses/geometric.en.md (Riemannian geometry, geodesics, curvature), ../../lenses/probabilistic.en.md (intrinsic dimensionality)
14
+ - Knowledge: ../../knowledge-base/differential-geometry/manifold.en.md (manifolds, tangent spaces, exponential maps),
15
+ ../../knowledge-base/matrix-analysis/projection.en.md (SVD, low-rank approximation, PCA)
16
16
 
17
17
  ## Required Mathematical Background
18
18
  - **Manifold Hypothesis**: Data x in R^D actually lies on a smooth d-dimensional manifold M with d << D
@@ -66,17 +66,17 @@ Method 3 - Riemannian Optimization (optimize directly on the manifold):
66
66
  - **Adaptive d**: Local dimensionality varies across regions; estimate locally via PCA
67
67
 
68
68
  ## GPU Feasibility
69
- - **Tensorization**: Local linear projections are GEMM (d x D) @ (D x N); graph Laplacian regularization is SpMM
70
- - **GEMM-mappable**: K linear projections in Chart MoE form a batched GEMM (K x d x D) @ (D x N)
71
- - **Complexity**: k-NN construction O(N * D * log N) requires FAISS; manifold regularization O(N^2) requires sampling approximation
72
- - **Memory & KV-Cache**: K chart parameters K * d * D typically < 10 MB; k-NN graph N * k * 4 bytes
73
- - **Low-precision stability**: Distance computations and exp in fp16 require attention to numerical range; Riemannian retract recommended in fp32
74
- - **Parallelism & Communication**: K charts computed independently, perfectly parallel; k-NN search accelerated with FAISS GPU
75
- - **Sparse structure**: k-NN graph is naturally sparse; manifold regularization L is a sparse matrix, enabling SpMM acceleration
76
- - **Operator fusion**: Matmul + bias + activation within a chart can be fused; gating softmax + weighted-sum can be fused
69
+ - **D1[v]**: Local linear projections are GEMM (d x D) @ (D x N); graph Laplacian regularization is SpMM
70
+ - **D2[v]**: K linear projections in Chart MoE form a batched GEMM (K x d x D) @ (D x N)
71
+ - **D3[~]**: k-NN construction O(N * D * log N) requires FAISS; manifold regularization O(N^2) requires sampling approximation
72
+ - **D4[v]**: K chart parameters K * d * D typically < 10 MB; k-NN graph N * k * 4 bytes
73
+ - **D5[~]**: Distance computations and exp in fp16 require attention to numerical range; Riemannian retract recommended in fp32
74
+ - **D6[v]**: K charts computed independently, perfectly parallel; k-NN search accelerated with FAISS GPU
75
+ - **D7[v]**: k-NN graph is naturally sparse; manifold regularization L is a sparse matrix, enabling SpMM acceleration
76
+ - **D8[v]**: Matmul + bias + activation within a chart can be fused; gating softmax + weighted-sum can be fused
77
77
 
78
78
  ## Paper-Worthy Formulation
79
- "Based on the manifold hypothesis, we constrain D-dimensional token representations to a d*-dimensional (intrinsic dimension estimate) submanifold, achieving piecewise-linear approximation via K local coordinate charts (Chart MoE) and preserving global geodesic structure through graph Laplacian manifold regularization, with theoretical guarantees that embedding error converges at rate O(N^{-2/d*})."
79
+ "Based on the manifold hypothesis, we model D-dimensional token representations as a low-intrinsic-dimensional structure, approximate it with K local coordinate charts (Chart MoE), and use graph-Laplacian regularization to encourage local-neighborhood consistency. Embedding-error or geodesic-preservation bounds require assumptions on sampling density, manifold smoothness, graph construction, and estimator choice; in practice report neighborhood preservation, reconstruction error, and downstream metrics."
80
80
 
81
81
  ## Risks
82
82
  - Inaccurate intrinsic dimension d* estimation leads to over-compression or dimension waste
@@ -10,9 +10,9 @@
10
10
  核心诉求:**利用数据的低维流形结构,提高表示效率和泛化能力**。
11
11
 
12
12
  ## 数学思想来源
13
- - 透镜:lenses/geometric.md(黎曼几何、测地线、曲率)、lenses/probabilistic.md(内在维度)
14
- - 知识:knowledge-base/differential-geometry/manifold.md(流形、切空间、指数映射)、
15
- knowledge-base/matrix-analysis/projection.md(SVD、低秩近似、PCA)
13
+ - 透镜:../../lenses/geometric.md(黎曼几何、测地线、曲率)、../../lenses/probabilistic.md(内在维度)
14
+ - 知识:../../knowledge-base/differential-geometry/manifold.md(流形、切空间、指数映射)、
15
+ ../../knowledge-base/matrix-analysis/projection.md(SVD、低秩近似、PCA)
16
16
 
17
17
  ## 需要的数学知识
18
18
  - **流形假设**:数据 x ∈ R^D 实际分布在 d << D 维的光滑流形 M 上
@@ -66,19 +66,18 @@
66
66
  - **自适应 d**:不同区域的局部维度不同,用 PCA 局部估计
67
67
 
68
68
  ## GPU 可行性
69
- - **张量化**:局部线性投影为 GEMM (d×D)@(D×N);图拉普拉斯正则为 SpMM
70
- - **GEMM 可映射**:Chart MoE 的 K 个线性投影为 batched GEMM (K×d×D)@(D×N)
71
- - **复杂度**:k-NN 构建 O(N·D·log N) 需 FAISS;流形正则 O(N²) 需采样近似
72
- - **显存与 KV-Cache**:K 个 chart 参数 K·d·D 通常 <10MB;k-NN 图 N·k·4 bytes
73
- - **低精度稳定**:距离计算和 exp 在 fp16 下需注意数值范围;黎曼 retract 建议 fp32
74
- - **并行与通信**:K 个 chart 独立计算,完美并行;k-NN 搜索用 FAISS GPU 加速
75
- - **稀疏结构**:k-NN 图天然稀疏,流形正则 L 为稀疏矩阵,SpMM 加速
76
- - **算子融合**:chart 内的 matmul+bias+activation 可融合;门控 softmax+weighted-sum 可融合
69
+ - **D1[v]**:局部线性投影为 GEMM (d×D)@(D×N);图拉普拉斯正则为 SpMM
70
+ - **D2[v]**:Chart MoE 的 K 个线性投影为 batched GEMM (K×d×D)@(D×N)
71
+ - **D3[~]**:k-NN 构建 O(N·D·log N) 需 FAISS;流形正则 O(N²) 需采样近似
72
+ - **D4[v]**:K 个 chart 参数 K·d·D 通常 <10MB;k-NN 图 N·k·4 bytes
73
+ - **D5[~]**:距离计算和 exp 在 fp16 下需注意数值范围;黎曼 retract 建议 fp32
74
+ - **D6[v]**:K 个 chart 独立计算,完美并行;k-NN 搜索用 FAISS GPU 加速
75
+ - **D7[v]**:k-NN 图天然稀疏,流形正则 L 为稀疏矩阵,SpMM 加速
76
+ - **D8[v]**:chart 内的 matmul+bias+activation 可融合;门控 softmax+weighted-sum 可融合
77
77
 
78
78
  ## 论文表述方式
79
- "基于流形假设将 D 维 token 表示约束到 d*(内在维度估计)维子流形上,
80
- 通过 K 个局部坐标卡(Chart MoE)实现分段线性近似,配合图拉普拉斯流形正则
81
- 保持全局测地线结构,理论上保证嵌入误差以 O(N^{-2/d*}) 收敛。"
79
+ "基于流形假设将 D 维 token 表示建模为低内在维度结构,
80
+ 通过 K 个局部坐标卡(Chart MoE)实现分段近似,并用图拉普拉斯正则鼓励局部邻域一致性。嵌入误差或测地线保持只在采样密度、流形光滑性、图构造和估计器假设满足时才有理论界,实际应报告邻域保持、重构误差和下游指标。"
82
81
 
83
82
  ## 风险
84
83
  - 内在维度 d* 估计不准确导致过度压缩或维度浪费
@@ -9,16 +9,16 @@ Typical scenarios: (1) Multi-task MoE -- Shared experts handle linguistic common
9
9
  Core requirement: **explicitly separate commonality from individuality to prevent negative transfer and catastrophic forgetting**.
10
10
 
11
11
  ## Mathematical Inspiration
12
- - Lenses: lenses/projection.md (subspace decomposition, direct sum decomposition), lenses/probabilistic.md (information decomposition)
13
- - Knowledge: knowledge-base/matrix-analysis/projection.md (direct sum decomposition V = U + W, projection operators),
14
- knowledge-base/probability/kl-divergence.md (information decomposition: shared/synergy/unique)
12
+ - Lenses: ../../lenses/projection.en.md (subspace decomposition, direct sum decomposition), ../../lenses/probabilistic.en.md (information decomposition)
13
+ - Knowledge: ../../knowledge-base/matrix-analysis/projection.en.md (direct sum decomposition V = U + W, projection operators),
14
+ ../../knowledge-base/probability/kl-divergence.en.md (information decomposition: shared/synergy/unique)
15
15
 
16
16
  ## Required Mathematical Background
17
17
  - **Direct Sum Decomposition**: R^d = S + P, where S intersect P = {0}, and every x = x_S + x_P is unique
18
18
  Projection matrices P_S + P_P = I, P_S * P_P = 0
19
19
  - **Information Decomposition (Williams & Beer PID)**:
20
20
  I(X; Y_1, Y_2) = Shared + Unique_1 + Unique_2 + Synergy
21
- Shared = the redundant information component min(I(X; Y_1), I(X; Y_2))
21
+ Shared is the redundant-information term; min(I(X;Y_1), I(X;Y_2)) is only an early/simplified proxy, not the general Williams-Beer redundancy definition
22
22
  - **Low-Rank + Sparse Decomposition (RPCA)**: M = L + S, where L is low-rank (common) + S is sparse (specific)
23
23
  Solved via nuclear norm + L1 norm convex relaxation
24
24
  - **CCA (Canonical Correlation Analysis)**: max corr(W_1^T X, W_2^T Y), extracting shared variation between two sets of variables
@@ -42,12 +42,17 @@ Method 2 - Gated Decomposition (dynamic weighting):
42
42
  z = gate * z_shared + (1 - gate) * z_private
43
43
  // Gating allows per-dimension selection of shared/private contribution ratios
44
44
 
45
- Method 3 - Adversarial Decomposition (information-theoretic guarantee):
45
+ Method 3 - Adversarial Decomposition (information-theoretic proxy):
46
46
  z_shared = E_shared(X)
47
47
  z_private = E_private[t](X)
48
48
  // Shared should be indistinguishable across tasks (adversarial gradient):
49
+ // ⚠ Sign correctness is critical! Original formula L_adv = -CE with flip_gradient creates a double sign reversal:
50
+ // Discriminator minimizes -CE → gets worse at prediction; Encoder (sees +CE after reversal) → helps discriminator → shared becomes MORE task-specific!
51
+ // Correct approach: L_adv = +CE, combined with flip_gradient:
52
+ // Discriminator minimizes +CE → learns to predict task from shared
53
+ // Encoder (gradient reversed) sees -CE → maximizes discriminator loss → shared becomes task-independent
49
54
  task_pred = classifier(z_shared.flip_gradient())
50
- L_adv = -CE(task_pred, t) // Shared contains no task information
55
+ L_adv = CE(task_pred, t) // Discriminator: minimize CE to predict task; Encoder: sees -CE after reversal, maximizes CE, making shared task-independent
51
56
  // Private should be discriminative across tasks:
52
57
  L_private = CE(classifier(z_private), t)
53
58
  L = L_task + lambda_adv * L_adv + lambda_priv * L_private
@@ -75,7 +80,7 @@ Dimension Allocation Principle:
75
80
  - **Operator fusion**: Additive fusion is trivial; gated fusion sigmoid -> multiply -> add can be fused
76
81
 
77
82
  ## Paper-Worthy Formulation
78
- "We decompose the multi-task representation space R^d into a direct sum S + P. The Shared subspace ensures task-invariance through adversarial training (H(T|Z_s) -> log T), while the Private subspace guarantees information complementarity with Shared via orthogonal regularization. Theoretical analysis shows that negative transfer decays as O(||P_S * P_P||_F) with increasing orthogonality."
83
+ "We decompose the multi-task representation space R^d into a shared subspace S and task-private subspaces P: the shared branch reduces task identifiability through adversarial training, while the private branches use orthogonality / decorrelation regularization to reduce linear overlap with S. Information complementarity and reduced negative transfer must be validated with task-transfer matrices, mutual-information / PID proxies, and ablations; they are not automatically guaranteed by orthogonality alone."
79
84
 
80
85
  ## Risks
81
86
  - Min-max variational in adversarial training is unstable; the gradient reversal scale and lambda_adv require careful tuning
@@ -9,16 +9,16 @@
9
9
  核心诉求:**显式分离共性与个性,避免负迁移和灾难性遗忘**。
10
10
 
11
11
  ## 数学思想来源
12
- - 透镜:lenses/projection.md(子空间分解、直和分解)、lenses/probabilistic.md(信息分解)
13
- - 知识:knowledge-base/matrix-analysis/projection.md(直和分解 V = U ⊕ W、投影算子)、
14
- knowledge-base/probability/kl-divergence.md(信息分解:shared/synergy/unique)
12
+ - 透镜:../../lenses/projection.md(子空间分解、直和分解)、../../lenses/probabilistic.md(信息分解)
13
+ - 知识:../../knowledge-base/matrix-analysis/projection.md(直和分解 V = U ⊕ W、投影算子)、
14
+ ../../knowledge-base/probability/kl-divergence.md(信息分解:shared/synergy/unique)
15
15
 
16
16
  ## 需要的数学知识
17
17
  - **直和分解**:R^d = S ⊕ P,其中 S ∩ P = {0},每个 x = x_S + x_P 唯一
18
18
  投影矩阵 P_S + P_P = I,P_S · P_P = 0
19
19
  - **信息分解 (Williams & Beer PID)**:
20
20
  I(X;Y₁,Y₂) = Shared + Unique₁ + Unique₂ + Synergy
21
- Shared = min(I(X;Y₁), I(X;Y₂)) 的冗余信息部分
21
+ Shared 为冗余信息项;min(I(X;Y₁), I(X;Y₂)) 只是早期/简化代理,不是 Williams-Beer 冗余的一般定义
22
22
  - **低秩+稀疏分解 (RPCA)**:M = L + S,L 低秩(共性)+ S 稀疏(特异)
23
23
  通过核范数 + L1 范数凸松弛求解
24
24
  - **CCA (典型相关分析)**:max corr(W₁^T X, W₂^T Y),提取两组变量的共享变异
@@ -42,12 +42,17 @@
42
42
  z = gate ⊙ z_shared + (1 - gate) ⊙ z_private
43
43
  // 门控允许逐维度选择 shared/private 的贡献比例
44
44
 
45
- 方法3 - 对抗分解(信息论保证):
45
+ 方法3 - 对抗分解(信息论代理):
46
46
  z_shared = E_shared(X)
47
47
  z_private = E_private[t](X)
48
48
  // Shared 应无法区分任务(对抗梯度):
49
+ // ⚠ 符号正确性至关重要!原公式 L_adv = -CE 与 flip_gradient 形成双重符号反转:
50
+ // 判别器最小化 -CE → 变差;编码器(梯度反转后看到 +CE)→ 帮助判别器 → shared 变得更任务相关!
51
+ // 正确做法:L_adv = +CE,配合 flip_gradient:
52
+ // 判别器最小化 +CE → 学会从 shared 预测任务
53
+ // 编码器(梯度反转)看到 -CE → 最大化判别器损失 → shared 不含任务信息
49
54
  task_pred = classifier(z_shared.flip_gradient())
50
- L_adv = -CE(task_pred, t) // Shared 不含任务信息
55
+ L_adv = CE(task_pred, t) // 判别器:最小化 CE 预测任务;编码器:梯度反转后最大化 CE,使 shared 任务无关
51
56
  // Private 应能区分任务:
52
57
  L_private = CE(classifier(z_private), t)
53
58
  L = L_task + λ_adv·L_adv + λ_priv·L_private
@@ -75,9 +80,7 @@
75
80
  - **算子融合**:加法融合 trivial;门控融合的 sigmoid→multiply→add 可融合
76
81
 
77
82
  ## 论文表述方式
78
- "将多任务表示空间 R^d 分解为直和 S P,Shared 子空间通过对抗训练确保任务无关性
79
- (H(T|Z_s)→log T),Private 子空间通过正交正则保证与 Shared 的信息互补,
80
- 理论分析表明负迁移随正交性以 O(‖P_S·P_P‖_F) 衰减。"
83
+ "将多任务表示空间 R^d 分解为共享子空间 S 与任务私有子空间 P:共享分支通过对抗训练降低任务可识别性,私有分支通过正交/去相关正则减少与共享分支的线性重叠。信息互补与负迁移降低需通过任务间迁移矩阵、互信息/PID 代理和消融实验验证,不能仅由正交性自动保证。"
81
84
 
82
85
  ## 风险
83
86
  - 对抗训练的 min-max 优化不稳定,梯度反转的 scale 和 λ_adv 需精心调节