版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Ordered MemoryYikang ShenMila/Universite de Montreal and Microsoft Research Montreal, CanadaShawn Tan Mila/Universite de Montreal Montreal, CanadaSeyedarian Hosseini Mila/Universite de Montreal and Microsoft Research Montreal, CanadaZhouhan Lin Mila/Universite de Montreal Montreal, CanadaAlessandro
2、Sordoni Microsoft Research Montreal, CanadaAaron Courville Mila/Universite de Montreal Montreal, CanadaAbstractStack-augmented recurrent neural networks (RNNs) have been of interest to the deep learning community for some time. However, the difficulty of training mem- ory models remains a problem ob
3、structing the widespread use of such models. In this paper, we propose the Ordered Memory architecture. Inspired by Or- dered Neurons (Shen et al., 2018), we introduce a new attention-based mechanism and use its cumulative probability to control the writing and erasing operation of memory. We also i
4、ntroduce a new Gated Recursive Cell to compose lower level representations into higher level representation. We demonstrate that our model achieves strong performance on the logical inference task (Bowman et al., 2015) and the ListOps (Nangia and Bowman, 2018) task. We can also interpret the model t
5、o retrieve the induced tree structure, and find that these induced structures align with the ground truth. Finally, we evaluate our model on the Stanford Sentiment Treebank tasks (Socher et al., 2013), and find that it performs comparatively with the state-of-the-art methods in the literature2.1 Int
6、roductionA long-sought after goal in natural language processing is to build models that account for the com- positional nature of language granting them an ability to understand complex, unseen expressions from the meaning of simpler, known expressions (Montague, 1970; Dowty, 2007). Despite being s
7、uccessful in language generation tasks, recurrent neural networks (RNNs, Elman (1990) fail at tasks that explicitly require and test compositional behavior (Lake and Baroni, 2017; Loula et al., 2018). In particular, Bowman et al. (2015), and later Bahdanau et al. (2018) give evidence that, by exploi
8、ting the appropriate compositional structure of the task, models can generalize better to out-of-distribution test examples. Results from Andreas et al. (2016) also indicate that recursively composing smaller modules results in better representations. The remaining challenge, however, is learning th
9、e underlying structure and the rules governing composition from the observed data alone. This is often referred to as the grammar induction (Chen, 1995; Cohen et al., 2011; Roark, 2001; Chelba and Jelinek, 2000; Williams et al., 2018).Fodor and Pylyshyn (1988) claim that “cognitive capacities always
10、 exhibit certain symmetries, so that the ability to entertain a given thought implies the ability to entertain thoughts with seman- tically related contents,” and use the term systematicity to describe this phenomenon. Exploiting yi-kang.shenumontreal.ca, tanjingsmila.quebec, arian.hosseini9gmail.co
11、m.2The code can be found at /yikangshen/Ordered-Memory33rd Conference on Neural Information Processing Systems (NeurIPS 2019), Vancouver, Canada.known symmetries in the structure of the data has been a useful technique for achieving good gener- alization capabilities in deep learnin
12、g, particularly in the form of convolutions (Fukushima, 1980), which leverage parameter-sharing. If we consider architectures used in Socher et al. (2013) or Tai et al. (2015), the same recursive operation is performed at known points along the input where the substructures are meant to be composed.
13、 Could symmetries in the structure of natural language data be learned and exploited by models that operate on them?In recent years, many attempts have been made in this direction using neural network architec- tures (Grefenstette et al., 2015; Bowman et al., 2016; Williams et al., 2018; Yogatama et
14、 al., 2018; Shen et al., 2018; Dyer et al., 2016). These models typically augment a recurrent neural network with a stack and a buffer which operate in a similar way to how a shift-reduce parser builds a parse-tree. While some assume that ground-truth trees are available for supervised learning (Bow
15、man et al., 2016; Dyer et al., 2016), others use reinforcement learning (RL) techniques to learn the optimal sequence of shift reduce actions in an unsupervised fashion (Yogatama et al., 2018).To avoid some of the challenges of RL training (Havrylov et al., 2019), some approaches use a con- tinuous
16、stack (Grefenstette et al., 2015; Joulin and Mikolov, 2015; Yogatama et al., 2018). These can usually only perform one push or pop action per time step, requiring different mechanisms akin to adaptive computation time (ACT, Graves (2016); Jernite et al. (2016) to perform the right number of shift an
17、d reduce steps to express the correct parse. In addition, continuous stack mod- els tend to “blur” the stack due to performing a “soft” shift of either the pointer to the head of the stack (Grefenstette et al., 2015), or all the values in the stack (Joulin and Mikolov, 2015; Yogatama et al., 2018).
18、Finally, while these previous models can learn to manipulate a stack, they lack the capability to lookahead to future tokens before performing the stack manipulation for the current time step.In this paper, we propose a novel architecture: Ordered Memory (OM), which includes a new mem- ory updating
19、mechanism and a new Gated Recursive Cell. We demonstrate that our method general- izes for synthetic tasks where the ability to parse is crucial to solving them. In the Logical inference dataset (Bowman et al., 2015), we show that our model can systematically generalize to unseen com- bination of op
20、erators. In the ListOps dataset (Nangia and Bowman, 2018), we show that our model can learn to solve the task with an order of magnitude less training examples than the baselines. The parsing experiments shows that our method can effectively recover the latent tree structure of the both tasks with v
21、ery high accuracy. We also perform experiments on the Stanford Sentiment Treebank, in both binary classification and fine-grained settings (SST-2 & SST-5), and find that we achieve comparative results to the current benchmarks.2 Related WorkComposition with recursive structures has been shown to wor
22、k well for certain types of tasks. Pol- lack (1990) first suggests their use with distributed representations. Later, Socher et al. (2013) shows their effectiveness on sentiment analysis tasks. Recent work has demonstrated that recursive composition of sentences is crucial to systematic generalisati
23、on (Bowman et al., 2015; Bahdanau et al., 2018). Kuncoro et al. (2018) also demonstrate that architectures like Dyer et al. (2016) handle syntax-sensitive dependencies better for language-related tasks.Schutzenberger (1963) first showed an equivalence between push-down automata (stack-augmented auto
24、matons) and context-free grammars. Knuth (1965) introduced the notion of a shift-reduce parser that uses a stack for a subset of formal languages that can be parsed from left to right. This technique for parsing has been applied to natural language as well: Shieber (1983) applies it to English, usin
25、g assumptions about how native English speakers parse sentences to remove ambiguous parse candi- dates. More recently, Maillard et al. (2017) shows that a soft tree could emerge from all possible tree structures through back propagation.The idea of using neural networks to control a stack is not new
26、. Zeng et al. (1994) uses gradient estimates to learn to manipulate a stack using a neural network. Das et al. (1992) and Mozer and Das (1993) introduced the notion of a continuous stack in order for the model to be fully differ- entiable. Much of the recent work with stack-augmented networks built
27、upon the development of neural attention (Graves, 2013; Bahdanau et al., 2014; Weston et al., 2014). Graves et al. (2014) proposed methods for reading and writing using a head, along with a “soft” shift mechanism. Apart from using attention mechanisms, Grefenstette et al. (2015) proposed a neural st
28、ack where the push6Figure 1: An example run of the OM model. Let the input sequence a, b, c, d, e and its hierarchical structure be as shown in the figure. Ideally, the OM model will output the values shown in the above tables. The occupied slots in Mt are highlighted in gray. The yellow slots in Mt
29、 are slots that can be attended on in time-step t + 1. At the first time-step (t = 1), the model will initialize the candidate memory M1 with input a and the memory M0 with zero vectors. At t = 2, the model attends on the last memory slot to compute M1 (Eqn. 5), followed by M2 (Eqn. 7). At t = 3, gi
30、ven theinput c, the model will attend on the last slot. Consequently the memory slot for b is erased by 3.cell( ) function only takes 2 inputs, the acttualGinicvleundeEiqnnfso.rm6 atnidon7,frooumr mMoide1l wanildl rMeciursi.vSeilnycceotmhepute ev ery slot in the candidate memory M i totcomputation g
31、raph is a binary tree.t1and pop operations are made to be differentiable, which worked well in synthetic datasets. Yo- gatama et al. (2016) proposes RL-SPINN where the discrete stack operations are directly learned by reinforcement learning.3 ModelThe OM model actively maintains a stack and processe
32、s the input from left to right, with a one-step lookahead in the sequence. This allows the OM model to decide the local structure more accurately, much like a shift-reduce parser (Knuth, 1965).At a given point t in the input sequence x (the t-th time-step), we have a memory of candidate sub-trees sp
33、anning the non-overlapping sub-sequences in x1, . . . , xt1, with each sub-tree being represented by one slot in the memory stack. We also maintain a memory stack of sub-trees that contains x1, . . . , xt2. We use the input xt to choose its parent node from our previous candidate sub-trees. The desc
34、endant sub-trees of this new sub-tree (if they exist) are removed from the memorystack, and this new sub-tree is then added. We then build the new candidate sub-trees that include xt using the current input and the memory stack. In what follows, we describe the OM model in detail. To facilitate a cl
35、earer description, a discrete attention scheme is assumed, but only “soft” attention is used in both the training and evaluation of this model.Let D be the dimension of each memory slot and N be the number of memory slots. At time-step t, the model takes four inputs: Mt1: a memory matrix of dimensio
36、n N D, where each occupied slot is a distributedrepresentation for sub-trees spanning the non-overlapping subsequences in x1, .,xt2; Mt1: a matrix of dimension N D that contains representations for candidate subtrees that include the leaf node xt1; t1: a vector of dimension N , where each element in
37、dicate whether the respective slotin Mt1 occupied by a subtree. xt: a vector of dimension Din, the input at time-step t.The model first transforms xt to a D dimension vector.xt = LN (Wxt + b)(1)where LN () is the layer normalization function (Ba et al., 2016).To select the candidate representations
38、from Mt1, the model uses xt as its query to attend on Mt1:pt = Att(xt, Mt1, t1)(2)t i =ti =j tpjipj tji(3)(4)where Att() is a masked attention function, t1 is the mask, pt is a distribution over differentmemory slots in Mt1, and pj is the probability on the j-th slot. The attention mechanism will be
39、tdescribed in section 3.1. Intuitively, pt can be viewed as a pointer to the head of the stack, t is anindicator value over where the stack exists, and t is an indicator over where the top of the stack is and where it is non-existent.To compute Mt, we combine Mt1 and Mt1 through:t1t1ttM i = M i (1 )
40、i + M i i,i(5)Suppose pt points at a memory slot yt in m .Then t will write M i 1 to M ifor i y ,tData: x , ., x itt1TtoiNand (1 t) will write Mt1Mt for i yt.Result: oTIn other words, Eqn. 5 copies everything from Mt1 to the current timestep, up to the where pt is pointing.We believe that this is a
41、crucial point that differ-initialize M0, M0;for i1 to T doxt = LN (Wxt + b);pt = APtt(xt, Mt1, t1);entiates our model from past stack-augmented i =ji pj;models like Yogatama et al. (2016) and JoulintPtttand Mikolov (2015). Both constructions havei =ji pj;the 0-th slot as the top of the stack, and pe
42、rform a convex combination of each slot in the mem-ory / stack given the action performed. More concretely, a distribution over the actions thatM 0 = xt;tfor i 1 to N dot1t1ttM i = M i (1 t)i + M i i;t(1 t)+ o ;oi = cell(M i, M i1);is not sharp (e.g. 0.5 for pop) will result inMt i = x tt ii ia weig
43、hted sum of an un-popped stack and a pop stack, resulting in a blurred memory state.Compounded, this effect can make suchmodelsend endttthard to train. In our case, because (1 t)i is non-decreasing with i, its value will accumulateto 1 at or before N . This results in a full copy, guaranteeing that
44、the earlier states are retained. This full retention of earlier states may play a part in the training process, as it is a strategy also used in Gulcehre et al. (2017), where allreturn oN;TAlgorithm 1: Ordered Memory algorithm. Theattention function Att() is defined in section 3.1. The recursive cel
45、l function cell( ) is defined in section 3.2.the memory slots are filled before any erasing or writing takes place.To compute candidate memories for time step t, we recurrently update all memory slots withoi = cell(M i, M i1)(6)tttttM i = xt (1 t)i+1 + oi i, i(7)twhere M 0 is xt. The cell() function
46、 can be seen as a recursive composition function in a recursive neural network (Socher et al., 2013). We propose a new cell function in section 3.2.tThe output of time step t is the last memory slot M N of the new candidate memory, which summa- rizes all the information from x1, ., xt using the indu
47、ced structure. The pseudo-code for the OM algorithm is shown in Algorithm 1.3.1 Masked Attentiont1t1Given the projected input xt and candidate memory M i. We feed every (xt, M i) pair into afeed-forward network:wAtt tanh WAtt M i+ b + b21ti=Nt1xt1 2(8)ttjti= exp i max j(9)where WAtt is N 2N matrix,
48、wAtt is N dimension vector, and the output i is a scalar. The1 2tpurpose of dividing byN is to scale down the logits before softmax is applied, a technique similar to the one seen in Vaswani et al. (2017). We further mask the t with the cumulative probability from the previous time step to prevent t
49、he model attending on non-existent parts of the stack:i = i i+1(10)ttt1where N+1 = 1 and N = 0. We can then compute the probability distribution:t10ipi(11)t = t P jj tThis formulation bears similarity to the method used for the multi-pop mechanism seen in Yogatamaet al. (2018).3.2 Gated Recursive Ce
50、llInstead of using the recursive cell proposed in TreeLSTM (Tai et al., 2015) and RNTN (Socheret al., 2010), we propose a new gated recursive cell, whichiis1 inspired by the feed-forward layer inTransformer (Vaswani et al., 2017). The inputs M i and Mttare concatenated and fed into a fullyconnect fe
51、ed-forward network:ivtii1ht = WCell ReLU WCell Mt+ b1 + b2(12)i21M ittuic ttLike the TreeLSTM, we compute the output with a gated combination of the inputs and ui:tttttttoi = LN (vi) M i1 + (hi) M i + (ci) ui)(13) where vi is the vertical gate that controls the input from previous slot, hi is horizo
52、ntal gate that controlstthe input from previous time step, cgi is cell gate that control the uti, oi is the output of celltttfunction, and LN () share the same parameters with the one used in the Eqn. 1.3.3 Relations to ON-LSTM and Shift-reduce ParserOrdered Memory is implemented following the princ
53、iples introduced in Ordered Neurons (Shen et al., 2018). Our model is related to ON-LSTM in several aspects: 1) The memory slots are simi- lar to the chunks in ON-LSTM, when a higher ranking memory slot is forgotten/updated, all lower ranking memory slots should likewise be forgotten/updated; 2) ON-
54、LSTM uses the monotonicallynon-decreasing master forget gate to preserve long-term information while erasing short term in-formation, the OM model uses the cumulative probability t; 3) Similarly, the master input gateused by ON-LSTM to control the writing of new information into the memory is replac
55、ed with the reversed cumulative probability t in the OM model.At the same time, the internal mechanism of OM can be seen as a continuous version of a shift- reduce parser.At time step t, a shift-reduce parser could perform zero or several reduce stepsto combine the heads of stack, then shift the wiord1 t into stack. The OM implement the reducestep with Gated Recursive Cell. It combines M, the output of previous reduce step, and M i,ttTable 1: Test accuracy of the models, trained on operation lengths of 6, with their out-of- distributi
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 河南省新乡市2025-2026学年高考仿真模拟历史试卷含解析
- 2025-2026学年甘肃省兰州市高三下学期联考历史试题含解析
- 2026品质道德面试题目及答案
- 2026前端运营面试题及答案
- 2026权益部面试题及答案
- 2026深圳电子厂面试题及答案
- 校外基地劳动合同范本
- 股东撤销协议书范本
- 离婚要几份协议书
- 赊销协议书范本
- 城市固废综合处理生活垃圾焚烧发电项目可行性研究报告模板-拿地备案
- 2026大唐环境产业集团股份有限公司新能源设计高层次专业人才招聘7人笔试历年难易错考点试卷带答案解析
- 安徽县域高中联盟2025-2026学年高一上学期期末自测地理试题(含答案)
- 高脂血症胰腺炎护理总结2026
- 旅游景区旅游营销策划方案
- DB3301-T 65.11-2024 反恐怖防范系统管理规范 第11部分:医院
- 2024年新人教版九年级上册化学教学课件 1.2.2 物质的加热 仪器的洗涤
- 幼儿一日生活皆教育
- 重大危险源(专项)施工方案
- 黔西南中药材教学大纲
- 中建履约过程风险发函时点提示及函件指引(2023年)
评论
0/150
提交评论