Files
maths-cs-ai-compendium-zh/images/transformer_paradigms.svg
T
flykhan 2536c937e3 feat: 完整中文翻译 maths-cs-ai-compendium(数学·计算机科学·AI 知识大全)
翻译自英文原版 maths-cs-ai-compendium,共 20 章全部完成。

第01章 向量 | 第02章 矩阵 | 第03章 微积分
第04章 统计学 | 第05章 概率论 | 第06章 机器学习
第07章 计算语言学 | 第08章 计算机视觉 | 第09章 音频与语音
第10章 多模态学习 | 第11章 自主系统 | 第12章 图神经网络
第13章 计算与操作系统 | 第14章 数据结构与算法
第15章 生产级软件工程 | 第16章 SIMD与GPU编程
第17章 AI推理 | 第18章 ML系统设计
第19章 应用人工智能 | 第20章 前沿人工智能

翻译说明:
- 所有数学公式 $...$ / $$...$$、代码块、图片引用完整保留
- mkdocs.yml 配置中文导航 + language: zh
- README.md 已翻译为中文(兼 docs/index.md)
- docs/ 目录包含指向各章文件的 symlink
- 约 29,000 行中文内容,排除 .cache/ 构建缓存
2026-05-03 10:23:20 +08:00

117 lines
7.5 KiB
XML

