N EURAL S PEED R EADING VIA S KIM -RNN
Anonymous authors
Paper under double-blind review
A BSTRACT
Inspired by the principles of speed reading, we introduce Skim-RNN, a recurrent neural network (RNN) that dynamically decides to update only a small fraction of the hidden state for relatively unimportant input tokens.
Skim-RNN gives signiﬁcant computational advantage over an RNN that always updates the entire hidden state.
Skim-RNN uses the same input and output interfaces as a standard RNN and can be easily used instead of RNNs in existing models.
In our experiments, we show that Skim-RNN can achieve signiﬁcant reduced computational cost without losing accuracy compared to standard RNNs across ﬁve different natural language tasks.
In addition, we demonstrate that the trade-off between accuracy and speed of Skim-RNN can be dynamically controlled during inference time in a stable manner.
Our analysis also show that Skim-RNN running on a single CPU offers lower latency compared to standard RNNs on GPUs.
I NTRODUCTION
Recurrent neural network (RNN) is a predominantly popular architecture for modeling natural language, where RNN sequentially ‘reads’ input tokens and outputs a distributed representation for each token.
By recurrently updating the hidden state with an identical function, RNN inherently requires the same computational cost across time.
While this requirement seems natural for some application domains, not all input token are equally important in many language processing tasks.
For instance, in question answering, a rather efﬁcient strategy would be to allocate less computation on irrelevant parts of the text (to the question) and only allow heavy computation on important parts.
Attention models (Bahdanau et al., 2014) compute the importance of the words relevant to the given task using an attention mechanism.
They, however, do not focus on improving the efﬁciency of the inference.
More recently, a variant of LSTMs (Yu et al., 2017) is introduced to improve inference efﬁciency through skipping multiple tokens at a given time step.
In this paper, we introduce skimRNN that takes advantage of ‘skimming’ rather than ‘skipping’ tokens.
Skimming refers to the ability to decide to spend little time (rather than skipping) on parts of the text that does not affect the reader’s main objective.
Skimming typically gains trained human peed readers up to 4x speed up, occasionally with a bit of loss in the comprehension rates (Marcel Adam Just, 1987).
Inspired by the principles of human’s speed reading, we introduce Skim-RNN (Figure 1), which makes a fast decision on the signiﬁcance of each input (to the downstream task) and ‘skims’ through unimportant input tokens by using a smaller RNN to update only a fraction of the hidden state.
When the decision is to ‘fully read’, Skim-RNN updates the entire hidden state with the default RNN cell.
Since the hard decision function (‘skim’ or ‘read’) is non-differentiable, we use gumbel-softmax (Jang et al., 2017) to estimate the gradient of the function, instead of more traditional methods such as
REINFORCE (policy gradient) (Williams, 1992).
The switching mechanism between the two RNN cells enables Skim-RNN to reduce the total number of ﬂoat operations (Flop reduction, or Flop-R) when the skimming rate is high, which often leads to faster inference on CPUs 1 , a highly desirable goal for large-scale products and small devices.
Skim-RNN has the same input and output interfaces as standard RNNs, so it can be conveniently used to speed up RNNs in existing models.
This is in contrast to LSTM-Jump (Yu et al., 2017) that does not have outputs for the skipped time steps.
Moreover, the speed of Skim-RNN can be dynamically
Big RNN
SmallRNN
COPY
READ
SKIM
Big RNN
SmallRNN
COPY
READ
SKIM 𝐡 " 𝐱 " 𝐱 $ 𝐱 % 𝐱 & 𝐡 & 𝐡 % 𝐡 $ 𝐡 ’ “Intelligent” “and” “invigorating” “film” 𝑄 & = 𝑄 " = 𝑄 $ = 𝑄 % = controlled at inference time by adjusting the threshold for the ‘skim’ decision.
Lastly, we show that skimming achieves higher accuracy compared to skipping the tokens, implying that paying some attention to unimportant tokens is better than completely ignoring (skipping) them.
Our experiments show that Skim-RNN attains computational advantage (ﬂoat operation reduction, or Flop-R) over a standard RNN, with up to 3x reduction in computations while maintaining the same level of accuracy, on four text classiﬁcation tasks and two question answering task.
Moreover, for applications that are concerned with latency than throughput, Skim-RNN on a CPU can offer lower-latency inference time compared to to standard RNNs on GPUs (Section 4.3).
Our experiments show that we achieve higher accuracy and/or computational efﬁciency compared to LSTM-jump and verify our intuition about the advantages of skimming compared to skipping.
R ELATED W ORK
Fast neural networks.
As neural networks become widely integrated into real-world applications, making neural networks faster and lighter has drawn much attention in machine learning communities and industries recently.
Mnih et al.
(2014) perform hard attention instead of soft attention on image patches for caption generation, which reduces number of computations and memory usage.
Han et al.
(2016) compress a trained convolutional neural networks so that the model occupies less memory.
Rastegari et al.
(2016) approximate 32-bit ﬂoat operations with single bit binary operations to substantially increase computational speed at the cost of little loss of precision.
More relevant work to ours are those that are speciﬁcally targeted for sequential data.
LSTMJump (Yu et al., 2017) has the same goal as our model in that it aims to reduce the computational cost of recurrent neural networks.
However, it is fundamentally different from skim-RNN in that it skips some input tokens while ours does not ignore any token and skims if the token is unimportant.
Our experiments conﬁrm the beneﬁts of skimming compared to skipping in Figure 5.
In addition,
LSTM-Jump does not produce LSTM outputs for skipped tokens, which often means that it is nontrivial to replace a regular LSTM in existing models with LSTM-Jump, if the outputs of the
LSTM (instead of just the last hidden state) is used.
On the other hand, Skim-RNN emits a ﬁxed-size output at every time step, so it is compatible with any RNN-based model.
We also note the existence of Skip-LSTM (Campos et al., 2017), a recent, concurrent submission to ours that shares many characteristics with LSTM-Jump.
Choi et al.
(2017) use a CNN-based sentence classiﬁer, which can be efﬁciently computed with GPUs, to select the most relevant sentence(s) to the question among hundreds of candidates, and uses an
RNN-based question answering model, which is relatively costly on GPUs, to obtain the answer from the selected sentence.
The two models are jointly trained with REINFORCE (Williams, 1992).
Skim-RNN is inherently different from the model in that ours is generic (replaces RNN) and is not
), while ours
Johansen et al.
(2017) have shown that, for sentiment analysis, it is possible to cheaply determine if entire sentence can be correctly classiﬁed with a cheap bag-of-word model or needs a more expensive
LSTM classiﬁer.
Again, Skim-RNN is intrinsically different from their approach in that it makes a single, static decision on which model to use on the entire example.
Attention.
Modeling human’s attention while reading has been studied in the ﬁeld of cognitive psychology (Reichle et al., 2003).
Neural attention mechanism has been also widely employed and proved to be essential for many language tasks (Bahdanau et al., 2014), allowing the model to focus on speciﬁc parts of of the text.
Nevertheless, it is important to note the distinction from Skim-RNN that the neural attention mechanism is soft (differentiable) and is not intended for faster inference.
More recently, Hahn & Keller (2016) have modeled the human reading pattern with neural attention in an unsupervised learning approach, leading to conclusion that there exists trade-off between a system’s performance in a given reading-based task and the speed of reading.
RNNs with hard decisions.
Our model is relevant to several recent works that incorporate hard decisions within recurrent neural networks (Kong et al., 2016).
Dyer et al.
(2016) uses RNN for transition-based dependency parsing.
At each time step, the RNN unit decides between three possible choices.
The architecture does not suffer from the intractability of computing the gradients, because the decision is supervised at every time step.
Chung et al.
(2017) dynamically construct multiscale
RNN by making a hard binary decision on whether to update hidden state of each layer at each time step.
In order to handle the intractability of computing the gradient, they use straight-through estimation (Bengio et al., 2013) with slope annealing, which can be considered as an alternative method to Gumbel-softmax reparameterization.
M ODEL
Skim-RNN unit consists of two RNN cells, default (big) RNN cell of hidden state size d and small
RNN cell of hidden state size d (cid:48) , where d and d (cid:48) are hyperparameters deﬁned by the user and d (cid:48) (cid:28) d .
Each RNN cell has its own weight and bias, and it can be any variant of RNN, such as GRU and
LSTM.
The core idea of the model is that the Skim-RNN dynamically makes the decision at each time step whether to use the big RNN (if the current token is important), or to skim by using the small
RNN (if the current token is unimportant).
Skipping a token can be implemented by setting d (cid:48) , the size of the small RNN, equal to zero.
Since small RNN requires less number of ﬂoat operations than big RNN, the model is faster than big RNN alone while obtaining similar or better results than the big RNN alone.
Later in Section 4, we will measure the speed effectiveness of Skim-RNN via three criteria: skim rate (how many words are skimmed), number of ﬂoat operations, and benchmarked speed on several platforms.
Figure 1 depicts the schematic of Skim-RNN on a short word sequence.
We ﬁrst describe the desired inference model of Skim-RNN to be learned in Section 3.1.
The input to and the output of Skim-RNN are equivalent to that of a regular RNN: a varying-length sequence of vectors go in, and an equal-length sequence of output vectors come out.
We model the hard decision of skimming at each time step with a stochastic multinomial variable.
Note that obtaining the exact gradient is intractable as the sequence becomes longer, and the loss is not differentiable due to hard argmax; hence, in Section 3.2, we reparameterize the stochastic distribution with Gumbelsoftmax (Jang et al., 2017) to approximate the inference model with a fully-differentiable function, which can be efﬁciently trained with stochastic gradient descent.
3. I NFERENCE
At each time step t , Skim-RNN unit takes the input x t ∈ R d and the previous hidden state h t − 1 ∈ R d as its arguments, and outputs the new state h t .
2 Let k represent the number of choices for the hard decision at each time step.
In Skim-RNNs, k = 2 since it either fully reads or skims .
In general, although not explored in this paper, one can have k > 2 for multiple degrees of skimming.
We model the decision making process with a multinomial random variable Q t over the probability distribution of choices p t .
We model p t with
[Equation]
where W ∈ R k × 2 d and b ∈ R k are weights to be learned, and [; ] indicates row concatenation.
Note that one can deﬁne α in a different way (e.g., the dot product between x t and h t − 1 ), as long as its time complexity is strictly less than O ( d 2 ) to gain computational advantage.
For the ease of explanation, let the ﬁrst element of the vector, p 1 t , indicate the probability for fully reading, and the second element, p 2 t , indicate the probability for skimming.
Now we deﬁne the random variable
Q t to make the decision to skim ( Q t = 2 ) or not ( Q t = 1 ), by sampling Q t from the probability distribution p t .
[Equation]
which means Q t = 1 and Q t = 2 will be sampled with the probability of p 1 t and p 2 t , respectively.
If Q t = 1 , then the unit applies a standard, full RNN on the input and the previous hidden state to obtain the new hidden state.
If Q t = 2 , then the unit applies a smaller RNN to obtain a small hidden state, which replaces only a portion of the previous hidden state.
More formally,
[Equation]
where f is a full RNN with d -dimensional output, while f (cid:48) is a smaller RNN with d (cid:48) -dimensional output, where d (cid:48) (cid:28) d , and (:) is vector slicing.
Note that f and f (cid:48) can be any variant of RNN such as
GRU and LSTM 3 .
The main computational advantage of the model is that, if d (cid:48) (cid:28) d , then whenever the model decides to skim, it requires O ( d (cid:48) d ) computations, which is substantially less than O ( d 2 ) .
Also, as a side effect, the last d − d (cid:48) dimensions of the hidden state are less frequently updated, which we hypothesize to be a nontrivial factor for improved accuracy in some datasets (Section 4).
3. T RAINING
Since the loss is a random variable that depends on the random variables Q t , we minimize the expected loss with respect to the distribution of the variables.
4 Suppose that we deﬁne the loss function to be minimized conditioned on a particular sequence of decisions, L ( θ ; Q ) where Q = Q 1 . . .
Q T is a sequence of decisions with length T .
Then the expectation of the loss function over the distribution of the sequence of the decisions is
[Equation]
In order to exactly compute ∇ E Q t [ L ( θ )] , one needs to enumerate all possible Q , which is intractable (exponentially increases with the sequence length).
It is possible to approximate the gradients with
REINFORCE (Williams, 1992), which is an unbiased estimator, but it is known to have a high variance.
We instead use gumbel-softmax distribution (Jang et al., 2017) to approximate Equation 2, r t ∈ R k (same size as p it ), which is fully differentiable.
Hence the back-propagation can now efﬁciently ﬂow to p t without being blocked by the stochastic variable Q t , and the approximation can arbitrarily approach to Q t by controlling hyperparameters.
The reparameterized distribution is obtained by
[Equation]
where g it is an independent sample from Gumbel(0 , 1) =
− log( − log(Uniform(0 , 1)) and τ is the temperature (hyperparameter).
We relax the conditional statement of Equation 3 by rewriting h t
[Equation]
where ˜ h it is the candidate hidden state if Q t
= i .
That is,
[Equation]
as shown in Equation 3.
Note that Equation 6 approaches Equation 3 as r it approaches to be a one-hot vector.
Jang et al.
(2017) have shown that r t becomes more discrete and approaches the distribution of Q t as τ → 0 .
Hence we start from a high temperature (smoother r t ) value and slowly decreases it.
Lastly, in order to encourage the model to skim when possible, in addition to minimizing the main loss function ( L ( θ ) ), which is application-dependent, we also jointly minimize the arithmetic mean of the negative log probability of skimming , 1 T (cid:80) log( p 2 t ) , where T is the sequence length.
We deﬁne the ﬁnal loss function by
[Equation]
where γ is a hyperparameter to control the ratio between the two terms.
E XPERIMENTS
[Table]
We evaluate the effectiveness of Skim-RNN in terms of accuracy and ﬂoat operation reduction (Flop-R) on four classiﬁcation tasks and a question answering task.
These language tasks have been chosen because they do not require one’s full attention to every detail of the text, but rather ask for capturing the high-level information (classiﬁcation) or focusing on speciﬁc portion (QA) of the text, which is more appropriate for the principle of speed reading 5 .
We start with classiﬁcation tasks (Section 4.1) and compare Skim-RNN against standard RNN and LSTM-Jump (Yu et al., 2017), which has a similar goal to ours.
Then we evaluate and analyze our system in a well-studied question answering dataset,
Stanford Question Answering Dataset (SQuAD) (Section 4.2).
Since LSTM-Jump does not report on this dataset, we simulate ‘skipping’ by not updating the hidden state when the decision is to ‘skim’, and show that skimming yields better accuracy-speed trade-off than skipping.
We defer the results of Skim-RNN on Children Book Test to
Appendix B.
Evaluation Metrics.
We measure the accuracy for the the classiﬁcation task (Acc) and the F and exact match (EM) scores of the correct span for the question answering task.
We evaluate the computational efﬁciency with skimming rate (Sk) i.e., how frequently words are skimmed, and reduction in ﬂoat operations (Flop-R).
We also report benchmarked speed gain rate (compared to standard LSTM) of classiﬁcation tasks and CBT since LSTM-Jump does not report Flop reduction rate (See Section 4.3 for how the benchmark is performed).
Note that LSTM-Jump measures speed gain based on GPU while ours is measured based on CPU.
4. T EXT C LASSIFICATION
In a language classiﬁcation task, the input is a sequence of words and the output is the vector of categorical probabilities.
Each word is embedded into a d -dimensional vector.
We initialize the vector
[Table]
[Figure] [Figure]
I liked this movie, not because Tom Selleck was in it, but because it was a good story about baseball and it also had a semi-over dramatized view of some of the issues that a BASEBALL player coming to the end of their time in Major League sports must face.
I also greatly enjoyed the cultural differen- Positive ces in American and Japanese baseball and the small facts on how the games are played differently.
Overall , it is a good movie to watch on Cable TV or rent on a cold winter’s night and watch about the "Dog Day’s" of summer and know that spring training is only a few months away.
A good movie for a baseball fan as well as a good "DATE" movie.
Trust me on that one!
*Wink*
[Table]
with GloVe (Pennington et al., 2014) and use those as the inputs for LSTM (or Skim-LSTM).
We make a linear transformation on the last hidden state of the LSTM and then apply softmax function to obtain the classiﬁcation probabilities.
We use Adam (Kingma & Ba, 2015) for optimization, with initial learning rate of 0.0001.
For Skim-LSTM, τ = max(0 .
5 , exp ( − rn )) where r = 1 e − 4 and n is the global training step, following Jang et al.
We experiment on different sizes of big
LSTM ( d ∈ { 100 , 200 } ) and small LSTM ( d (cid:48) ∈ { 5 , 10 , 20 } ) and the ratio between the model loss and the skim loss ( γ ∈ { 0 . 01 , 0 . 02 } ) for Skim-LSTM.
We use batch size of 32 for SST and Rotten
Tomatoes, and 128 for others.
For all models, we stop early when the validation accuracy does not increase for 3000 global steps.
Results.
Table 2 shows the accuracy and the computational cost of our model compared with standard LSTM and LSTM-Jump (Yu et al., 2017).
First, Skim-LSTM has a signiﬁcant reduction in number of ﬂoat operations compared to LSTM, as indicated by ‘Flop-R’.
When benchmarked on Python (‘Sp’ column), we observe a nontrivial speed up.
We expect that the gain can be further maximized when implemented with lower level language that has smaller overhead.
Second, our model outperforms standard LSTM and LSTM-Jump across all tasks, and its accuracy is better than or close to that of RNN-based state of the art models, which are often speciﬁcally designed for these tasks.
We hypothesize the accuracy improvement over LSTM could be due to the increased stability of the hidden state, as the majority of the hidden state is not updated when skimming.
Figure 2 shows the effect of varying the size of the small hidden state as well as the parameter γ on the accuracy and computational cost.
[Table]
[Table]
Table 3 shows an example from IMDb dataset, where Skim-RNN with d = 200 , d (cid:48)
= 10 , and γ = 0 .
01 correctly classiﬁes it with high skimming rate (92%).
The black words are skimmed, and blue words are fully read.
As expected, the model skims through unimportant words, including prepositions, and latently learns to only carefully read the important words, such as ‘liked’, ‘dreadful’, and ‘tiresome’.
4. Q UESTION A NSWERING
In Stanford Question Answering Dataset, the task is to locate the answer span for a given question in a context paragraph.
We evaluate the effectiveness of Skim-RNN for SQuaD with two different models: LSTM+Attention and BiDAF (Seo et al., 2017).
The ﬁrst model is inspired by most current
QA systems consisting of multiple LSTM layers and an attention mechanism.
The model is complex enough to reach reasonable accuracy on the dataset, and simple enough to run well-controlled analyses for the Skim-RNN.
The details of the model are described in Appendix A.1.
The second model is an open-source model designed for SQuAD, which is studied to mainly show that Skim-RNN could replace RNN in existing complex systems. Training.
We use Adam and initial learning rate of 0 . 0005 .
For stable training, we pretrain with standard LSTM for the ﬁrst 5k steps , and then ﬁnetune with Skim-LSTM (Section A.2 shows different pretraining schemas).
Other hyperparameter setup follows that of classiﬁcation in Section 4.1.
Results.
Table 4 (above double line) shows the accuracy (F1 and EM) of LSTM+Attention and
Skim-LSTM+Attention models.
We observe that the skimming models achieve higher or similar F1 score to those of the default non-skimming models (LSTM+Att) while attaining the reduction in computational cost (Flop-R) by more than 1.4 times.
Moreover, decreasing layers (1 layer) or hidden size (d=5) improves Flop-R, but signiﬁcantly decreases the accuracy (compared to skimming).
Table 4 (below double line) demonstrates that replacing LSTM with Skim-LSTM in an existing complex model (BiDAF) stably gives reduced computational cost without losing much accuracy (only 0 .
2% drop from 77 .
3% of BiDAF to 77 .
1% of Sk-BiDAF with γ = 0 .
Figure 3 shows the skimming rate of different layers of LSTM with varying values of γ in LSTM+Att model.
There are four points on the axis of the ﬁgures associated with two forward and two backward layers of the model.
We see two interesting trends here.
First, the skimming rate of the second layers (forward and backward) are higher than that of the ﬁrst layer across different gamma values.
A possible explanation for this trend is that the model is more conﬁdent about which tokens are important at the second layer.
Second, higher γ value leads to higher skimming rate, which agrees with its intended functionality.
Figure 4 shows F1 score of LSTM+Attention model using standard LSTM and Skim LSTM, sorted in ascending order by Flop-R. While models tend to perform better with larger computational cost,
Skim LSTM (Red) outperforms standard LSTM (Blue) with comparable computational cost.
We also observe that the F1 score of Skim-LSTM is more stable across different conﬁgurations and computational cost.
Moreover, increasing the value of γ for Skim-LSTM gradually increases skipping rate and Flop-R, while it also leads to reduced accuracy.
B ( 50 )
S ( 20 - 0 .
S ( 50 - 0 .
B ( 60 )
S ( 50 - 0 .
S ( 20 - 0 . S ( 20 - 0 .
B ( 1 - l s t m ) B
I n v .
F l o pR
F
F1 (Skim-RNN)
Inv.
Flop-R
F1 (Baseline)
F
Flop-R (Float operation Reduction) [Figure] [Figure]
[Figure]
’ =
t h e s u cce ss f u l s c h e du li ng , budg e ti ng , c on s t
r u c ti on - s it
e s a f e t y , a v a il a b ilit y a nd t r a n s po r t a ti on o f bu il d
i ng m a t e r i a l s , l og i s ti c s , i n c onv e n i e n ce t o t
h e pub li c ca u s e d by c on s t
r u c ti on d e l a y s a nd b i dd i ng , e t c .
T h
e l a r g e s t c on s t r u c ti on p r
o j ec t s a r e r e f e rr e d t
o a s m e ga p
r
o j ec t s 1 f w 1 b w 2 f w 2 b w
Controlling skim rate.
An important advantage of Skim-RNN is that the skim rate (and thus computational cost) can be dynamically controlled at inference time by adjusting the threshold for ‘skim’ decision probability p 1 t (Equation 1). Figure 5 shows the trade-off between the accuracy and computational cost for two settings, conﬁrming the importance of skimming ( d (cid:48) > 0 ) compared to skipping ( d (cid:48) = 0 ). Visualization.
Table 6 shows an example from SQuAD and visualizes which words Skim-LSTM ( d = 100 , d (cid:48)
= 20 ) reads (red) and skims (white).
As expected, the model does not skim when the input seems to be relevant to answering the question.
In addition, LSTM in second layer skims more than that in the ﬁrst layer mainly because the second layer is more conﬁdent about the importance of each token, as shown in Figure 6.
More visualizations are shown in in Appendix C.
4. R UNTIME B ENCHMARKS
Here we brieﬂy discuss the details of the runtime benchmarks for LSTM and Skim-LSTM, which allow us to estimate the speed up of Skim-LSTM-based models in our experiments (corresponding to ‘Sp’ in Table 2).
We assume CPU-based benchmark by default, which has direct correlation with the number of ﬂoat operations (Flop) 6 .
As mentioned previously, the speed-up results in Table 2 (as well as Figure 7 below) are benchmarked using Python (NumPy), instead of popular frameworks such as
TensorFlow or PyTorch.
In fact, we have benchmarked the speed of Length-100 LSTM with d =(batch size = 1) in all three frameworks on a single thread of CPU (averaged over 100 trials), and have observed that NumPy is 1.5 and 2.8 times faster than TensorFlow and PyTorch. This seems to be mostly due to the fact that the frameworks are primarily (optimized) for GPUs and they have
[Figure]
ee
[Figure]
g a i n ov e r s t d l s t m larger overhead than NumPy that they cannot take much advantage of reducing the size of the hidden state of
Figure 7 shows the relative speed gain of Skim-LSTM compared to standard LSTM with varying hidden state size and skim rate.
We use NumPy, and the inferences are run on a single thread of CPU.
We also plot the ratio between the reduction of the number of ﬂoat operations (Flop-R) of LSTM and
Skim-LSTM.
This can be considered as a theoretical upper bound of the speed gain on CPUs.
We note two important observations.
First, there is an inevitable gap between the actual gain (solid line) and the theoretical gain (dotted line).
This gap will be larger with more overhead of the framework, or more parallelization (e.g. multithreading).
Second, the gap decreases as the hidden state size increases because the the overhead becomes negligible with very large matrix operations.
Hence, the beneﬁt of Skim-RNN will be greater for larger hidden state size.
Latency.
A modern GPU has much higher throughput than a CPU with parallel processing.
However, for small networks, the CPU often has lower latency than the GPU.
Comparing between NumPy with
CPU and TensorFlow with GPU (Titan X), we observe that the former has 1.5 times lower latency (75 µ s vs 110 µ s per token) for LSTM of d = 100 .
This means that combining Skim-RNN with
CPU-based framework can lead to substantially lower latency than GPUs.
For instance, Skim-RNN with CPU on IMDb has 4.5x lower latency than a GPU, requiring only 29 µ s per token on average.
C ONCLUSION
We present Skim-RNN, a recurrent neural network that can dynamically decide to use the big RNN (read) or the small RNN (skim) at each time step, depending on the importance of the input.
While
Skim-RNN has signiﬁcantly lower computational cost than its RNN counterpart, the accuracy of
Skim-RNN is still on par with or better than standard RNNs and LSTM-Jump.
Since Skim-RNN has the same input and output interface as an RNN, it can easily replace RNNs in existing applications.
We also show that a Skim-RNN can offer better latency results on a CPU compared to a standard
RNN on a GPU.
Future work involves using Skim-RNN for applications that require much higher hidden state size, such as video understanding, and using multiple small RNN cells for varying degrees of skimming.
A M ODELS AND TRAINING DETAILS ON SQ U AD A. LSTM+A TTENTION DETAILS
Let x t and q i be the embeddings of t -th context word and i -th question word, respectively.
We ﬁrst obtain the d -dimensional representation of the entire question by computing the weighted average of the question word vectors.
We obtain a t = softmax
i ( w (cid:62) [ x t ; q i ; x t ◦ q t ]) and u t = (cid:80) i a t q i , where w ∈ R 3 d is a trainable weight vector and ◦ is element-wise multiplication.
Then the input to the (two layer)
Bidirectional LSTMs will be [ x t ; u t ; x t ◦ u t ] ∈ R 3 d .
We use the outputs of the second layer LSTM to independently predict the start index and the end index of the answer.
We obtain the logits (to be softmaxed) of the start and the end index distributions from the weighted average of the outputs (the weights are learned and different for the start and the end).
We minimize the sum of the negative log probabilities of the correct start/end indices.
A. U SING PRE - TRAINED MODEL
(a) No pretrain We train Skim LSTM from scratch.
It has unstable skim rates, which are often too high or too low, and have very different skim rate in forward and backward direction of LSTM, with a signiﬁcant loss in performance.
(b) Full pretrain We ﬁnetune Skim LSTM from fully pretrained standard LSTM (F1 75.5, global step 18k).
As we ﬁnetune the model, performance decreases and skim rate increases.
(c) Half pretrain We ﬁnetune Skim LSTM from partially-pretrained standard LSTM (F1 70.7, pretraining stopping at 5k steps).
Performance and skim rate increase together during training.
[Figure]
[Figure]
B E XPERIMENTS ON C HILDREN B OOK T EST
In Children Book Test, the input is a sequence of 21 sentences, where the last sentence has one missing word (i.e. cloze test).
The system needs to predict the missing word, which is one of ten provided candidates.
Following LSTM-Jump (Yu et al., 2017), we use a simple LSTM-based QA model that help us to compare against LSTM and LSTM-Jump.
We use single-layer LSTM on the embeddings of the inputs and use the last hidden state of the LSTM for the classiﬁcation, where the output distribution is obtained by performing softmax on the dot product between the embedding of each answer candidate and the hidden state.
We minimize the negative log probability of the correct answers.
We follow the same hyperparameter setup and evaluation metrics from that of Section 4.1.
Results.
In Table 5, we ﬁrst note that Skim-LSTM obtain better results than standard LSTM and
LSTM-Jump.
As discussed in Section 4.1, we hypothesize that the increase in accuracy could be due to the stabilization of the recurrent hidden state over a long distance.
Second, using Skim-LSTM, we see up to 72.2% skimming rate, 3.6x reduction in the number of ﬂoating point operations and 2.2x reduction in actual benchmarked time on NumPy with reasonable accuracies.
Lastly, we note that
LSTM, LSTM-Jump
[Table]
and Skim-LSTM are all signiﬁcantly lower than the state of the art models, which consist of a wide variety of components such as attention mechanism which are often crucial for question answering models
[Table]
C V ISUALIZATION
[Table]
T h e c
o l o r w a s uno
ff i c
i a ll y a dop t e d by a n 1875 vo t e o f t h e s t ud e n t body , a lt hough t h e a ss o c i a ti on w it
h
s o m e f o r m o f r e d ca n b e t r ace d b ac k t o
[Table]
D a v
i s c o m p il e d 5½ s ac k s , f
o u r f
o r ce d f u m b l e s , a nd f ou r i n t e r ce p ti on s , w h il e
K u ec h l y l e d t h e t
ea m i n t ac k l e s ( 118 ) f
o r ce d t w o f u m b l e s
[Table]
D a v
i s c o m p il e d 5½ s ac k s , f
o u r f
o r ce d f u m b l e s , a nd f ou r i n t e r ce p ti on s , w h il e
K u ec h l y l e d t h e t
ea m i n t ac k l e s ( 118 ) f
o r ce d t w o f u m b l e s t h
= 0 .t
h = 0 .t h = 0 .t
h = 0 .t
h = 0 .