Skip to main content
QUICK REVIEW

[Paper Review] Positional Encoding Helps Recurrent Neural Networks Handle a Large Vocabulary

Takashi Morita|arXiv (Cornell University)|Jan 31, 2024
Natural Language Processing TechniquesComputer Science3 citations
TL;DR

This paper demonstrates that positional encoding significantly enhances recurrent neural networks (RNNs) in handling large vocabularies, despite RNNs inherently modeling sequence order. Using synthetic benchmarks, it shows that sinusoidal positional encoding improves generalization and stability in tasks like reverse-ordering and sorting, particularly as vocabulary size increases up to 16,384, without extending memory duration. The key contribution is establishing a synergy between input-driven and autonomous time representation in RNNs.

ABSTRACT

This study reports an unintuitive finding that positional encoding enhances learning of recurrent neural networks (RNNs). Positional encoding is a high-dimensional representation of time indices on input data. Most famously, positional encoding complements the capabilities of Transformer neural networks, which lack an inherent mechanism for representing the data order. By contrast, RNNs can encode the temporal information of data points on their own, rendering their use of positional encoding seemingly redundant/unnecessary. Nonetheless, investigations through synthetic benchmarks reveal an advantage of coupling positional encoding and RNNs, especially for handling a large vocabulary that yields low-frequency tokens. Further scrutinization unveils that these low-frequency tokens destabilizes the gradients of vanilla RNNs, and the positional encoding resolves this instability. These results shed a new light on the utility of positional encoding beyond its canonical role as a timekeeper for Transformers.

Motivation & Objective

  • To investigate whether positional encoding, typically used in Transformers, provides benefits when combined with RNNs despite RNNs' inherent ability to model sequence order.
  • To evaluate the impact of positional encoding on RNNs' ability to generalize across large vocabularies in synthetic sequence tasks.
  • To explore the interplay between input-driven temporal dynamics and autonomous time representation in RNNs.
  • To draw connections between sinusoidal positional encoding and neural oscillations in biological brains.

Proposed method

  • Synthetic benchmarks were designed to test RNNs on tasks requiring generalization over large vocabularies, including reverse-ordering and sorting sequences.
  • Positional encoding was implemented using sinusoidal functions, as in Vaswani et al. (2017), to provide fixed, frequency-based time-stamping of input tokens.
  • Long Short-Term Memory (LSTM) and Gated Recurrent Unit (GRU) networks were trained with and without positional encoding on sequences of varying length and vocabulary size.
  • The performance was evaluated using token-wise accuracy and cross-entropy loss, with 95% confidence intervals estimated via bootstrapping over 10,000 samples.
  • The study compared models using ground-truth feedback and self-feedback in autoregressive settings to assess error propagation.
  • Biological plausibility was discussed by linking sinusoidal positional encoding to endogenous neural oscillations observed in the brain.

Experimental results

Research questions

  • RQ1Does positional encoding improve the performance of RNNs on tasks involving large vocabularies, despite RNNs' inherent sequential processing capability?
  • RQ2Can positional encoding enhance the stability and generalization of RNNs in tasks where input order is irrelevant, such as sorting?
  • RQ3Does positional encoding extend the memory duration of RNNs, as measured by the copying task with a hold phase?
  • RQ4How does the combination of input-driven and autonomous time representation affect RNN performance?
  • RQ5What is the biological relevance of sinusoidal positional encoding in relation to neural oscillations in the brain?

Key findings

  • Positional encoding significantly improved RNN performance on the reverse-ordering task with a large vocabulary size (up to 16,384), while showing no benefit in the standard copying task with small vocabularies (K=8).
  • In the sorting task, position-encoded RNNs maintained higher accuracy than vanilla RNNs as vocabulary size increased, with a 2.09-point average improvement at K=64 for Elman RNNs.
  • The error rate in sorting tasks was primarily due to incorrect inventory construction or retrieval, not failure to sort, with over 99.9% of predictions being correctly sorted regardless of encoding.
  • Autoregressive inference suffered from error propagation due to mismatched feedback during training and inference, while positional encoding provided a more stable alternative.
  • Positional encoding did not improve memory duration in the copying task, indicating its benefit is not due to enhanced long-term memory but rather better handling of large input diversity.
  • The sinusoidal implementation of positional encoding closely resembles neural oscillations in biological brains, suggesting a potential biological basis for its effectiveness.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.