[Paper Review] Feed-Forward Networks with Attention Can Solve Some Long-Term Memory Problems
This paper proposes a feed-forward neural network with a simplified attention mechanism that enables efficient, parallel computation and solves long-term memory tasks like addition and multiplication on sequences up to 10,000 tokens long. The model achieves near-perfect accuracy (99.9% on addition, 99.4% on multiplication) on variable-length sequences, outperforming both standard RNNs and unweighted averaging, demonstrating that attention in feed-forward networks can effectively capture long-range dependencies without recurrence.
We propose a simplified model of attention which is applicable to feed-forward neural networks and demonstrate that the resulting model can solve the synthetic "addition" and "multiplication" long-term memory problems for sequence lengths which are both longer and more widely varying than the best published results for these tasks.
Motivation & Objective
- To investigate whether feed-forward networks with attention can solve long-term memory problems typically requiring recurrent architectures.
- To evaluate the effectiveness of attention in enabling long-range sequence modeling without recurrence, particularly for variable-length sequences.
- To compare the performance of attention-based integration against unweighted averaging in handling long and variable-length sequences.
- To demonstrate that feed-forward networks with attention can achieve high accuracy on synthetic long-term memory tasks while enabling full parallelization.
- To provide empirical evidence that attention allows models to selectively refer to specific positions in a sequence, even in non-recurrent architectures.
Proposed method
- The model computes a hidden state $ h_t = \text{LReLU}(W_{xh}x_t + b_{xh}) $ for each input token $ x_t $, using a learnable weight matrix and bias.
- A context vector $ c $ is computed via feed-forward attention: $ c = \sum_{t=1}^T \alpha_t h_t $, where $ \alpha_t = \frac{\exp(a(h_t))}{\sum_k \exp(a(h_k))} $, with $ a $ a learnable function producing attention weights.
- The attention mechanism allows the model to compute a fixed-length, adaptive representation of the entire sequence by weighting hidden states based on their relevance.
- The model is trained end-to-end using backpropagation, with no recurrence—enabling full parallelization across sequence positions.
- The method is compared against a baseline using unweighted mean pooling: $ c = \frac{1}{T}\sum_{t=1}^T h_t $, to isolate the benefit of adaptive attention.
- Experiments are conducted on synthetic addition and multiplication tasks with fixed and variable-length sequences, testing generalization across sequence lengths up to 10,000.
Experimental results
Research questions
- RQ1Can a feed-forward network with attention solve long-term memory tasks such as addition and multiplication on sequences longer than those handled by standard RNNs?
- RQ2Does the proposed attention mechanism enable better generalization across variable-length sequences compared to unweighted averaging?
- RQ3Can a non-recurrent model with attention achieve high accuracy on long sequences while maintaining computational efficiency through parallelization?
- RQ4To what extent does the attention mechanism allow the model to selectively attend to relevant positions in the input sequence?
- RQ5How does the performance of the feed-forward attention model compare to RNNs on long and widely varying sequence lengths in synthetic benchmarks?
Key findings
- The feed-forward attention model achieved 99.9% accuracy on the addition task and 99.4% on the multiplication task when trained on variable-length sequences ranging from 50 to 10,000 time steps.
- The model solved the long-term memory tasks for sequence lengths up to 10,000, significantly exceeding the typical few-hundred-step limit of standard RNNs.
- Training one epoch on 100,000 sequences of length 10,000 took only 254 seconds on an NVIDIA GTX 980 Ti GPU, compared to 917 seconds for a single-layer RNN with comparable parameters.
- The attention mechanism provided a substantial performance boost over unweighted averaging: 99.9% vs. 77.4% accuracy on the variable-length addition task.
- The model demonstrated that adaptive attention in feed-forward networks enables effective long-range dependency learning without recurrence, supporting efficient parallel training.
- The results suggest that for order-agnostic tasks, feed-forward networks with attention can be a powerful alternative to RNNs for long 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.