周五推送的《Applied Attention-Based Models in NLP》(回复代码:GH021)引起了许多同学的讨论。其实那次的总结并不是很完整,只是选了一些代表性的论文。今天再给大家带来三篇 Attention Mechansim 相关论文,但这次并不完全是 in NLP。选入非 NLP(非小S 擅长领域)的论文是有特别的考虑,因为它“超越”了 Attention!详情见下。
第一篇,《Teaching Machines to Read and Comprehend》,来自 Google DeepMind 团队。很早就放在了 arXiv 上,前天已经被 NIPS 2015 accepted。这篇论文有两个主要贡献,个人觉得最大的贡献还是在于构造了一个 supervised document-query based 的数据集,虽然说是供 machine comprehend 使用,其实依然没有超过 QA 范畴,就是基于一篇 document,一个 query(document-query pair)回答一个 entity form 的 answer。数据集在此不表。来看他们 attention-based 的相关 model。
论文一共提出三个新 model,其中只有后两个(图中 (a)(b))是 attention-based 的。input 都是一个 document query pair。作者尝试了两种机制,一种是 document 按一小段句子(以标点分割)输入,一小段句子+一个query,这样算一次输入;另一种是一篇 document 全部输入完毕再输入 query,这种方法被认为失去了 query 的 mention 作用。
两个 attention-based model,(a) Attentive Reader 和 (b) Impatient Reader。(a) 非常好理解,看 (a) 左边就是标准的 attention mechanism 的结构啊,对比一下:
再看 (b) Impatient Reader,这个 model 很有趣,尤其和我下面想说的非 NLP 那篇有点像。我按我的理解来解读,这个 model 强调“reread”,就是说,对于每一个 query,有许多个 token,按照 query token 一个个输入,每一个 query token(不再是每一个 query),就都读一遍 document,然后下一个 token,再来一遍——reread。
我会把这种 reread 机制,理解为一种“逐渐”获取(理解)文章的过程,就像我们读一篇艰深的文章,读一遍不成,读两遍,读三遍。这个机制的 motivation 很好,但是如果只用来预测一个 token(the answer),我会认为起不到 motivation 的作用。个人理解。
来看第二篇,第二篇应该是上面 Impatient Reader model 的源泉。依然来自 Google DeepMind 团队,arXiv 文章《DRAW:A Recurrent Neural Network For Image》。开源!有代码!
文章简直写的不能再好,强烈推荐,强烈推荐,强烈推荐!文章开篇就用短短三行解释了 motivation:
A person asked to draw, paint or otherwise recreate a visual scene will naturally do so in a sequential, iterative fashion, reassessing their handiwork after each modification. Rough outlines are gradually replaced by precise forms, lines are sharpened, darkened or erased, shapes are altered, and the final picture emerges.
啥意思,我们人类画画不是一次到位的!要不断的修正,一遍遍的完善细节啊等等。所以呢,为啥我们要求 NN 一步到位的给我们 generate 出一幅完整(entire)的图?这!不!科!学!(汗,画风不太对了,我严谨一点)于是乎,作者就想模拟这个一遍遍的过程。每次我们只画一丢丢,只着重于某一个 part——然后大家就说了,你这个不新鲜啊,attention mechanism 不是也这个意思么,但是 attention model 是啥呢,是在 decode 的过程中,最后的过程中,再去决定,而不是在反复画的过程中:
The main challenge faced by sequential attention models is learning where to look, which can be addressed with reinforcement learning techniques such as policy gradients (Mnih et al. , 2014 ). The attention model in DRAW, however, is fully differentiable, making it possible to train with standard backpropagation. In this sense it resembles the selective read and write operations developed
for the Neural Turing Machine.
所以他们就提出了这个 DRAW——Deep Recurrent Attentive Writer 的 model。recurrent 表示一遍遍去“修正”完善,attentive 表示每次只着重于某个 part。而且文章不仅配图丰富(在许多个图像数据集如 MINST 上做了实验),还有视频套餐(地址见论文)。视频中可以动态的看出,这个 DRAW 是如何把一个个 digit “写”出来的。
第三篇,EMNLP'15 《Not All Contexts Are Created Equal: Better Word Representations with Variable Attention》,来自 CMU Wang Ling。先说下作者,作者今年有许多篇改进 word2vec 模型的文章,其中 NAACL'15 的一篇也给我印象深刻(还是开源的,我自己也跑了代码,效果不错)《Two/Too Simple Adaptations of Word2Vec for Syntax Problems》。先简单说下《Two/Too》这篇,文章主张用 word order information 去 induce syntactically-motivated embeddings,这个思想其实很像著名的 dependency-based word embeddings,但用的信息不一样。word order information 的巧妙之处是,直接把 word2vec 两个 model 中的 average/concatenate 的 function 改成保留位置信息的(参数变多)就可以了。
但是接下来就是问题了。参数成倍的涨(基本和 window size 成正比),复杂度也就成倍的涨,运行时间也是。而作者 EMNLP'15 这篇中的模型就可以改进这个问题。
作者提出了 Attention-Based CBOW,比如上图,预测中心词 south,越深颜色的 context words 对于预测越重要——越应该 attend。什么样的词颜色应该越深越有用呢?作者很简单的选择了 word type 和 distance(relative position) 的信息——其实也算是一种对于 dependency parsing 的简化。然后就是很简单的把 CBOW 的 average of contexts words 变成 attention-based 了(weighted sum)。Simple again!
鉴于干货内容越来越多,我们也在考虑将格式不友好的微信公众号内容不定期按专题整理成更优美的格式供大家下载,欢迎大家帮我们提一些建议。谢谢大家!