<svg width="720" height="340" xmlns="http://www.w3.org/2000/svg">
<text x="360" y="22" fill="#333" font-size="14" font-weight="bold" text-anchor="middle">Three Transformer Paradigms</text>
<!-- === Encoder-only (BERT) === -->
<rect x="15" y="38" width="220" height="290" rx="10" fill="#3498db" opacity="0.05" stroke="#3498db" stroke-width="1.5"/>
<text x="125" y="58" fill="#3498db" font-size="12" font-weight="bold" text-anchor="middle">Encoder-only (BERT)</text>
<!-- Attention matrix: full bidirectional -->
<text x="125" y="78" fill="#666" font-size="9" text-anchor="middle">Attention mask</text>
<rect x="60" y="85" width="130" height="80" rx="4" fill="#3498db" opacity="0.2" stroke="#3498db" stroke-width="1"/>
<text x="125" y="130" fill="#3498db" font-size="10" text-anchor="middle" font-weight="bold">All-to-all</text>
<!-- Fill squares to show full attention -->
<g opacity="0.4">
<rect x="65" y="90" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="87" y="90" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="109" y="90" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="131" y="90" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="153" y="90" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="65" y="106" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="87" y="106" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="109" y="106" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="131" y="106" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="153" y="106" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="65" y="143" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="87" y="143" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="109" y="143" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="131" y="143" width="20" height="14" rx="2" fill="#3498db"/>
<rect x="153" y="143" width="20" height="14" rx="2" fill="#3498db"/>
</g>
<!-- Training -->
<text x="125" y="185" fill="#333" font-size="10" text-anchor="middle" font-weight="bold">Training: Masked LM</text>
<text x="125" y="200" fill="#666" font-size="9" text-anchor="middle">Predict [MASK] tokens</text>
<!-- Use case -->
<text x="125" y="225" fill="#333" font-size="10" text-anchor="middle" font-weight="bold">Best for:</text>
<text x="125" y="240" fill="#666" font-size="9" text-anchor="middle">Classification, NER,</text>
<text x="125" y="253" fill="#666" font-size="9" text-anchor="middle">QA, retrieval</text>
<!-- Example -->
<rect x="30" y="265" width="190" height="30" rx="5" fill="#3498db" opacity="0.1" stroke="#3498db" stroke-width="1"/>
<text x="125" y="277" fill="#3498db" font-size="9" text-anchor="middle">The [MASK] sat on the mat</text>
<text x="125" y="290" fill="#3498db" font-size="8" text-anchor="middle">→ predict "cat"</text>
<!-- Models -->
<text x="125" y="318" fill="#3498db" font-size="9" text-anchor="middle" font-weight="bold">BERT, RoBERTa, DeBERTa</text>
<!-- === Decoder-only (GPT) === -->
<rect x="250" y="38" width="220" height="290" rx="10" fill="#e74c3c" opacity="0.05" stroke="#e74c3c" stroke-width="1.5"/>
<text x="360" y="58" fill="#e74c3c" font-size="12" font-weight="bold" text-anchor="middle">Decoder-only (GPT)</text>
<!-- Attention matrix: causal (lower triangle) -->
<text x="360" y="78" fill="#666" font-size="9" text-anchor="middle">Attention mask</text>
<rect x="295" y="85" width="130" height="80" rx="4" fill="#fff" stroke="#e74c3c" stroke-width="1"/>
<!-- Lower triangle filled -->
<g opacity="0.4">
<rect x="300" y="90" width="20" height="14" rx="2" fill="#e74c3c"/>
<rect x="300" y="106" width="20" height="14" rx="2" fill="#e74c3c"/>
<rect x="322" y="106" width="20" height="14" rx="2" fill="#e74c3c"/>
<rect x="300" y="122" width="20" height="14" rx="2" fill="#e74c3c"/>
<rect x="322" y="122" width="20" height="14" rx="2" fill="#e74c3c"/>
<rect x="344" y="122" width="20" height="14" rx="2" fill="#e74c3c"/>
<rect x="300" y="143" width="20" height="14" rx="2" fill="#e74c3c"/>
<rect x="322" y="143" width="20" height="14" rx="2" fill="#e74c3c"/>
<rect x="344" y="143" width="20" height="14" rx="2" fill="#e74c3c"/>
<rect x="366" y="143" width="20" height="14" rx="2" fill="#e74c3c"/>
</g>
<text x="360" y="130" fill="#e74c3c" font-size="10" text-anchor="middle" font-weight="bold">Causal</text>
<!-- Training -->
<text x="360" y="185" fill="#333" font-size="10" text-anchor="middle" font-weight="bold">Training: Next token</text>
<text x="360" y="200" fill="#666" font-size="9" text-anchor="middle">Predict w_t from w_&lt;t</text>
<!-- Use case -->
<text x="360" y="225" fill="#333" font-size="10" text-anchor="middle" font-weight="bold">Best for:</text>
<text x="360" y="240" fill="#666" font-size="9" text-anchor="middle">Text generation,</text>
<text x="360" y="253" fill="#666" font-size="9" text-anchor="middle">chat, code, reasoning</text>
<!-- Example -->
<rect x="265" y="265" width="190" height="30" rx="5" fill="#e74c3c" opacity="0.1" stroke="#e74c3c" stroke-width="1"/>
<text x="360" y="277" fill="#e74c3c" font-size="9" text-anchor="middle">The cat sat on the</text>
<text x="360" y="290" fill="#e74c3c" font-size="8" text-anchor="middle">→ predict "mat"</text>
<!-- Models -->
<text x="360" y="318" fill="#e74c3c" font-size="9" text-anchor="middle" font-weight="bold">GPT, LLaMA, Claude</text>
<!-- === Encoder-Decoder (T5) === -->
<rect x="485" y="38" width="220" height="290" rx="10" fill="#27ae60" opacity="0.05" stroke="#27ae60" stroke-width="1.5"/>
<text x="595" y="58" fill="#27ae60" font-size="12" font-weight="bold" text-anchor="middle">Encoder-Decoder (T5)</text>
<!-- Attention: split view -->
<text x="595" y="78" fill="#666" font-size="9" text-anchor="middle">Attention mask</text>
<rect x="500" y="85" width="60" height="35" rx="4" fill="#3498db" opacity="0.15" stroke="#3498db" stroke-width="1"/>
<text x="530" y="107" fill="#3498db" font-size="8" text-anchor="middle">bidir</text>
<text x="565" y="107" fill="#666" font-size="8" text-anchor="middle">+</text>
<rect x="575" y="85" width="60" height="35" rx="4" fill="#e74c3c" opacity="0.15" stroke="#e74c3c" stroke-width="1"/>
<text x="605" y="107" fill="#e74c3c" font-size="8" text-anchor="middle">causal</text>
<rect x="500" y="125" width="135" height="25" rx="4" fill="#27ae60" opacity="0.15" stroke="#27ae60" stroke-width="1"/>
<text x="567" y="142" fill="#27ae60" font-size="8" text-anchor="middle">cross-attention</text>
<!-- Training -->
<text x="595" y="172" fill="#333" font-size="10" text-anchor="middle" font-weight="bold">Training: Span corrupt</text>
<text x="595" y="187" fill="#666" font-size="9" text-anchor="middle">Reconstruct masked spans</text>
<!-- Use case -->
<text x="595" y="212" fill="#333" font-size="10" text-anchor="middle" font-weight="bold">Best for:</text>
<text x="595" y="227" fill="#666" font-size="9" text-anchor="middle">Translation, summarisation,</text>
<text x="595" y="240" fill="#666" font-size="9" text-anchor="middle">text-to-text tasks</text>
<!-- Example -->
<rect x="500" y="252" width="190" height="43" rx="5" fill="#27ae60" opacity="0.1" stroke="#27ae60" stroke-width="1"/>
<text x="595" y="267" fill="#27ae60" font-size="9" text-anchor="middle">In: "The [X] on [Y]"</text>
<text x="595" y="282" fill="#27ae60" font-size="9" text-anchor="middle">Out: "[X] cat sat [Y] the mat"</text>
<!-- Models -->
<text x="595" y="318" fill="#27ae60" font-size="9" text-anchor="middle" font-weight="bold">T5, BART, mBART</text>
</svg>