[Paper Review] LARNN: Linear Attention Recurrent Neural Network
LARNN proposes a novel recurrent neural network architecture that integrates multi-head self-attention into an LSTM-like cell, using a fixed-size window of past cell states to enable efficient, attention-augmented memory retrieval. It achieves 91.924% test accuracy on a sensor-based human activity recognition task—surpassing vanilla LSTM by 0.271%—and discovers that applying batch-normalized ELU activation within the attention mechanism's linear layers further improves performance.
The Linear Attention Recurrent Neural Network (LARNN) is a recurrent attention module derived from the Long Short-Term Memory (LSTM) cell and ideas from the consciousness Recurrent Neural Network (RNN). Yes, it LARNNs. The LARNN uses attention on its past cell state values for a limited window size $k$. The formulas are also derived from the Batch Normalized LSTM (BN-LSTM) cell and the Transformer Network for its Multi-Head Attention Mechanism. The Multi-Head Attention Mechanism is used inside the cell such that it can query its own $k$ past values with the attention window. This has the effect of augmenting the rank of the tensor with the attention mechanism, such that the cell can perform complex queries to question its previous inner memories, which should augment the long short-term effect of the memory. With a clever trick, the LARNN cell with attention can be easily used inside a loop on the cell state, just like how any other Recurrent Neural Network (RNN) cell can be looped linearly through time series. This is due to the fact that its state, which is looped upon throughout time steps within time series, stores the inner states in a "first in, first out" queue which contains the $k$ most recent states and on which it is easily possible to add static positional encoding when the queue is represented as a tensor. This neural architecture yields better results than the vanilla LSTM cells. It can obtain results of 91.92% for the test accuracy, compared to the previously attained 91.65% using vanilla LSTM cells. Note that this is not to compare to other research, where up to 93.35% is obtained, but costly using 18 LSTM cells rather than with 2 to 3 cells as analyzed here. Finally, an interesting discovery is made, such that adding activation within the multi-head attention mechanism's linear layers can yield better results in the context researched hereto.
Motivation & Objective
- To address the limitations of standard RNNs in capturing long-range dependencies efficiently.
- To integrate attention mechanisms within a recurrent architecture to enhance memory recall without increasing computational complexity unduly.
- To explore whether attention over past hidden states can improve performance in sequence modeling tasks.
- To evaluate the impact of architectural choices such as positional encoding and residual connections on model performance.
- To investigate whether activation functions in the attention mechanism’s linear projections improve learning.
Proposed method
- The LARNN cell maintains a fixed-size, first-in-first-out queue of the k most recent cell states, enabling bounded memory access.
- It applies multi-head self-attention over the k past cell states to dynamically weight and aggregate relevant historical information.
- The attention mechanism is applied within the cell using queries derived from the current input, keys and values from past states, with dot-product attention and scaled dot-product computation.
- The architecture uses batch normalization and ELU activation on the linear projections within the multi-head attention mechanism, improving training stability and performance.
- The model is trained in a standard RNN loop, with the hidden state updated at each time step using the attention-augmented cell state.
- Residual connections are applied across stacked LARNN layers, allowing feature fusion and improved gradient flow.
Experimental results
Research questions
- RQ1Can integrating a local attention mechanism over past cell states improve the representational capacity of an RNN without incurring quadratic complexity?
- RQ2Does applying batch-normalized activation within the linear layers of the multi-head attention mechanism lead to better generalization on sequence modeling tasks?
- RQ3How does positional encoding affect performance when used in a fixed-window attention mechanism within an RNN?
- RQ4Can a lightweight attention mechanism in an RNN outperform standard LSTM on sequence classification benchmarks?
- RQ5What is the optimal configuration of hyperparameters such as window size k, number of attention heads, and residual stacking for maximum performance?
Key findings
- LARNN achieves a test accuracy of 91.924% on the sensor-based human activity recognition dataset, surpassing the vanilla LSTM baseline of 91.653%.
- The use of batch-normalized ELU activation in the linear projections of the multi-head attention mechanism leads to improved test performance, suggesting a beneficial inductive bias for this architecture.
- Positional encoding did not improve performance when applied in a dense manner, indicating limited utility in this specific setup.
- Stacking LARNN cells in a residual fashion yields superior results compared to a simple sequential (layer-wise) stacking configuration.
- The model maintains linear complexity O(nk²) with a fixed k, offering a scalable alternative to full self-attention while still capturing long-range dependencies through attention over recent memory.
- The architecture demonstrates that attention mechanisms can be effectively embedded within RNNs to enhance memory recall, supporting the continued relevance of RNNs in sequence modeling.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.