赞
踩
Self-Supervised Learning 很多模型都是以芝麻街的人物命名
Self-supervised Learning Framework
Embeddings from Language Model
How to exploit the context?
上面蓝框中的 NN 其实并不是一个 deep network;word embedding 文献中其实只是一个全连接层
Prediction-based – Sharing Parameters
Prediction-based – Training
Prediction-based – Various Architectures
Characteristics
Solving analogies
In typical word embedding, each word type has an embedding. But a word can have multiple senses.
timeline: Transformer (2017/06) → \rightarrow → GPT (2018/06) → \rightarrow → BERT (2018/10) → \rightarrow → GPT-2 (2019/02) → \rightarrow → GPT-3 (2020/05)
GPT 生成过一篇发现独角兽的假新闻,展示了 GPT 的超强能力,因此用独角兽代表 GPT
talk to transformer (一个小型的 GPT), GPT 3 demos
Unsupervised pre-training
Supervised fine-tuning
在下游任务微调时,模型需要的额外参数仅有 W y W_y Wy 和 delimiter tokens 的 embeddings
Task-specific input transformations
上图中,蓝色的 Start, Extract, Delim 均为特殊的 delimiter tokens,它们对应的 embeddings 需要在下游任务中进行额外训练
GPT-2
dog.
和 dog!dog?
,为此作者禁止了 BPE 合并不同种类的字符 (空格除外)Few-Shot (FS), One-Shot (1S), Zero-Shot (0S)
GPT-3 这种 fet-shot learning 的方法尴尬之处在于,当你下游任务真有一个数据集的时候,GPT-3 模型太大不方便做微调,同时每次做推理时都把数据集所有样本列进文本里也很不方便
Model and Architectures
Training Dataset
e.g. 把 pixel 当作 token 训练 GPT 的话,就可以生成图片 (Ref: Image GPT)
pre-training + fine-tuning
BERT 的网络架构
可以简单看一下如何计算 BERT 的参数量。假设词典大小为 N N N,那么 Input Embedding 的参数量即为 N × H N\times H N×H。多头注意力模块由四个线性层组成,其中 3 个负责将 Q , K , V Q,K,V Q,K,V 映射到 A A A 个低维线性空间上,1 个负责将 A A A 个头拼接得到的结果再进行一次线性变换,因此参数量为 4 × H × H 4\times H\times H 4×H×H。MLP 由两个全连接层组成,一个将 H H H 维向量映射为 4 H 4H 4H 维向量,一个将 4 H 4H 4H 维向量映射回 H H H 维向量,因此参数量为 2 × 4 H × H 2\times 4H\times H 2×4H×H。因此总的参数量即为 N H + L × 12 H 2 NH+L\times 12H^2 NH+L×12H2 (paper 中 N = 30 , 000 N=30,000 N=30,000)
BERT base 模型与 GPT 模型大小相同,就是为了方便与 GPT 进行比较
BERT 的预训练任务 - 双向
联想:在 NLP 领域,使用大量无标签数据预训练出的模型比使用相对少量的有标签数据预训练出的模型效果更好。那么在 CV 领域是否也是这样的呢?
Tokenization in simple words is the process of splitting a phrase, sentence, paragraph, one or multiple text documents into smaller units. Each of these smaller units is called a token.
word and character-based tokenization
Subword-based tokenization
Byte-Pair Encoding (BPE)
如果我们永远都不删除那些单个字符,就一定能表示 OOV 的单词
WordPiece (bottom-up)
WordPiece (top-down) (used in BERT)
[CLS]
(classification),对于分类任务来说该符号对应的最终输出被当作整个输入序列的总体特征表示 (aggregate sequence representation) (由于 BERT 是双向的结构,第一个输出也能融合整个输入序列的信息)。为了区分句子对中的两个句子,两个句子中间由一个特殊符号 [SEP]
隔开,同时 BERT 还加入了一个特殊的 Segement Embedding 层用于表示每个 token 是属于句子
A
A
A 还是句子
B
B
B (Segement Embedding 层参数由两个向量
E
A
,
E
B
E_A,E_B
EA,EB 组成,它们不是事先确定的,而是跟模型一起学习得到的)。因此如下图所示,一个 token 对应的输入特征是三个部分的加和:WordPiece Embedding + Segement Embedding + Position Embedding (这里的 Position Embedding 并不是和 Transformer 一样是用正余弦函数得到的,而是随模型一起学得的。由于 BERT 能够处理最长 512 个 token 的输入序列,Position Embedding 的参数量实际上为
512
×
d
m
o
d
e
l
512\times d_{model}
512×dmodel)
[CLS]
对应的最终输出记为 C ∈ R H C\in\R^H C∈RH,第 i i i 个 token 对应的最终输出记为 T i ∈ R H T_i\in\R^H Ti∈RH
[CLS]
, [SEP]
这些特殊词元) 替换为一个掩码 [MASK]
), and the objective is to predict those masked tokens based only on its context. (类似于完形填空)[MASK]
是不会出现在下游任务中的,这会导致 pre-training 和 fine-tuning 看到的数据会有不同 (a mismatch between pre-training and fine-tuning)。为了缓解该问题,BERT 并不总是将 15% 作为掩码的输入 token 都直接替换为 [MASK]
。如果第
i
i
i 个词元被选作掩码用于给模型作预测,那么 (1) 有 80% 的几率将其替换为 [MASK]
;(2) 10% 的几率将其替换为一个随机 token (相当于加 noise);(3) 10% 的几率不改变该 token,但仍让模型对其进行预测 (用来缩小 pre-training 和 fine-tuning 所用数据之间的差距)IsNext
), and 50% of the time it is a random sentence from the corpus (labeled as NotNext
). (在作分类任务时,[CLS]
对应的输出被用于提供整个句子的总体信息)注意到,BERT 的预训练数据集不仅使用了 GPT 的 BooksCorpus,还增加了 English Wikipedia,这也是为什么 BERT 不仅能训练出与 GPT 一样大的 BERT base,还能训练出 3 倍参数量的 BERT large。从这个角度来看,BERT 打败 GPT 也得益于更大的数据集和更大的模型
BERT 在 pre-train 阶段是 unsupervised-learning (self-supervised learning),而 fine-tune 阶段是 supervised learning;整个训练过程可以看作 semi-supervised learning
BERT 的论文里也做了 Ablation Studies,实验了用 Feature-based Approach 的方法使用 BERT 的效果,结果是没有 fine-tuning 好的
Extraction-based QA: 答案一定出现在问题里
随机初始化蓝色和橙色的向量,分别用它们与 BERT 的输出作内积 (类似于 attention) 得到答案的起始和终止位置 (如果 s > e s>e s>e 则表示问题无解)。训练时的 loss 为答案开始位置的 log-loss 和答案结束位置的 log-loss 之和
BERT 中 self-attention 计算量很大,因此不能输入太长的序列。在训练时可以每次只截取一部分的文本作为训练数据进行训练
When does BERT know POS tagging, syntactic parsing, semantics?
如何生成 “corrupted input”? – MASS / BART
Text infilling: mask+delete
BART 用了上图中的所有方法,得到了比较好的效果
Cross-lingual Alignment?
Weird???
Where is Language?
De-noising Auto-encoder
Original Seq2seq Auto-encoder
Feature Disentangle
e.g. phonetic information 可以做语音识别,speaker information 可以做声纹比对
Training
Result: Audio segments of two different speakers
Application: Voice Conversion
Vector Quantized Variational Auto-encoder (VQVAE)
For speech, the codebook represents phonetic information (paper: Unsupervised speech representation learning using WaveNet autoencoders)
Application: Unsupervised Summarization
Only need a lot of documents to train the model
Auto-encoder
More about Anomaly Detection
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。