深度学习中的Attention机制

转自:https://mp.weixin.qq.com/s/EMCZHuvk5dOV_Rz00GkJMA

【文末有彩蛋!】

推荐阅读时间:8min~13min

主要内容:简介明了的讲解一些Attention Model的套路和理论

---------------------------------------------

作者:YBB

单位:清华大学研究生

1
Attention 的本质


attention其实就是一个加权平均。

attention处理的问题,往往面临的是这样一个场景:

2
Attention的设计


如何计算得到alpha(i),一般分为两个步骤:

那么如何设计step 1中的打分函数f呢,在论文”Dynamic Attention Deep Model for Article Recommendation by Learning Human Editors’Demonstration”中的Attention Mechanism章节给了较为全面的概括。大体分为三类:

其中General Attention并不常见,(可能笔者读的paper不够多,目前还没有遇到过)因此在这里不做介绍。接下来详细介绍下Location-based Attention和Concatenation-based Attention的设计。


2.1 Location-based Attention


具体我们来举几个例子,可能具体实现上,有略微区别,不过都大同小异:

Example 1:A Context-aware Attention Network for Interactive Interactive Question Answering_KDD2017

Example 2:Dynamic Attention Deep Model for Article Recommendation by Learning Human Editors’ Demonstration_KDD2017

2.2 Concatenation-based Attention

具体我们来举几个例子,可能具体实现上,有略微区别,不过都大同小异:

Example 1:Attentive Collaborative Filtering Multimedia Recommendation with Item- and Component-Level Attention_sigir17

Example 3:Dipole Diagnosis Prediction in Healthcare via Attention-based Bidirectional Recurrent Neural Network_2017KDD

Example 4:Enhancing Recurrent Neural Networks with Positional Attention for Question Answering_SIGIR2017

Example 5:Learning to Generate Rock Descriptions from Multivariate Well Logs with Hierarchical Attention_2017KDD

Example 6:Reasoning about entailment with neural attention_ICLR2016

看到这里相信大家对于attention有了较为直观的感觉,其实套路都差不太多,看各家paper给出的公式也都差不多,具体是结合问题,怎么去设计这个attention向量,怎么去说故事罢了

3
Attention的扩展(多层attention,常见的是2层)


这里举几个例子(不具体展开讲公式),比如:

Example 1:A Context-aware Attention Network for Interactive Interactive Question Answering_KDD2017

Example 2:Leveraging Contextual Sentence Relations for Extractive Summarization Using a Neural Attention Model_SIGIR2017


Example 3: Learning to Generate Rock Descriptions from Multivariate Well Logs with Hierarchical Attention_2017KDD

Example 4:Attentive Collaborative Filtering Multimedia Recommendation with Item- and Component-Level Attention_sigir17

4
总结


目前来看,attention的套路还是很固定的,主要的关键点是如何结合具体问题,设计出你想要关心的attention,既ht,然后将ht加入到model中去,作为计算score的依据。

posted @ 2020-05-25 14:38  Le1B_o  阅读(700)  评论(0编辑  收藏  举报