文章目录
摘要
本周先是好好理解了一下self-attention的QKV的理解,关于如何让自注意力机制更有效的问题,学习了self-attention的多种变形,包括减少注意力矩阵的计算量、加快注意力机制的运算速度、去掉attention等。
Abstract
This week, I first had a good understanding of the QKV of self-attention, about how to make the self-attention mechanism more effective, and learned a variety of variants of self-attention, including reducing the computation amount of attention matrix, speeding up the computation speed of attention mechanism, removing attention and so on.
self-attetion
QKV理解
以搜索查询商品为例:
query可以理解为输入要查询的商品;
key为商品的标签或者title;
value可理解为商品的评价之类的;
相似度=querykey(矩阵乘法) 根据相似度 召回
总分=相似度value 根据总分排序输出
Q(query):模型从token中提取出来的对token的理解信息,用于主动与其他token计算相似程度
K(key):模型从token提取出来的,与其他token的关系信息,被用于与其他token计算相似程度
V(value):表示当前token的重要程度
-
self-attention中self的理解
self-attention的self,表示query,key,value都来自自己,每个token都能提取出来自己的query,key,value -
计算过程
A t t e n t i o n ( Q , K , V ) = s o f t m a x ( Q K T d k V ) Attention(Q,K,V)=softmax(\frac{QK^T}{\sqrt{d_k}}V) Attention(Q,K,V)=softmax(