Attention!注意力机制可解释吗?
来源:哈工大SCIR
本文将与您探讨注意力机制的可解释性问题。
序言
一、注意力机制(Attention Mechanism)
1.1 背景
1.2 结构
- Key(键) 与值相对应同时又用来与查询计算相似度作为Attention选取的依据;
- Query(查询) 一次执行Attention时的查询;
- Value(值)被注意并选取的数据。
- 对每个输入元素计算一个非负对归一化权重;
- 将这些权重与对应成分的表示相乘;
- 将得到的结果求和,产生一个固定长度的表示。
二、可解释性的定义
- Attention权重的高低应该与对应位置信息的重要程度正相关;
- 高权重的输入单元对于输出结果有决定性作用。
三、具体论证
3.1 Not Explanation
3.1.1 中间表示擦除
- Total Variance Distance(TVD) 作为输出结果分布区别的指标,公式为:其和为两个不同的输出结果分布。
- Jensen-Shannon Divergence(JSD) 作为输出结果分布和Attention权重区别的指标,公式为:其中和为两个不同的分布,可以是输出结果也可以是Attention权重,为Kullback-Leibler Divergence。
- Hierarchical Attention Network 由Yang[7]提出的层级Attention模型,如图3左侧所示,分为词语级和句子级两个部分,实验只测试句子级的Attention层,之前的部分均视为编码阶段;
- Flat Attention Network 在前一个模型的基础上修改得到的只有一个词级别的Attention层对不分句对整个文档进行操作;
- Flat Attention Network with CNN 在前一个模型上将作为编码器的双向RNN结构替换为CNN,如图3右侧所示,参考了Kim[8]的实现;
- No Encoder 不使用编码器,直接将词嵌入之后的结果输入Attention层。这一对照组的目的在于剔除编码器而防止单个token得到上下文信息。
- 按照Attention权重从大到小依次将其加入置零集合;
- 如果模型的决策发生翻转则停止扩展集合;
- 检验是否有真子集同样能翻转模型的决策。
- 随机排序;
- 用回传到Attention层的梯度值大小来排序;
- 将梯度值与Attention权重相乘的值来排序。
3.1.2 构造对抗权重
- Attention权重与特征的重要度指标的相关程度有多少?
- 是否不一样的权重分布就一定会让模型作出不一样的决策?
- ‘Only weakly and inconsistenly’,Attention权重与特征的重要度指标(梯度分布、删去某个中间表示后模型结果变化程度TVD分布)的相关度并不大,并且不稳定;
- ‘It is very possible to construct adversarial attention distributions that yield effectively equivalent predictions.’,很容易就能构造出与原始权重关注特征完全不同的对抗权重,更进一步而言,随机设置权重往往不会对模型决策结果有太大影响。
3.2 Not Not Explanation
- Attention Distribution is not a Primitive. Attention权重分布不是独立存在的,由于经历了前向传播和反向传播的整个过程,Attention层的参数是无法同整个模型隔离开的,不然就失去了实际的意义;
- Existence does not Entail Exclusivity. Attention分布的存在并不蕴含着排他性,Attention只是提供一个解释而不是提供唯一的解释。尤其是当中间表示的向量维度很大而输出结果的类别很少时,降维的映射函数很容易就有较大的灵活性。
- Uniform as Adversary 训练一个将Attention权重固定为均值的baseline来模型;
- Variance with a Model 用随机种子初始化重新训练来作为Attention权重分布偏差的正常基准;
- Diagnosing Attention Distribution by Guiding Simpler Models 实现一个利用的固定住的预训练Attention权重的诊断框架;
- Training an Adversary 设计一个end-to-end的对抗权重训练方法,需要注意的是这不是一个独立的实验,而是上一个实验的对抗权重生成的具体实现。
- 预设的Attention权重为均值,作为baseline;
- 不固定权重,允许其随着MLP一起训练;
- 直接使用LSTM作为编码器时使用的原始Attention权重;
- 使用对抗生成的Attention权重(在后一节实现)。
四、结论
- 什么样的任务需要Attention机制,它是不是普适的?
- 编码层的选取对Attention到底会产生什么样的影响?
- 在同一个数据集上的不同模型之间迁移Attention权重是否合理?
- 模型和数据集的复杂程度会对构造对抗权重的难易产生何种影响?
参考文献:
[1] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. Advances in neural information processing systems, pp. 5998-6008.
[2] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2019. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171-4186.
[3] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. 2015. Neural machine translation by jointly learning to align and translate. In Proceedings of the International Conference on Learning Representations.
[4] Sofia Serrano, and Noah A. Smith. 2019. Is Attention Interpretable. arXiv preprint arXiv:1906.03731.
[5] Sarthak Jain and Byron C. Wallace. 2019. Attention is not Explanation. InProceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers).
[6] Sarah Wiegreffe, and Yuval Pinter. 2019. Attention is not not Explanation.arXiv preprint arXiv:1908.04626.
[7] Zichao Yang, Diyi Yang, Chris Dyer, Xiaodong He, Alex Smola, and Eduard Hovy. 2016. Hierarchical attention networks for document classification. InProceedings of the Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies.
[8] Yoon Kim. 2014. Convolutional neural networks for sentence classification. InProceedings of the Conference on Empirical Methods in Natural Language Processing.
[9] Zachary C Lipton. 2016. The mythos of model interpretability. arXiv preprint arXiv:1606.03490.
参考来源:
NAACL 2019《Attention is Not Explanation》
ACL 2019《Is Attention Interpretable?》
EMNLP 2019《Attention is Not Not Explanation》
Attention!注意力机制可解释吗?相关推荐
- DL之Attention:Attention注意力机制的简介、应用领域之详细攻略
DL之Attention:Attention注意力机制的简介.应用领域之详细攻略 目录 Attention的简介 1.Why Attention? 2.Attention机制的分类 3.Attenti ...
- 图片的描述生成任务、使用迁移学习实现图片的描述生成过程、CNN编码器+RNN解码器(GRU)的模型架构、BahdanauAttention注意力机制、解码器端的Attention注意力机制
日萌社 人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新) Encoder编码器-Decoder解码器框架 + Atten ...
- Attention注意力机制–原理与应用
Attention注意力机制–原理与应用 注意力机制即Attention mechanism在序列学习任务上具有巨大的提升作用,在编解码器框架内,通过在编码段加入A模型,对源数据序列进行数据加权变换, ...
- Attention注意力机制学习(二)------->一些注意力网络整理
SKNet--SENet孪生兄弟篇(2019) 论文 Selective Kernel Networks https://arxiv.org/abs/1903.06586 2019年 介绍 SKNe ...
- Transform中的Attention注意力机制
本文边讲细节边配合代码实战,代码地址为: https://github.com/princewen/tensorflow_practice/tree/master/basic/Basic-Transf ...
- Attention注意力机制--原理与应用
Attention注意力机制--原理与应用 注意力机制即Attention mechanism在序列学习任务上具有巨大的提升作用,在编解码器框架内,通过在编码段加入A模型,对源数据序列进行数据加权变换 ...
- 循环神经网络RNN 2—— attention注意力机制(附代码)
attention方法是一种注意力机制,很明显,是为了模仿人的观察和思维方式,将注意力集中到关键信息上,虽然还没有像人一样,完全忽略到不重要的信息,但是其效果毋庸置疑,本篇我们来总结注意力机制的不同方 ...
- 基于Transformer的文本情感分析编程实践(Encoder编码器-Decoder解码器框架 + Attention注意力机制 + Positional Encoding位置编码)
日萌社 人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新) Encoder编码器-Decoder解码器框架 + Atten ...
- 机器翻译 MXNet(使用含注意力机制的编码器—解码器,即 Encoder编码器-Decoder解码器框架 + Attention注意力机制)
日萌社 人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新) Encoder编码器-Decoder解码器框架 + Atten ...
- CVPR2021|| Coordinate Attention注意力机制
Paper:https://arxiv.org/pdf/2103.02907.pdf GitHub:https://github.com/Andrew-Qibin/CoordAttention 轻量, ...
最新文章
- 密码界“女杀手”,破译世上最安全密码系统,获 771 万奖金!
- python编程员工资-Python 程序员的工资能有多高?
- cocos2d-x初探学习笔记(15)--CCOrbitCamera
- 数据结构之顺序表(二)
- 每天学一点ubuntu指令
- U盘安装linux后无法引导
- CentOS 关闭防火墙和selinux
- 关于合格工程师素养的一些思考
- 安川服务器显示ab32,安川驱动器维修常见报警代码及维修方法
- 网络七层协议和TCP/IP五层协议
- 在注视之外:对于认知和认知发展研究,眼动追踪还能揭示什么?
- jFreeChart连接oracle数据库数据实现顺序图,饼形图和柱状图
- Android跳转到应用商店详情页面
- 古典恺撒移位密码破解
- 基于LayUI使用FullCalendar实现日程管理
- 热门解读:社交裂变的拉新效果评估及优化
- 人们怎么总跟质数过不去?
- 本地配置多个git账户(公司、GitHub)
- resent = msg.get_all('Resent-Date') AttributeError: 'str' object has no attribute 'get_all'
- es android,ES文件浏览器
热门文章
- Python 绘图与可视化 matplotlib 制作Gif动图
- $.when().done().then()的用法
- Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (usin
- J2EE 13规范(4)-JSP
- SIPp工具Linux下安装
- Guid和Int还有Double、Date的ToString方法的常见格式
- Linux操作系统文件系统基础知识详解
- js获取asp.net服务器端控件Label,TextBox,RadioButtonList,DropDownList的值
- [轉]Webdings字体图案
- DLL(MFC)通过Window消息向C#程序传递数据