Closed Bryce1010 closed 3 years ago
NLP tasks
展开描述这么多组合
如何fine-tune模型呢?
有两种常见做法, 一种是fix feature extractor; 另一种是non-fix;
但是这样fine-tune的模型往往会非常巨大, 那就变成富人玩的游戏, 穷人怎么分一杯羹?
我们固定住模型, 添加adaptor, 只要学习adaptor的参数.
Adaptor举例
Adaptor结果
Pretrain 的魔力
根据输出的类型不同, 李宏毅老师将NLP任务分为两种:
第一种是sequence to class
第二种是 sequence to sequence
那怎么解决multi-sequence的问题?
第一种是采用multi-model 每一个model训练一个sequence, 然后合并起来;
第二种是, 将mutli-sequence合并成一个sequence, 中间采用特殊符号分隔;
对句子中每个词的词性做tagging, 动词, 名词, 形容词
比如中文来说 ,需要对句子断句;
比如人名代称, he she it 等
指摘要
input: sequence
output: sequence
input: sequence output: sequence
input: sequence
output: class
立场检测
input: two sequence
output: class
真实性评估
self attention 的每一个token或者输入都生成三个向量:Q, K, V.
Q的作用是匹配其他的输入,K的作用是被Q匹配,吃入两个向量得到一个attention;V是用来与attention做矩阵相乘后提取的特征。
然后拿每一个query q都跟key k做attention; 其中d表示q和k的维度大小,表示一个小的正则化。
然后通过softmax生成attention map
得到了attention map后,乘上V然后累加起来,就能得到输出
这是一种position independent的考虑方式,不同于RNN 与时间序列相关是一种position relative。
算出第二个输出
b1, b2, b3, b4是并行输出的,所以可以用matrix来计算,而且matrix在GPU中很容易加速。
所以接下来看一下self attentition的矩阵形式
最终形式如下:
multi-head就是每一个输入对应了多个Q, K, V向量;然后每一个head都是相互独立计算的,计算过程跟上面介绍的一致。
在self-attention中没有位置信息,论文中的做法是:
对每一个输入xi,可以加上一个位置向量,这个位置向量可以是one-hot向量。
http://speech.ee.ntu.edu.tw/~tlkagk/courses_DLHLP20.html