Skip to content

论文笔记

flowchart TD
A[Attention Is All You Need<br/>2017] --> B[BERT<br/>2018]
A --> C[GPT 系列<br/>2018-2023]
C --> D[InstructGPT<br/>2022]
D --> E[RLHF 对齐]
A --> F[ViT<br/>2020]
F --> G[多模态]

作者:Vaswani et al. (Google Brain)
引用:超过 100,000 次
意义:提出 Transformer 架构,完全取代了 RNN 在序列建模中的地位。

  1. 完全基于 Attention 的架构:不使用任何循环或卷积
  2. Multi-Head Attention:多个注意力头并行捕捉不同粒度的关系
  3. 位置编码:用正弦函数编码位置信息
  4. 训练效率:可并行计算,训练速度远超 RNN

缩放点积注意力:

Attention(Q,K,V)=softmax(QKTdk)V\text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V

Multi-Head Attention:

MultiHead(Q,K,V)=Concat(head1,...,headh)WO\text{MultiHead}(Q, K, V) = \text{Concat}(\text{head}_1, ..., \text{head}_h)W^O

其中 headi=Attention(QWiQ,KWiK,VWiV)\text{head}_i = \text{Attention}(QW_i^Q, KW_i^K, VW_i^V)

  • Encoder:6 层,每层有 Self-Attention + FFN
  • Decoder:6 层,每层有 Masked Self-Attention + Cross-Attention + FFN
  • dmodel=512d_{\text{model}} = 512h=8h = 8 个头,dk=dv=64d_k = d_v = 64
  • 在 WMT 2014 英德翻译任务上达到 28.4 BLEU(当时最佳)

“BERT: Pre-training of Deep Bidirectional Transformers” (2018)

Section titled ““BERT: Pre-training of Deep Bidirectional Transformers” (2018)”

作者:Devlin et al. (Google AI)
意义:提出双向预训练范式,在 11 项 NLP 任务上刷新纪录。

  1. Masked Language Model (MLM):随机 mask 15% 的 token,训练模型预测被 mask 的词
  2. Next Sentence Prediction (NSP):判断两句话是否连续
  3. 双向上下文:与 GPT 的单向不同,BERT 能同时看到前后文
  • 数据:BooksCorpus (800M 词) + English Wikipedia (2.5B 词)
  • 两个版本:BERT-base (110M 参数) / BERT-large (340M 参数)
  • 输入格式:[CLS] 句子A [SEP] 句子B [SEP]

BERT 通过添加一个简单的分类头即可适配各种下游任务:

  • 单句分类:取 [CLS] 的输出
  • 句子对分类:同上
  • 序列标注:取每个 token 的输出
  • 问答:预测答案的起始和结束位置

“Training language models to follow instructions” (InstructGPT, 2022)

Section titled ““Training language models to follow instructions” (InstructGPT, 2022)”

作者:Ouyang et al. (OpenAI)
意义:提出 RLHF 方法,让大模型对齐人类意图。

  1. SFT(监督微调):收集人类写的 prompt-answer 对,微调 GPT-3
  2. RM(奖励模型训练):让标注员对多个回答排序,训练奖励模型
  3. PPO(强化学习):用奖励模型通过 PPO 算法优化策略
  • 1.3B 的 InstructGPT 比 175B 的 GPT-3 更受人类偏好
  • RLHF 显著减少了有害输出和编造信息
  • 在”真实性”(Truthfulness)指标上大幅提升
  • RLHF 成为 ChatGPT、Claude 等产品的核心对齐技术
  • DPO (2023) 提出了更简单的替代方案,无需显式训练奖励模型

  • 先读 Abstract + Conclusion,了解核心贡献
  • 再看图和表,理解架构
  • 最后读实验细节
  • 配合代码实现加深理解