RNNs implicitly implement tensor-product representations

R. Thomas McCoy, Tal Linzen, Ewan Dunbar, Paul Smolensky

Recurrent Neural Networks (RNNs) are remarkably successful at processing language, yet they operate on continuous vectors that are notoriously difficult to interpret. A long-standing debate in cognitive science and AI is whether these "black box" vectors implicitly encode the compositional structure of language (like trees or ordered sequences) or if they are just high-dimensional "statistical mush."

This paper introduces a method to "reverse-engineer" the internal representations of RNNs by decomposing them into symbolic Tensor Product Representations (TPRs). The authors find that while RNNs can learn highly structured, compositional representations when tasks demand it, many state-of-the-art sentence encoding models are surprisingly well-approximated by a simple "bag-of-words" approach.

Linear regularities in vector spaces across words, digits, and sentences.

The Interpretability Challenge

The authors tackle the challenge of interpretability motivated by the linear regularities (analogies) often found in learned vector spaces. They want to know if an RNN's hidden state can be mathematically mapped back to a symbolic "filler-role" framework—for example, knowing that the word "dog" (the filler) is specifically in the "subject" position (the role).

Methods: The Tensor Product Decomposition Network (TPDN)

The core innovation is the Tensor Product Decomposition Network (TPDN).

  1. The TPR Framework: A Tensor Product Representation (Smolensky, 1990) represents a structure as a sum of bindings: $\sum (\text{filler}_i \otimes \text{role}_i)$.
  2. The TPDN Approach: Instead of building a model using TPRs, the authors use the TPDN to approximate an existing, pre-trained RNN. The TPDN is given a hypothesized role scheme (e.g., "left-to-right position") and then learns the best filler and role embeddings to reconstruct the RNN's original vector.
Architecture of the Tensor Product Decomposition Network (TPDN) approximating an RNN representation.

To see if the approximation is good, they replace the original RNN encoder with their TPDN approximation and see if the original RNN's decoder can still perform the task (Substitution Accuracy). If accuracy remains high, the approximation is "faithful" to the original model's logic.

The authors tested several role schemes, including Positional (left-to-right, bidirectional), Structural (tree-based), Local (context-based), and Astructural (bag-of-words).

Key Insights and Results

The researchers evaluated their approach on both synthetic digit sequences (for controlled experiments) and natural language datasets (like SNLI, evaluated on SentEval).

  • The Decoder is the Architect: One of the most surprising findings is that the decoder architecture (the part of the model that uses the representation) influences the learned representation more than the encoder. A unidirectional encoder paired with a tree-based decoder will actually learn tree-like representations.
  • Task-Driven Compositionality: RNNs only learn complex structures if the task requires it. On a "sorting" task where order doesn't matter for the output, the RNN discards structural information and defaults to a bag-of-words representation.
  • Synthetic Success: For a unidirectional RNN autoencoder trained on digit sequences, the TPDN achieved a substitution accuracy of >0.99 using bidirectional roles, proving that the RNN's "black box" vector was almost perfectly equivalent to a TPR.
  • The "Bag-of-Words" Reality of NLP: While we often think of models like InferSent as deeply structural, the TPDN shows they are often just "Bag-of-Words Plus." For models like InferSent and Skip-thought, the Mean Squared Error (MSE) for a Bag-of-Words approximation was only slightly higher than for complex structural roles. They capture some order, but a bag-of-words TPR approximates them nearly as well.
  • Analogy Tests: Using "role-diagnostic analogies" (e.g., I see now — I see = you know now — you know), the authors found that sentence models demonstrate systematicity consistent with bidirectional roles, but these signals are often "drowned out" by non-structural information in standard tasks.

Limitations and Future Work

The TPDN is a powerful tool for interpreting vector representations, but it has limitations. It requires the researcher to guess the role scheme beforehand and assumes a linear combination of filler-role bindings. If an RNN uses a highly non-linear way of storing data, the TPDN might fail to approximate it.

Future work suggests developing methods to automatically explore the space of possible role schemes, allowing the TPDN to discover the "latent grammar" of any neural network without human intervention. Ultimately, while standard RNNs can induce compositional sequence representations, existing training tasks for sentence representation learning may not be sufficient for inducing robust structural representations.

Summary updated

BibTeX
@inproceedings{mccoy2019rnns,
  author = {R. Thomas McCoy and Tal Linzen and Ewan Dunbar and Paul Smolensky},
  title = {{RNNs implicitly implement tensor-product representations}},
  booktitle = {International Conference on Learning Representations},
  year = {2019},
  url = {https://openreview.net/forum?id=Zso8sm34ClV},
}
Figure