We develop a formal hierarchy of the expressive capacity of RNN architectures. The hierarchy is based on two formal properties: space complexity, which measures the RNN's memory, and rational recurrence, defined as whether the recurrent update can be described by a weighted finite-state machine. We place several RNN variants within this hierarchy. For example, we prove the LSTM is not rational, which formally separates it from the related QRNN (Bradbury et al., 2016). We also show how these models' expressive capacity is expanded by stacking multiple layers or composing them with different pooling functions. Our results build on the theory of saturated RNNs (Merrill, 2019). While formally extending these findings to unsaturated RNNs is left to future work, we hypothesize that the practical learnable capacity of unsaturated RNNs obeys a similar hierarchy. Experimental findings from training unsaturated networks on formal languages support this conjecture. While neural networks are central to the performance of today's strongest NLP systems, theoretical understanding of the formal properties of different kinds of networks is still limited. It is established, for example, that the Elman (1990) RNN is Turing-complete, given infinite precision and computation time (Siegelmann and Sontag, 1992, 1994; Chen et al., 2018). But tightening these unrealistic assumptions has serious implications for expressive power (Weiss et al., 2018), leaving a sig-nificant gap between classical theory and practice, which theorems in this paper attempt to address. Recently, Peng et al. (2018) introduced rational RNNs , a subclass of RNNs whose internal state can be computed by independent weighted finite automata (WFAs). Intuitively, such models have a computationally simpler recurrent update than Figure 1: Hierarchy of state expressiveness for saturated RNNs and related models. conventional models like long short-term memory networks (LSTMs; Hochreiter and Schmidhuber, 1997). Empirically, rational RNNs like the quasi-recurrent neural network (QRNN; Bradbury et al., 2016) and unigram rational RNN (Dodge et al., 2019) perform comparably to the LSTM, with a smaller computational budget. Still, the underlying simplicity of rational models raises the question of whether their expressive power is fundamentally limited compared to other RNNs. In a separate line of work, Merrill (2019) introduced the saturated RNN 1 as a formal model for analyzing the capacity of RNNs. A saturated RNN is a simplified network where all activation functions have been replaced by step functions. The saturated network may be seen intuitively as a sta-ble version of its original RNN, in which the in-1 Originally referred to as the asymptotic RNN . ternal activations act discretely. A growing body of workincluding this paperfinds that the saturated theory predicts differences in practical learnable capacity for various RNN architectures (Weiss et al., 2018; Merrill, 2019; Suzgun et al., 2019a). We compare the expressive power of rational and non-rational RNNs, distinguishing between state expressiveness (what kind and amount of information the RNN states can capture) and language expressiveness (what languages can be recognized when the state is passed to a classifier). To do this, we build on the theory of saturated RNNs. State expressiveness We introduce a unified hierarchy (Figure 1) of the functions expressible by the states of rational and non-rational RNN encoders. The hierarchy is defined by two formal properties: space complexity, which is a measure of network memory, 2 and rational recurrence, whether the internal structure of the RNN can be described by WFAs. The hierarchy reveals concrete differences between LSTMs and QRNNs, and further separates both from a class containing convolutional neural networks (CNNs, Lecun and Bengio, 1995; Kim, 2014), Elman RNNs, and gated recurrent units (GRU; Cho et al., 2014). We provide the first formal proof that LSTMs can encode functions that rational recurrences cannot. On the other hand, we show that the saturated Elman RNN and GRU are rational recurrences with constant space complexity, whereas the QRNN has unbounded space complexity. We also show that an unrestricted WFA has rich expressive power beyond any saturated RNN we considerincluding the LSTM. This difference potentially opens the door to more expressive RNNs incorporating the computational efficiency of rational recurrences. Language expressiveness When applied to clas-sification tasks like language recognition, RNNs are typically combined with a decoder: additional layer(s) that map their hidden states to a prediction. Thus, despite differences in state expressiveness, rational RNNs might be able to achieve comparable empirical performance to non-rational RNNs on NLP tasks. In this work, we consider the setup in which the decoders only view the final hidden state of the RNN. 3 We demonstrate that 2 Space complexity measures the number of different configurations an RNN can reach as a function of input length. Formal definition deferred until Section 2. 3 This is common, but not the only possibility. a sufficiently strong decoder can overcome some of the differences in state expressiveness between different models. For example, an LSTM can recognize a n b n with a single decoding layer, whereas a QRNN provably cannot until the decoder has two layers. However, we also construct a language that an LSTM can recognize without a decoder, but a QRNN cannot recognize with any decoder. Thus, no decoder can fully compensate for the weakness of the QRNN compared to the LSTM. Experiments Finally, we conduct experiments on formal languages, justifying that our theorems correctly predict which languages unsaturated recognizers trained by gradient descent can learn. Thus, we view our hierarchy as a useful formal tool for understanding the relative capabilities of different RNN architectures. Roadmap We present the formal devices for our analysis of RNNs in Section 2. In Section 3 we develop our hierarchy of state expressiveness for single-layer RNNs. In Section 4, we shift to study RNNs as language recognizers. Finally, in Section 5, we provide empirical results evaluating the relevance of our predictions for unsaturated RNNs. In this work, we analyze RNNs using formal models from automata theoryin particular, WFAs and counter automata. In this section, we first define the basic notion of an encoder studied in this paper, and then introduce more specialized formal concepts: WFAs, counter machines (CMs), space complexity, and, finally, various RNN architectures. We view both RNNs and automata as encoders : machines that can be parameterized to compute a set of functions f :    Q k , where  is an input alphabet and Q is the set of rational reals. Given an encoder M and parameters  , we use M  to represent the specific function that the parameterized encoder computes. For each encoder, we refer to the set of functions that it can compute as its state expressiveness . For example, a deterministic finite state acceptor (DFA) is an encoder whose parameters are its transition graph. Its state expressiveness is the indicator functions for the regular languages. Formally, a WFA is a non-deterministic finite automaton where each starting state, transition, and final state is weighted. Let Q denote the set of states,  the alphabet, and Q the rational reals. 4 This weighting is specified by three functions: 1. Initial state weights  : Q  Q 2. Transition weights  : Q    Q  Q 3. Final state weights  : Q  Q The weights are used to encode any string x    : Definition 1 (Path score) . Let  be a path of the form q 0  x 1 q 1  x 2     x t q t through WFA A . The score of  is given by A [  ] =  ( q 0 ) (cid:0)(cid:81) ti =1  ( q i  1 , x i , q i ) (cid:1)  ( q t ) . By ( x ) , denote the set of paths producing x . Definition 2 (String encoding) . The encoding computed by a WFA A on string x is A [ x ] = (cid:80)   ( x ) A [  ] . Hankel matrix Given a function f :    Q and two enumerations ,  of the strings in   , we define the Hankel matrix of f as the infinite matrix [ H f ] ij = f (  i   j ) . where  denotes concatenation. It is sometimes convenient to treat H f as though it is directly indexed by   , e.g. [ H f ]  i , j = f (  i   j ) , or refer to a sub-block of a Hankel matrix, rowand column-indexed by prefixes and suffixes P, S    . The following result relates the Hankel matrix to WFAs: Theorem 1 (Carlyle and Paz, 1971; Fliess, 1974) . For any f :    Q , there exists a WFA that computes f if and only if H f has finite rank. Rational series (Sakarovitch, 2009) For all k  N , f :    Q k is a rational series if there exist WFAs A 1 ,    , A k such that, for all x    and 1  i  k , A i [ x ] = f i ( x ) . We now turn to introducing a different type of encoder: the real-time counter machine (CM; Merrill, 2020; Fischer, 1966; Fischer et al., 1968). CMs are deterministic finite-state machines augmented with finitely many integer counters. While processing a string, the machine updates these counters, and may use them to inform its behavior. We view counter machines as encoders mapping    Z k . For m  N ,   { + ,  , } , let  m denote the function f ( n ) = n  m . Definition 3 (General CM; Merrill, 2020) . A k counter CM is a tuple (cid:104)  , Q, q 0 , u,  (cid:105) with 1. A finite alphabet 2. A finite set of states Q , with initial state q 0 3. A counter update function u :   Q  { 0 , 1 } k  { 0 ,  1 , +0 , +1 } k 4. A state transition function  :   Q  { 0 , 1 } k  Q A CM processes input tokens { x t } nt =1 sequentially. q t +1 =  (cid:16) x t , q t , (cid:126) 1 =0 ( c t ) (cid:17) c t +1 = u (cid:16) x t , q t , (cid:126) 1 =0 ( c t ) (cid:17) ( c t ) , where (cid:126) 1 =0 is a broadcasted zero-check operation, i.e., (cid:126) 1 =0 ( v ) i (cid:44) 1 =0 ( v i ) . In (2) and (3), note that the machine only views the zeroness of each counter, and not its actual value. A general CM's encoding of a string x is the value of its counter vector c t after processing all of x . 1. A CM is  -restricted iff u and  depend only on the current input    . 2. A CM is (  Q ) -restricted iff u and  depend only on the current input    and the current state q  Q . 3. A CM is  w -restricted iff it is (  Q ) restricted, and the states Q are windows over the last w input tokens, e.g., Q =   w . 5 These restrictions prevent the machine from being counter-aware: u and  cannot condition on the counters' values. As we will see, restricted CMs have natural parallels in the realm of rational RNNs. In Subsection 3.2, we consider the relationship between counter awareness and rational recurrence. As in Merrill (2019), we also analyze encoders in terms of state space complexity, measured in bits. Definition 4 (Bit complexity) . An encoder M :    Q k has T ( n ) space iff max  (cid:12) (cid:12) { s M  ( x ) | x    n } (cid:12)(cid:12) = 2 T ( n ) , 5 The states q   <w represent the beginning of the sequence, before w input tokens have been seen. where s M  ( x ) is a minimal representation 6 of M 's internal configuration immediately after x . We consider three asymptotic space complexity classes: (1) , (log n ) , and ( n ) , corresponding to encoders that can reach a constant, polynomial, and exponential (in sequence length) number of configurations respectively. Intuitively, encoders that can dynamically count but cannot use more complex memory like stackssuch as all CMsare in (log n ) space. Encoders that can uniquely encode every input sequence are in ( n ) space. A saturated neural network is a discrete approximation of neural network considered by Merrill (2019), who calls it an asymptotic network. Given a parameterized neural encoder M  ( x ) , we construct the saturated network sM  ( x ) by taking sM  ( x ) = lim N  M N ( x ) (4) where N denotes the parameters  multiplied by a scalar N . This transforms each squashing function (sigmoid, tanh, etc.) to its extreme values (0,  1). In line with prior work (Weiss et al., 2018; Merrill, 2019; Suzgun et al., 2019b), we consider saturated networks a reasonable approximation for analyzing practical expressive power. For clarity, we denote the saturated approximation of an architecture by prepending it with s, e.g., s-LSTM. A recurrent neural network (RNN) is a parameterized update function g  : Q k  Q d x  Q k , where  are the rational-valued parameters of the RNN and d x is the dimension of the input vector. g  takes as input a current state h  Q k and input vector x  Q d x , and produces the next state. Defining the initial state as h 0 = 0 , an RNN can be applied to an input sequence x  ( Q d x )  one vector at a time to create a sequence of states { h t } t | x | , each representing an encoding of the prefix of x up to that time step. RNNs can be used to encode sequences over a finite alphabet x    by first applying a mapping (embedding) e :   Q d x . 6 I.e., the minimal state representation needed to compute M  correctly. This distinction is important for architectures like attention, for which some implementations may retain unusable information such as input embedding order. states h 1 , h 2 , ..., h | x | generated by each RNN on its input is fed as input to the layer above it, and only the first layer receives the original input sequence x    as input. The recurrent update function g can take several forms. The original and most simple form is that of the Elman RNN . Since then, more elaborate forms using gating mechanisms have become popular, among them the LSTM, GRU, and QRNN. Elman RNNs (Elman, 1990) Let x t be a vector embedding of x t . For brevity, we suppress the bias terms in this (and the following) affine operations. We refer to the saturated Elman RNN as the s-RNN The s-RNN has (1) space (Merrill, 2019). LSTMs (Hochreiter and Schmidhuber, 1997) An LSTM is a gated RNN with a state vector h t  Q k and memory vector c t  Q k . 7 f t =  ( W f x t + U f h t  1 ) (6) i t =  ( W i x t + U i h t  1 ) (7) o t =  ( W o x t + U o h t  1 ) (8) c t = tanh( W c x t + U c h t  1 ) (9) c t = f t (cid:12) c t  1 + i t (cid:12) c t (10) h t = o t (cid:12) tanh( c t ) . (11) The LSTM can use its memory vector c t as a regis-ter of counters (Weiss et al., 2018). Merrill (2019) showed that the s-LSTM has (log n ) space. GRUs (Cho et al., 2014) Another kind of gated RNN is the GRU. z t =  ( W z x t + U z h t  1 ) (12) r t =  ( W r x t + U r h t  1 ) (13) u t = tanh (cid:0) W u x t + U u ( r t (cid:12) h t  1 ) (cid:1) (14) h t = z t (cid:12) h t  1 + (1  z t ) (cid:12) u t . (15) Weiss et al. (2018) found that, unlike the LSTM, the GRU cannot use its memory to count dynamically. Merrill (2019) showed the s-GRU has (1) space. 7 With respect to our presented definition of RNNs, the concatenation of h t and c t can be seen as the recurrently updated state. However in all discussions of LSTMs we treat only h t as the LSTM's state', in line with common practice. QRNNs Bradbury et al. (2016) propose QRNNs as a computationally efficient hybrid of LSTMs and CNNs. Let  denote convolution over time, let W z , W f , W o  Q d x  w  k be convolutions with window length w , and let X  Q n  d x denote the matrix of n input vectors. An ifo -QRNN (hence-forth referred to as a QRNN) with window length w is defined by W z , W f , and W o as follows: Z = tanh( W z  X ) (16) F =  ( W f  X ) (17) O =  ( W o  X ) (18) c t = f t (cid:12) c t  1 + i t (cid:12) z t (19) h t = o t (cid:12) c t (20) where z t , f t , o t are respectively rows of Z , F , O . A QRNN Q can be seen as an LSTM in which all uses of the state vector h t have been replaced with a computation over the last w input tokensin this way it is similar to a CNN. The s-QRNN has (log n ) space, as the analysis of Merrill (2019) for the s-LSTM directly applies. Indeed, any s-QRNN is also a (  w )-restricted CM extended with =  1 (set to  1 ) operations. We now turn to presenting our results. In this section, we develop a hierarchy of single-layer RNNs based on their state expressiveness. A set-theoretic view of the hierarchy is shown in Figure 2. Let R be the set of rational series. The hierarchy relates (log n ) space to the following sets:  RR As in Peng et al. (2018), we say that An encoder is rationally recurrent (RR) iff its state expressiveness is a subset of R . RR-hard An encoder is RR-hard iff its state expressiveness contains R . A Turing machine is RR-hard, as it can simulate any WFA. RR-complete Finally, an encoder is RR-complete iff its state expressiveness is equivalent to R . A trivial example of an RR-complete encoder is a vector of k WFAs. The different RNNs are divided between the intersections of these classes. In Subsection 3.1, we prove that the s-LSTM, already established to have (log n ) space, is not RR. In Subsection 3.2, we demonstrate that encoders with restricted counting ability (e.g., QRNNs) are RR, and in Subsection 3.3, we show the same for all encoders with finite state (CNNs, s-RNNs, and s-GRUs). In Subsection 3.4, we demonstrate that none of these RNNs are RR-hard. In Appendix F, we extend this analysis from RNNs to self attention. We find that encoders like the s-LSTMwhich, as discussed in Subsection 2.3, is aware of its current counter valuesare not RR. To do this, we construct f 0 : { a, b }   N that requires counter awareness to compute on strings of the form a  b  , making it not rational. We then construct an s-LSTM computing f 0 over a  b  . Definition 5 (Rectified counting) . f 0 : x (cid:55) (cid:40) # a  b ( x ) if # a  b ( x ) > 0 0 otherwise . Lemma 1. For all f : { a, b }   N , if f ( a i b j ) = f 0 ( a i b j ) for all i, j  N , then f (cid:54) R . Proof. Consider the Hankel sub-block A n of H f with prefixes P n = { a i } i  n and suffixes S n = { b j } j  n . A n is lower-triangular:   0 0 0    1 0 0    2 1 0    ... ... ... ...   . Therefore rank( A n ) = n  1 . Thus, for all n , there is a sub-block of H f with rank n  1 , and so rank( H f ) is unbounded. It follows from Theorem 1 that there is no WFA computing f . Theorem 2. The s-LSTM is not RR. Proof. Assume the input has the form a i b j for some i, j . Consider the following LSTM 8 : i t =  (cid:0) 10 Nh t  1  2 N 1 = b ( x t ) + N (cid:1) (22)  c t = tanh (cid:0) N 1 = a ( x t )  N 1 = b ( x t ) (cid:1) (23) c t = c t  1 + i t  c t (24) h t = tanh( c t ) . (25) Let N   . Then i t = 0 iff x t = b and h t  1 = 0 (i.e. c t  1 = 0 ). Meanwhile,  c t = 1 iff x t = a . The update term becomes i t  c t =   1 if x t = a  1 if x t = b and c t  1 > 0 0 otherwise. (26) For a string a i b j , the update in (26) is equivalent to the CM in Figure 3. Thus, by Lemma 1, the s-LSTM (and the general CM) is not RR. While the counter awareness of a general CM enables it to compute non-rational functions, CMs that cannot view their counters are RR. Theorem 3. Any  -restricted CM is RR. Proof. We show that any function that a  restricted CM can compute can also be computed by a collection of WFAs. The CM update operations (  1 , +0 , +1 , or  0 ) can all be reexpressed in terms of functions r ( x ) , u ( x ) :    Z k to get: c t = r ( x t ) c t  1 + u ( x t ) (27) c t = (cid:80) t i =1 (cid:16)(cid:81) t j = i +1 r ( x j ) (cid:17) u ( x i ) . A WFA computing [ c t ] i is shown in Figure 4. 8 In which f t and o t are set to 1 , such that c t = c t  1 + i t  c t . The WFA in Figure 4 also underlies unigram rational RNNs (Peng et al., 2018). Thus,  -restricted CMs are actually a special case of unigram WFAs. In Appendix A, we show the more general result: Theorem 4. Any (  Q ) -restricted CM is RR. In many rational RNNs, the updates at different time steps are independent of each other outside of a window of w tokens. Theorem 4 tells us this independence is not an essential property of rational encoders. Rather, any CM where the update is conditioned by finite state (as opposed to being conditioned by a local window) is in fact RR. Furthermore, since ( w ) -restricted CMs are a special case of (  Q ) -restricted CMs, Theorem 4 can be directly applied to show that the s-QRNN is RR. See Appendix A for further discussion of this. Theorem 4 motivates us to also think about finite-space encoders: i.e., encoders with no counters where the output at each prefix is fully determined by a finite amount of memory. The following lemma implies that any finite-space encoder is RR: Lemma 2. Any function f :    Q computable by a (1) -space encoder is a rational series. Proof. Since f is computable in (1) space, there exists a DFA A f whose accepting states are isomorphic to the range of f . We convert A f to a WFA by labelling each accepting state by the value of f that it corresponds to. We set the starting weight of the initial state to 1 , and 0 for every other state. We assign each transition weight 1 . Since the CNN, s-RNN, and s-GRU have finite state, we obtain the following result: Theorem 5. The CNN, s-RNN, and s-GRU are RR. While Schwartz et al. (2018) and Peng et al. (2018) showed the CNN to be RR over the max-plus semiring, Theorem 5 shows the same holds for (cid:104) Q ,  , + (cid:105) . While rational recurrence is often used to indicate the simplicity of an RNN architecture, we find in this section that WFAs are surprisingly computationally powerful. Figure 5 shows a WFA mapping binary string to their numeric value, proving WFAs have ( n ) space. We now show that none of our RNNs are able to simulate an arbitrary WFA, even in the unsaturated form. q 0 start q 1  / 1  /u i (  )  /r i (  ) 6. Both the saturated and unsaturated RNN, GRU, QRNN, and LSTM 9 are not RR-hard. Proof. Consider the function f b mapping binary strings to their value, e.g. 101 (cid:55) 5 . The WFA in Figure 5 shows that this function is rational. The value of f b grows exponentially with the sequence length. On the other hand, the value of the RNN and GRU cell is bounded by 1 , and QRNN and LSTM cells can only grow linearly in time. Therefore, these encoders cannot compute f b . In contrast, memory networks can have ( n ) space. Appendix G explores this for stack RNNs. Appendix F presents preliminary results extending saturation analysis to self attention. We show saturated self attention is not RR and consider its space complexity. We hope further work will more completely characterize saturated self attention. Having explored the set of functions expressible internally by different saturated RNN encoders, we turn to the languages recognizable when using them with a decoder. We consider the following setup: 1. An s-RNN encodes x to a vector h t  Q k . 2. A decoder function maps the last state h t to an accept/reject decision, respectively: { 1 , 0 } . 9 As well as CMs. We say that a language L is decided by an encoder-decoder pair e , d if d ( e ( x )) = 1 for every sequence x  L and otherwise d ( e ( x )) = 0 . We explore which languages can be decided by different encoder-decoder pairings. Some related results can be found in Cortes and Mohri (2000), who study the expressive power of WFAs in relation to CFGs under a slightly different definition of language recognition. parameterized by w and b . For an encoder architecture E , we denote by D 1 ( E ) the set of languages decidable by E with d 1 . We use D 2 ( E ) analogously for a 2-layer decoder with 1 > 0 activations, where the first layer has arbitrary width. We refer to sets of strings using regular expressions, e.g. a  = { a i | i  N } . To illustrate the purpose of the decoder, consider the following language: L  = { x  { a, b }  | # a  b ( x )  0 } . The Hankel sub-block of the indicator function for L  over P = a  , S = b  is lower triangular. Therefore, no RR encoder can compute it. However, adding the D 1 decoder allows us to compute this indicator function with an s-QRNN, which is RR. We set the s-QRNN layer to compute the simple series c t = # a  b ( x ) (by increasing on a and decreasing on b ). The D 1 layer then checks c t  0 . So, while the indicator function for L  is not itself rational, it can be easily recovered from a rational representation. Thus, L   D 1 (s-QRNN). We compare the language expressiveness of several rational and non-rational RNNs on the following: a n b n is more interesting than L  because the D 1 decoder cannot decide it simply by asking the encoder to track # a  b ( x ) , as that would require it to compute the non-linearly separable =0 function. Thus, it appears at first that deciding a n b n with D 1 450 might require a non-rational RNN encoder. Let  denote stacking two layers. We will go on to discuss the following results: a n b n  D 1 ( WFA ) (33) a n b n  D 1 ( s-LSTM ) (34) a n b n (cid:54) D 1 ( s-QRNN ) (35) a n b n  D 1 ( s-QRNN  s-QRNN ) (36) a n b n  D 2 ( s-QRNN ) (37) a n b n    D 1 ( s-LSTM ) (38) a n b n   /  D ( s-QRNN ) for any D (39) a n b n    { (cid:15) }  D 1 ( s-QRNN  s-QRNN ) (40) WFAs (Appendix B) In Theorem 8 we present a function f :    Q satisfying f ( x ) > 0 iff x  a n b n , and show that H f has finite rank. It follows that there exists a WFA that can decide a n b n with the D 1 decoder. Counterintuitively, a n b n can be recognized using rational encoders. QRNNs (Appendix C) Although a n b n  D 1 ( WFA ) , it does not follow that every rationally recurrent model can also decide a n b n with the help of D 1 . Indeed, in Theorem 9, we prove that a n b n /  D 1 ( s-QRNN ) , whereas a n b n  D 1 ( s-LSTM ) (Theorem 13). It is important to note that, with a more complex decoder, the QRNN could recognize a n b n . For example, the s-QRNN can encode c 1 = # a  b ( x ) and set c 2 to check whether x contains ba , from which a D 2 decoder can recognize a n b n (Theorem 10). This does not mean the hierarchy dissolves as the decoder is strengthened. We show that a n b n    which seems like a trivial extension of a n b n is not recognizable by the s-QRNN with any decoder. This result may appear counterintuitive, but in fact highlights the s-QRNN's lack of counter awareness: it can only passively encode the information needed by the decoder to recognize a n b n . Failing to recognize that a valid prefix has been matched, it cannot act to preserve that information after additional input tokens are seen. We present a proof in Theorem 11. In contrast, in Theorem 14 we show that the s-LSTM can directly encode an indicator for a n b n   in its internal state. Proof sketch: a n b n   /  D ( s-QRNN ) . A sequence s 1  a n b n   is shuffled to create s 2 /  a n b n   with an identical multi-set of counter updates. 10 Counter updates would be order agnostic if not for reset operations, and resets mask all history, so extending s 1 and s 2 with a single suffix s containing all of their w -grams reaches the same final state. Then for any D , D ( s-QRNN ) cannot separate them. We formalize this in Theorem 11. We refer to this technique as the suffix attack , and note that it can be used to prove for multiple other languages L  D 2 ( s-QRNN ) that L    is not in D ( s-QRNN ) for any decoder D . 2-layer QRNNs Adding another layer overcomes the weakness of the 1-layer s-QRNN, at least for deciding a n b n . This follows from the fact that a n b n  D 2 ( s-QRNN ) : the second QRNN layer can be used as a linear layer. Similarly, we show in Theorem 10 that a 2-layer s-QRNN can recognize a n b n    { (cid:15) } . This suggests that adding a second s-QRNN layer compensates for some of the weakness of the 1-layer s-QRNN, which, by the same argument for a n b n   cannot recognize a n b n    { (cid:15) } with any decoder. Finally, we study the theoretical case where the decoder is an arbitrary recursively enumerable (RE) function. We view this as a loose upper bound of stacking many layers after a rational encoder. What information is inherently lost by using a rational encoder? WFAs can uniquely encode each input, making them Turing-complete under this setup; however, this does not hold for rational s-RNNs. RR-complete Assuming an RR-complete encoder, a WFA like Figure 5 can be used to encode each possible input sequence over  to a unique number. We then use the decoder as an oracle to decide any RE language. Thus, an RR-complete encoder with an RE decoder is Turing-complete. Bounded space However, the (log n ) space bound of saturated rational RNNs like the s-QRNN means these models cannot fully encode the input. In other words, some information about the prefix x : t must be lost in c t . Thus, rational s-RNNs are not Turing-complete with an RE decoder. 10 Since QRNN counter updates depend only on the w grams present in the sequence. these predictions carry over to the learnable capacity of unsaturated RNNs. 11 We compare the QRNN and LSTM when coupled with a linear decoder D 1 . We also train a 2 -layer QRNN (QRNN2) and a 1 -layer QRNN with a D 2 decoder (QRNN+). We train on strings of length 64 , and evaluate generalization on longer strings. We also compare to a baseline that always predicts the majority class. The results are shown in Figure 6. We provide further experimental details in Appendix E. Experiment 1 We use the following language, which has similar formal properties to a n b n , but with a more balanced label distribution: L 5 = (cid:8) x  ( a | b )  | | # a  b ( x ) | < 5 (cid:9) . In line with (34), the LSTM decides L 5 perfectly for n  64 , and generalizes fairly well to longer strings. As predicted in (35), the QRNN cannot fully learn L 5 even for n = 64 . Finally, as predicted in (36) and (37), the 2 -layer QRNN and the QRNN with D 2 do learn L 5 . However, we see that they do not generalize as well as the LSTM for longer strings. We hypothesize that these multi-11 https://github.com/viking-sudo-rm/ rr-experiments layer models require more epochs to reach the same generalization performance as the LSTM. Experiment 2 We also consider a n b n   . As predicted in (38) and (40), the LSTM and 2 -layer QRNN decide a n b n   flawlessly for n = 64 . A 1 -layer QRNN performs at the majority baseline for all n with both a 1 and 2 -layer decoder. Both of these failures were predicted in (39). Thus, the only models that learned a n b n   were exactly those predicted by the saturated theory. We develop a hierarchy of saturated RNN encoders, considering two angles: space complexity and rational recurrence. Based on the hierarchy, we formally distinguish the state expressiveness of the non-rational s-LSTM and its rational counterpart, the s-QRNN. We show further distinctions in state expressiveness based on encoder space complexity. Moreover, the hierarchy translates to differences in language recognition capabilities. Strengthening the decoder alleviates some, but not all, of these differences. We present two languages, both recognizable by an LSTM. We show that one can be recognized by an s-QRNN only with the help of a decoder, and that the other cannot be recognized by an s-QRNN with the help of any decoder. While this means existing rational RNNs are fundamentally limited compared to LSTMs, we find that it is not necessarily being rationally recurrent that limits them: in fact, we prove that a WFA can perfectly encode its inputsomething no saturated RNN can do. We conclude with an analysis that shows that an RNN architecture's strength must also take into account its space complexity. These results further our understanding of the inner working of NLP systems. We hope they will guide the development of more expressive rational RNNs. We appreciate Amir Yehudayoff's help in finding the WFA used in Theorem 8, and the feedback of researchers at the Allen Institute for AI, our anonymous reviewers, and Tobias Jaroslaw. The project was supported in part by NSF grant IIS-1562364, Israel Science Foundation grant no.1319/16, and the European Research Council under the EU's Horizon 2020 research and innovation program, grant agreement No. 802774 (iEXTRACT).
objective abstain abstain abstain result result objective abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method method abstain abstain abstain objective result result abstain abstain abstain method objective abstain abstain abstain abstain method abstain method abstain method objective method result method abstain method method method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method method abstain abstain abstain method abstain abstain abstain method abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain other abstain abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain method abstain abstain abstain abstain method method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain method method abstain abstain abstain method abstain abstain abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain method abstain abstain abstain abstain method abstain abstain abstain abstain method abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain result other abstain abstain abstain abstain abstain objective abstain result abstain abstain method result result result result abstain other other