返回 ppt-master
design_spec.md
根目录 / examples / ppt169_lora_hu_2021 / design_spec.md
1 # LoRA: Low-Rank Adaptation of Large Language Models - Design Spec
2
3 > 论文解读演示 · 源文档:Hu et al., 2021, Microsoft (arXiv:2106.09685v2)。设计叙事见本文;机器可读执行契约见 `spec_lock.md`(冲突以 spec_lock 为准)。
4
5 ## I. Project Information
6
7 | Item | Value |
8 | ---- | ----- |
9 | **Project Name** | lora_hu_2021 |
10 | **Canvas Format** | PPT 16:9 (1280×720) |
11 | **Page Count** | 15 |
12 | **Design Style** | B) 通用咨询(数据清晰优先)+ 学术技术极简 |
13 | **Target Audience** | 机器学习研究者 / 工程师;论文分享会、组会、技术答辩 |
14 | **Use Case** | 英文论文的中文讲解汇报(术语保留英文) |
15 | **Created Date** | 2026-05-23 |
16
17 ---
18
19 ## II. Canvas Specification
20
21 | Property | Value |
22 | -------- | ----- |
23 | **Format** | PPT 16:9 |
24 | **Dimensions** | 1280×720 |
25 | **viewBox** | `0 0 1280 720` |
26 | **Margins** | 左右 64px,上下 56px |
27 | **Content Area** | 1152×608(安全区) |
28
29 ---
30
31 ## III. Visual Theme
32
33 ### Theme Style
34
35 - **Style**: 学术技术极简 — 蓝图式结构、克制留白、数据与公式说话
36 - **Theme**: Light theme(白底)
37 - **Tone**: 严谨、可信、工程化、analytical
38
39 ### Color Scheme
40
41 | Role | HEX | Purpose |
42 | ---- | --- | ------- |
43 | **Background** | `#FFFFFF` | 页面底色 |
44 | **Secondary bg** | `#F4F7FA` | 卡片 / 区块背景 |
45 | **Primary** | `#1B3A5C` | 深学术蓝 — 标题、结构线、图表主轴、图标 |
46 | **Accent** | `#E8743B` | 暖橙 — 关键数字(10000×、零延迟)、高亮、LoRA 分支 |
47 | **Secondary accent** | `#3E7CB1` | 中蓝 — 次级数据系列、辅助结构 |
48 | **Body text** | `#1D2733` | 主体文字 |
49 | **Secondary text** | `#5B6776` | 注释、副标题 |
50 | **Tertiary text** | `#8A94A1` | 脚注、页码 |
51 | **Border/divider** | `#D8DEE6` | 卡片边、分割线 |
52 | **Success** | `#2E7D32` | 优于基线指示(LoRA 胜出) |
53 | **Warning** | `#C62828` | 代价 / 劣势指示(全量微调开销、延迟增加) |
54
55 **Color rules**: 60-30-10(白底 60% / 深蓝 30% / 暖橙 ≤10%);正文对比度 ≥ 4.5:1;每页 ≤ 4 色。
56
57 ### AI Image Strategy
58
59 - **Image Rendering**: blueprint
60 - **Image Palette**: cool-corporate
61
62 > blueprint × cool-corporate 兼容矩阵为 ✓✓。全 deck AI 图共享此渲染与色彩;`text_policy: embedded`,图内可带文字(术语英文、说明可中文),生成后校验输出。HEX 为真值,palette 仅规定 60-30-10 用法。
63
64 ### Gradient Scheme
65
66 ```xml
67 <linearGradient id="titleGradient" x1="0%" y1="0%" x2="100%" y2="0%">
68 <stop offset="0%" stop-color="#1B3A5C"/>
69 <stop offset="100%" stop-color="#3E7CB1"/>
70 </linearGradient>
71 <radialGradient id="bgDecor" cx="85%" cy="15%" r="55%">
72 <stop offset="0%" stop-color="#1B3A5C" stop-opacity="0.06"/>
73 <stop offset="100%" stop-color="#1B3A5C" stop-opacity="0"/>
74 </radialGradient>
75 ```
76
77 ---
78
79 ## IV. Typography System
80
81 ### Font Plan
82
83 **Typography direction**: 统一无衬线(技术论文 slides 惯例),代码 / 维度符号用等宽。
84
85 | Role | Chinese | English | Fallback tail |
86 | ---- | ------- | ------- | ------------- |
87 | **Title** | `"Microsoft YaHei"` | `Arial` | `sans-serif` |
88 | **Body** | `"Microsoft YaHei"` | `Arial` | `sans-serif` |
89 | **Emphasis** | `"Microsoft YaHei"` | `Arial` | `sans-serif`(weight 对比,非换字体) |
90 | **Code** | — | `Consolas, "Courier New"` | `monospace` |
91
92 **Per-role font stacks**:
93
94 - Title: `"Microsoft YaHei", Arial, sans-serif`
95 - Body: `"Microsoft YaHei", Arial, sans-serif`
96 - Emphasis: same as Body(靠 font-weight 700/900 制造对比)
97 - Code: `Consolas, "Courier New", monospace`
98
99 ### Font Size Hierarchy
100
101 **Baseline**: Body = 18px(dense — 数据表 + 公式 + 多点内容)。
102
103 | Purpose | Ratio | px | Weight |
104 | ------- | ----- | -- | ------ |
105 | Cover title | 3.3x | 60 | Heavy |
106 | Hero number(10000× 等) | 3.1x | 56 | Heavy |
107 | Page title | 1.8x | 32 | Bold |
108 | Subtitle | 1.3x | 24 | SemiBold |
109 | **Body** | **1x** | **18** | Regular |
110 | Annotation / caption | 0.78x | 14 | Regular |
111 | Chart annotation | 0.72x | 13 | Regular |
112 | Page number / footnote | 0.61x | 11 | Regular |
113
114 ---
115
116 ## V. Layout Principles
117
118 ### Page Structure
119
120 - **Header area**: 高 ~96px — 页眉标题 + 细色条 + 页序
121 - **Content area**: 高 ~520px — 主体(图表 / 图 / 公式 / 卡片)
122 - **Footer area**: 高 ~40px — 来源标注(LoRA, Hu et al. 2021)+ 页码
123
124 ### Layout Pattern Library(按信息权重组合)
125
126 按页采用:单列居中(封面/结论)、非对称分栏(图 vs 要点)、三/四列卡片(优势/KPI)、image-as-canvas + 原生叠加(方法图)、负空间主导(breathing 概念页)。不把每页做成同一张卡片网格。
127
128 ### Spacing Specification
129
130 **Universal**: 安全边距 64px;内容块间距 28px;图标-文字间距 10px。
131 **Card-based**: 卡片间距 24px;卡片内边距 24px;圆角 12px;四列卡片宽 ~264px。
132 **Non-card(breathing)**: 行高 1.5×;靠留白与分隔线分区。
133
134 ---
135
136 ## VI. Icon Usage Specification
137
138 ### Source
139
140 - 库:`tabler-outline`(线性、轻盈、技术屏显),`stroke_width: 2`,deck 内不混用其它库。
141 - 用法:`<use data-icon="tabler-outline/<name>" stroke-width="2" .../>`
142
143 ### Recommended Icon List
144
145 | Purpose | Icon Path | Page |
146 | ------- | --------- | ---- |
147 | 冻结权重 | `tabler-outline/snowflake` / `tabler-outline/lock` | P03/P06 |
148 | 部署成本 | `tabler-outline/building-bank` / `tabler-outline/server-2` | P03 |
149 | 局限警示 | `tabler-outline/alert-triangle` | P04 |
150 | 低秩洞察 | `tabler-outline/bulb` / `tabler-outline/layers-subtract` | P05 |
151 | 方法 / 公式 | `tabler-outline/math-function` / `tabler-outline/transform` | P06/P07 |
152 | 分支 A/B | `tabler-outline/arrows-split` | P06 |
153 | Transformer 结构 | `tabler-outline/sitemap` / `tabler-outline/topology-star` | P08 |
154 | 可共享 | `tabler-outline/share-2` / `tabler-outline/git-branch` | P09 |
155 | 高效训练 | `tabler-outline/bolt` | P09 |
156 | 零推理延迟 | `tabler-outline/gauge` | P09/P10 |
157 | 正交可叠加 | `tabler-outline/puzzle` | P09 |
158 | 实验 | `tabler-outline/flask` / `tabler-outline/database` | P11 |
159 | 结果 | `tabler-outline/chart-bar` | P10/P12 |
160 | 达标 / 优于 | `tabler-outline/circle-check` | P12/P13 |
161 | 结论 | `tabler-outline/target` | P15 |
162
163 ---
164
165 ## VII. Visualization Reference List
166
167 Catalog read: 71 templates
168
169 | Page | Template | Path | Summary-quote (verbatim from `charts_index.json`) | Usage |
170 | ---- | -------- | ---- | ------------------------------------------------- | ----- |
171 | P02 | agenda_list | `templates/charts/agenda_list.svg` | "Pick for table of contents, meeting agendas, or presentation roadmap — numbered items + brief description + duration / owner per row." | 演示路线图(6 节) |
172 | P04 | vertical_list | `templates/charts/vertical_list.svg` | "Pick for 3-6 numbered key points each with a short description — design principles, core tenets, action items, key takeaways, recommendations, executive summary points." | 已有方法 3 类局限 |
173 | P09 | icon_grid | `templates/charts/icon_grid.svg` | "Pick for 4-9 parallel features/capabilities/services as icon cards — feature grid, service lineup, benefits matrix, brand values, product highlights." | LoRA 四大优势 |
174 | P10 | grouped_bar_chart | `templates/charts/grouped_bar_chart.svg` | "Pick for 2-4 series side-by-side across the same categories (e.g. YoY/QoQ)." | 各方法推理延迟增幅对比 |
175 | P11 | basic_table | `templates/charts/basic_table.svg` | "Pick for plain tabular text/number grid, 3-8 columns." | 模型 × 基准 × 任务实验矩阵 |
176 | P12 | consulting_table | `templates/charts/consulting_table.svg` | "Pick for high-density tables with embedded micro bar visuals (consulting/financial reports)." | GLUE 结果(参数量 + Avg 微条) |
177 | P13 | kpi_cards | `templates/charts/kpi_cards.svg` | "Pick for 4-8 standalone numeric metrics shown as overview cards (2x2 or 1x4) — exec summary opener, dashboard headline, quarterly recap, results-at-a-glance." | GPT-3 175B 四项关键指标 |
178 | P14 | basic_table | `templates/charts/basic_table.svg` | "Pick for plain tabular text/number grid, 3-8 columns." | 适配权重(Table 5)+ 最优秩(Table 6) |
179 | P15 | vertical_list | `templates/charts/vertical_list.svg` | "Pick for 3-6 numbered key points each with a short description — design principles, core tenets, action items, key takeaways, recommendations, executive summary points." | 结论 takeaways |
180
181 **Runners-up considered**:
182
183 - `numbered_steps` | rejected for P02: 演示目录是并列章节而非顺序步骤,agenda_list 自带 duration/section 列更贴合。
184 - `pros_cons_chart` | rejected for P04: 已有方法局限是"单边缺点清单(延迟 / 序列长度 / 质量-效率权衡)",非左右对称的 pros vs cons。
185 - `bar_chart` | rejected for P10: 延迟需对比 AdapterL / AdapterH 两个变体 × 序列场景,属多系列并列,grouped_bar 更准。
186 - `comparison_table` | rejected for P12: GLUE 想用 Avg 微条强化"少参数高分"的视觉,consulting_table 的内嵌 micro-bar 优于纯文本对比表。
187 - `gauge_chart` | rejected for P13: GPT-3 是多项指标(参数比 / VRAM / 吞吐 / 准确率),非单一 hero 指标,kpi_cards 合适。
188
189 ---
190
191 ## VIII. Image Resource List
192
193 | Filename | Dimensions | Ratio | Purpose | Type | Layout pattern | Acquire Via | Status | Reference | text_policy | page_role |
194 | -------- | --------- | ----- | ------- | ---- | -------------- | ----------- | ------ | --------- | ----------- | --------- |
195 | cover_hero.png | 1280x720 | 1.78 | 封面主视觉(Slide 01) | Illustration | #1 full-bleed background with floating title + #29 two-stop scrim | ai | Pending | 冻结的大型预训练权重方阵被锁住,旁路注入一条由两个细长低秩矩阵(降维 A、升维 B)组成的可训练分支,连线汇合到输出;蓝图示意,留下方安静带给 SVG 标题 | embedded | hero_page |
196 | cost_explosion.png | 860x720 | 1.19 | 全量微调部署代价(Slide 03) | Diagram | #4 right image bleeding off the canvas edge + #32 multi-stop scrim with hue shift | ai | Pending | 同一个 175B 巨型模型被为每个下游任务整份复制成多座沉重的服务器机柜,强调"每任务一份满参数副本"的高昂存储/部署成本 | embedded | local |
197 | lowrank_insight.png | 1280x720 | 1.78 | 低秩内在维度洞察(Slide 05) | Illustration | #19 image floating in whitespace with thin frame and caption + #21 rounded rectangle crop | ai | Pending | 高维权重更新云坍缩贴合到一张低维子空间薄片上,少数主方向承载主要信息;概念示意,大量留白 | embedded | local |
198 | reparam_diagram_cropped.png | 1280x531 | 2.41 | LoRA 重参数化结构图(Slide 06) | Diagram | #44 background image + native network/architecture diagram + #41 measurement lines and module tags (engineering overlay) | ai | Pending | 输入 x 同时进入冻结的预训练权重 W 与并行低秩旁路:先经降维矩阵 A 到秩 r 瓶颈,再经升维矩阵 B,两路输出相加得 h;箭头清晰,瓶颈维度 r 标注 | embedded | local |
199 | attention_apply.png | 530x580 | 0.91 | 作用于 Transformer 注意力(Slide 08) | Diagram | #2 left-third image + right text body + #21 rounded rectangle crop | ai | Pending | 一个 Transformer 自注意力模块,四个投影矩阵 Wq/Wk/Wv/Wo,其中 Wq 与 Wv 各挂一条低秩 LoRA 旁路高亮,MLP 模块标为冻结;蓝图结构 | embedded | local |
200 | subspace_heatmap.png | 1024x1024 | 1.0 | 子空间相似度热力图(Slide 14) | Diagram | #3 right-third image + left text body + #21 rounded rectangle crop | ai | Pending | 方阵热力图:行 i 列 j 的归一化子空间相似度,左上角(top singular directions)高强度发亮、其余迅速变暗,清晰的网格单元,蓝-橙强度色阶 | embedded | local |
201 | formula_001.png | 688x44 | 15.64 | 前向传播公式(Slide 06) | Latex Formula | formula-block | formula | Rendered | `h = W_0 x + \Delta W x = W_0 x + B A x` — LoRA 修改后的前向传播 | | |
202 | formula_002.png | 1280x55 | 23.27 | 低秩分解与约束(Slide 06) | Latex Formula | formula-block | formula | Rendered | `W_0 + \Delta W = W_0 + BA, B∈R^{d×r}, A∈R^{r×k}, r≪min(d,k)` — 低秩分解 | | |
203 | formula_003.png | 220x91 | 2.42 | 缩放系数(Slide 07) | Latex Formula | formula-block | formula | Rendered | `\Delta W x · α/r` — ΔWx 的缩放 | | |
204 | formula_004.png | 604x60 | 10.07 | 可训练参数量(Slide 08) | Latex Formula | formula-block | formula | Rendered | `|Θ| = 2 × L_LoRA × d_model × r` — LoRA 可训练参数量 | | |
205
206 > 图内文字按"是否需可编辑"判别(冻结栅格 → 生成后校验);P06 采用 image-as-canvas(#44)满足 image-as-canvas 覆盖要求 — 精确公式与可改写标签走 SVG 叠加,图本身承载结构氛围。所有 AI 图同 blueprint × cool-corporate,HEX 不作为字面文字写进图内。
207
208 ---
209
210 ## IX. Content Outline
211
212 ### Part 1: 引入与问题
213
214 #### Slide 01 - Cover
215 - **Layout**: 全屏主视觉 + 浮层标题(breathing→anchor)
216 - **Title**: LoRA:大模型的低秩适配
217 - **Subtitle**: Low-Rank Adaptation of Large Language Models
218 - **Info**: Hu et al., 2021 · Microsoft · arXiv:2106.09685 · 论文解读
219
220 #### Slide 02 - 演示路线
221 - **Layout**: agenda_list(anchor)
222 - **Title**: 本次讲什么
223 - **Visualization**: agenda_list
224 - **Content**: ① 问题:微调为何越来越贵 ② 已有方法的局限 ③ 核心洞察:低秩假设 ④ LoRA 方法与实现 ⑤ 实验结果 ⑥ 低秩理解与结论
225
226 #### Slide 03 - 问题:全量微调的代价
227 - **Layout**: 左 hero 数字 + 右溢出图(breathing)
228 - **Title**: 模型越大,全量微调越不可行
229 - **Content**:
230 - GPT-3 175B:每个下游任务都要存一份满参数副本(175B)
231 - 部署 N 个任务 = N × 175B,存储与切换成本极高
232 - Hero:**175B** 可训练参数 / 每任务
233
234 ### Part 2: 已有方法与洞察
235
236 #### Slide 04 - 已有方法的局限
237 - **Layout**: vertical_list 三项(dense)
238 - **Title**: 为什么现有高效适配方法不够好
239 - **Visualization**: vertical_list
240 - **Content**:
241 - Adapter 层:增加模型深度 → 引入推理延迟(在线短序列尤甚)
242 - Prefix / Prompt tuning:占用输入长度 → 压缩可用序列
243 - 普遍:常达不到全量微调基线 → 效率与质量的权衡
244
245 #### Slide 05 - 核心洞察:低"内在秩"
246 - **Layout**: 概念图 + 短文(breathing)
247 - **Title**: 权重更新其实"低秩"
248 - **Content**:
249 - 过参数化模型实际位于低内在维度(Aghajanyan et al. 2020)
250 - 假设:适配时的权重变化 ΔW 也具有低"内在秩"
251 - 即使 d 高达 12,288,极低的 r(1~2)也足够
252
253 ### Part 3: 方法
254
255 #### Slide 06 - LoRA 方法
256 - **Layout**: image-as-canvas 结构图 + 公式叠加(breathing)
257 - **Title**: 冻结 W₀,注入低秩 BA
258 - **Visualization**: (AI 结构图 reparam_diagram_cropped + formula_001/002)
259 - **Content**:
260 - 用低秩分解约束更新:W₀ + ΔW = W₀ + BA
261 - 前向:h = W₀x + BAx;训练时 W₀ 冻结,只训 A、B
262 - A 高斯初始化、B 置零 → 起始 ΔW = 0
263
264 #### Slide 07 - 实现细节:初始化与缩放
265 - **Layout**: 公式 + 要点(dense)
266 - **Title**: 一个常数 α、一次部署合并
267 - **Visualization**: (formula_003)
268 - **Content**:
269 - ΔWx 按 α/r 缩放;α 设为首个尝试的 r,不再调
270 - 部署时显式合并 W = W₀ + BA → 与原模型同构
271 - 换任务:减去 BA 再加 B′A′,开销极小
272
273 #### Slide 08 - 作用于 Transformer
274 - **Layout**: 左结构图 + 右要点 + 参数量公式(dense)
275 - **Title**: 只适配注意力权重
276 - **Visualization**: (AI 结构图 attention_apply + formula_004)
277 - **Content**:
278 - 自注意力含 Wq/Wk/Wv/Wo;实验只适配 Wq、Wv,冻结 MLP
279 - 可训练参数量:|Θ| = 2 × L_LoRA × d_model × r
280 - GPT-3 175B:VRAM 1.2TB → 350GB;checkpoint 350GB → 35MB
281
282 #### Slide 09 - 四大优势
283 - **Layout**: icon_grid 四卡(dense)
284 - **Title**: LoRA 的四个关键优势
285 - **Visualization**: icon_grid
286 - **Content**:
287 - 可共享:一个底座 + 多个小 LoRA 模块,换任务只换 BA
288 - 高效训练:无需为冻结参数存梯度/优化器状态,硬件门槛降 3×
289 - 零推理延迟:合并权重后,与全量微调模型同构
290 - 正交可叠加:可与 prefix-tuning 等方法组合
291
292 ### Part 4: 实验结果
293
294 #### Slide 10 - 推理零延迟
295 - **Layout**: grouped_bar_chart(dense)
296 - **Title**: Adapter 增延迟,LoRA 不增
297 - **Visualization**: grouped_bar_chart
298 - **Content**:
299 - GPT-2 medium 单次前向延迟(100 次平均,RTX8000)
300 - AdapterL 最高 +20.7%,AdapterH 最高 +30.3%(短序列/小 batch)
301 - LoRA / FT 基线:**0% 额外延迟**
302
303 #### Slide 11 - 实验设置
304 - **Layout**: basic_table 模型×基准(dense)
305 - **Title**: 覆盖 NLU 到 NLG 的四类模型
306 - **Visualization**: basic_table
307 - **Content**:
308 - RoBERTa base/large(125M/355M)、DeBERTa XXL(1.5B)→ GLUE
309 - GPT-2 medium → E2E NLG;GPT-3 175B → WikiSQL / MNLI / SAMSum
310 - 基线:FT、BitFit、PreEmbed/PreLayer、Adapter H/L/P/D
311
312 #### Slide 12 - GLUE 结果
313 - **Layout**: consulting_table(dense)
314 - **Title**: 更少参数,持平或更优
315 - **Visualization**: consulting_table
316 - **Content**:
317 - RoBERTa-base:FT 86.4(125M)→ LoRA **87.2**(0.3M)
318 - RoBERTa-large:FT 88.9(355M)→ LoRA **89.0**(0.8M)
319 - DeBERTa-XXL:FT 91.1(1500M)→ LoRA **91.3**(4.7M)
320
321 #### Slide 13 - GPT-3 175B 结果
322 - **Layout**: kpi_cards 四指标(dense)
323 - **Title**: 在 175B 尺度上仍然成立
324 - **Visualization**: kpi_cards
325 - **Content**:
326 - **10,000×** 可训练参数缩减(checkpoint 350GB → 35MB)
327 - VRAM 1.2TB → **350GB**(约 1/3)
328 - 训练吞吐 **+25%**(无需为多数参数算梯度)
329 - WikiSQL/MNLI/SAMSum 均**持平或超过**全量微调
330
331 ### Part 5: 理解与结论
332
333 #### Slide 14 - 低秩理解:权重与秩
334 - **Layout**: 左双表 + 右热力图(dense)
335 - **Title**: 该适配谁?秩要多大?
336 - **Visualization**: basic_table + (AI 热力图 subspace_heatmap)
337 - **Content**:
338 - 同等参数预算:适配 {Wq, Wv} 最佳(WikiSQL 73.7)
339 - 秩 r=1 即足以适配 {Wq, Wv}(r=64 几乎无增益)
340 - 子空间相似度:top 奇异方向高度重叠 → ΔW 内在秩极低
341
342 #### Slide 15 - 结论与影响
343 - **Layout**: vertical_list takeaways(anchor)
344 - **Title**: 结论与影响
345 - **Visualization**: vertical_list
346 - **Content**:
347 - 低秩适配 = 参数高效 + 零额外推理延迟 + 质量持平/更优
348 - 工程意义:一个底座托管多任务,按需热插拔 LoRA
349 - 已开源(microsoft/LoRA),成为大模型微调的事实标准之一
350
351 ---
352
353 ## X. Speaker Notes Requirements
354
355 - 每页一篇,存 `notes/total.md`(主文档用 `#` 标题行,文件名匹配 SVG)
356 - 总时长:约 18-22 分钟;风格:讲解型(conversational-professional);目的:inform + instruct
357 - 中文讲解,术语保留英文
358
359 ---
360
361 ## XI. Technical Constraints Reminder
362
363 ### SVG Generation Must Follow:
364 1. viewBox `0 0 1280 720`;背景用 `<rect>`
365 2. 文本换行用 `<tspan>`;禁止 `<foreignObject>`
366 3. 透明默认用 `fill-opacity` / `stroke-opacity`;`rgba()` 保持转换兼容
367 4. 禁止:`mask`、`<style>`、`class`、`foreignObject`、`textPath`、`animate*`、`script`
368 5. 字符写原始 Unicode(`—`、`→`、`×`、`≪`);禁止 HTML 实体;`& < >` 转义为 `&amp; &lt; &gt;`
369 6. `clipPath` 仅用于 `<image>`(圆角裁剪等)
370
371 ### PPT Compatibility Rules:
372 - 默认逐子元素设置 opacity;`<g opacity>` 可转换但会产生近似保真 warning
373 - 图片半透明用叠加遮罩层
374 - 仅内联样式;禁外部 CSS / `@font-face`
375
375 lines MARKDOWN