内在次元仮説と低ランク行列分解の数理
Agent支援エンジニアリングチェック
前提条件
第48日線形層および行列積の基礎知識。
学習目標
内在次元仮説を理解し、パラメータ更新を Delta W = (alpha/r) * B @ A として表現する(ただし r << min(d, k))。
手順
1. Aghajanyan et al. (2020) の論文を精読します: 過剰パラメータ化された大規模言語モデルは、下流タスクへの適応時に驚くほど低い内在次元を持ちます。
2. 標準的な全量微調では W = W0 + Delta W とし、Delta W は R^{d x k} に属します(フルランク、d*k 個のパラメータを必要とします)。
3. LoRA(Hu et al. 2021)では、Delta W = B @ A と因数分解します。ここで B は R^{d x r}、A は R^{r x k} に属し、ランク r は通常 4、8、16 です。
4. d=4096, k=4096, r=8 の場合、全量微調では 16,777,216 個のパラメータが必要ですが、LoRA では 8*(4096+4096) = 65,536 個のパラメータのみで済むことに注意してください。
演習と予測記録
入力次元1024、出力次元2048の線形層において、全結合重みとランクr=8のLoRAパラメータ数を計算し、パラメータ削減率を求めてください。
元パラメータ = 1024 * 2048。LoRAパラメータ = 8 * (1024 + 2048)。
全量パラメータ数 = 1024 * 2048 = 2,097,152。
LoRA パラメータ数 = 8 * (1024 + 2048) = 8 * 3072 = 24,576。
パラメータ削減率 = (1 - 24,576 / 2,097,152) = 98.83% の削減。
低ランク分解の数式とパラメータ削減率を厳密に導出できる。
公式ソースリソースと権利証跡
LoRA: Low-Rank Adaptation of Large Language Models
該当セクション・タイムスタンプ: Section 4.1 Low-Rank-Parametrized Update Matrices; Section 7.2 What Is the Optimal Rank r for LoRA?
検証バージョンと日付: ICLR 2022 / arXiv:2106.09685v2 (Verified: 2026-10-30)
Primary literature introducing Low-Rank Adaptation, establishing parameter decomposition W = W0 + (alpha/r)*BA, initialization strategies, and zero inference latency merging.
Matrix factorization, rank, linear layers, and transformer attention.
Complete matrix derivations, tensor dimensions, and pure PyTorch LoRALinear modules are implemented directly in lesson code.
比較対象候補リソースと選定評価 (2)
Introduces bottleneck adapter layers in series, which introduces unavoidable inference latency overhead; LoRA's parallel formulation merges with zero latency.
Prepends virtual prompt tokens; reduces available context length, unlike LoRA which preserves full sequence capacity.
Intrinsic Dimensionality Explains the Effectiveness of Language Model Fine-Tuning
該当セクション・タイムスタンプ: Section 3 Intrinsic Dimensionality of Finetuning
検証バージョンと日付: ACL 2021 / arXiv:2012.13255v1 (Verified: 2026-10-30)
Key theoretical foundation demonstrating that overparameterized pre-trained language models reside on a low-dimensional manifold, proving why low rank r (e.g. 4 to 16) is sufficient for task adaptation.
Linear algebra, matrix subspace projection, and pretraining representations.
The intrinsic dimensionality concept, subspace projections, and parameter reduction trade-offs are fully explained in lesson text.
比較対象候補リソースと選定評価 (2)
General neural network optimization landscapes; Aghajanyan focuses explicitly on foundation language models.
Measures how low-rank LoRA trades target-domain learning for less forgetting; Aghajanyan provides the direct theoretical motivation for LoRA's low-rank assumption.