Ask Me Anything: Dynamic Memory Networks for Natural Language Processing

Ankit Kumar, Ozan Irsoy, Jonathan Su, James Bradbury, Robert English, Brian Pierce, Peter Ondruska, Ishaan Gulrajani, Richard Socher

Abstract

The Dynamic Memory Network (DMN) is a novel neural network architecture designed to unify diverse Natural Language Processing (NLP) tasks under a single question-answering framework. By employing an iterative attention mechanism within an episodic memory module, the DMN can perform complex, multi-hop reasoning over input sequences. This paper reviews the DMN's architecture, its performance across sentiment analysis, part-of-speech tagging, and synthetic reasoning tasks, and the significance of its "multi-pass" approach to understanding context.

Introduction

Historically, the field of Natural Language Processing (NLP) has relied on specialized architectures for distinct tasks. Sentiment analysis, part-of-speech (POS) tagging, and machine translation often utilized different model paradigms. A significant limitation of many sequence models is their struggle with transitive reasoning—the ability to synthesize multiple facts to reach a logical conclusion. For example, determining the location of an object based on a series of movement statements requires linking disparate pieces of information.

The authors propose that nearly all NLP tasks can be reformulated as Question Answering (QA). Under this paradigm, sentiment analysis becomes "What is the sentiment?", and POS tagging becomes "What is the tag for this word?". The challenge lies in creating a unified, end-to-end trainable architecture capable of such generalized reasoning.

The Dynamic Memory Network Architecture

The DMN architecture is composed of four distinct, communicating modules:

  1. Input Module: This module transforms raw text into a sequence of "fact" vectors. Using a Gated Recurrent Unit (GRU), it preserves the temporal and positional context of the input, unlike bag-of-words approaches.
  2. Question Module: The specific query is encoded into a vector representation using another GRU.
  3. Episodic Memory Module: The core of the DMN, this module iteratively processes the input facts. It uses an attention mechanism to focus on relevant facts based on the question and the current memory state, updating its internal representation over multiple "passes."
  4. Answer Module: A final GRU generates the output sequence or word based on the final state of the episodic memory.
High-level overview of the Dynamic Memory Network architecture showing the interaction between Input, Question, Episodic Memory, and Answer modules.

Iterative Attention and Multi-Hop Reasoning

The defining feature of the DMN is its episodic memory module's ability to perform multiple passes over the input data. This "multi-hop" reasoning is essential for tasks requiring logical deduction. In the first pass, the model might identify a primary subject; in subsequent passes, it can retrieve related actions or locations associated with that subject.

Detailed architecture of the DMN illustrating the flow from the Input Module through multiple episodes in the Memory Module to the final Answer Module.

As shown in the detailed architecture above, the model processes a story (e.g., "John moved to the bedroom... John went to the hallway") and a question ("Where is the football?"). The episodic memory module performs multiple passes ($m^1, m^2$), where the attention weights ($e^i_t$) shift as the model "re-reads" the facts to find the supporting evidence needed for the final answer.

Key Results and Insights

The DMN was evaluated on three major benchmarks:

  • Facebook bAbI: On this synthetic reasoning dataset, the DMN achieved a mean accuracy of 93.6%. Crucially, for tasks requiring three supporting facts, accuracy improved from 0% with one pass to over 95% with five passes, demonstrating the power of iterative attention.
  • Stanford Sentiment Treebank (SST): The model set new state-of-the-art results for both binary (88.6%) and fine-grained (52.1%) classification. The iterative process allowed the model to handle complex linguistic structures, such as contrastive conjunctions, by refining its sentiment estimate in the second pass.
  • WSJ-PTB: For POS tagging, the DMN achieved 97.56% accuracy, rivaling specialized state-of-the-art systems.

Conclusion

The Dynamic Memory Network demonstrates that a unified architecture can excel across a wide spectrum of NLP tasks by framing them as question-answering problems. Its ability to perform iterative, multi-hop reasoning through an episodic memory module provides a robust mechanism for capturing complex dependencies and context. While the model faces challenges with extremely long sequences due to its recurrent nature, it represents a significant step toward general-purpose language understanding systems.

Summary updated

Abstract

Most tasks in natural language processing can be cast into question answering (QA) problems over language input. We introduce the dynamic memory network (DMN), a neural network architecture which processes input sequences and questions, forms episodic memories, and generates relevant answers. Questions trigger an iterative attention process which allows the model to condition its attention on the inputs and the result of previous iterations. These results are then reasoned over in a hierarchical recurrent sequence model to generate answers. The DMN can be trained end-to-end and obtains state-of-the-art results on several types of tasks and datasets: question answering (Facebook's bAbI dataset), text classification for sentiment analysis (Stanford Sentiment Treebank) and sequence modeling for part-of-speech tagging (WSJ-PTB). The training for these different tasks relies exclusively on trained word vector representations and input-question-answer triplets.
BibTeX
@inproceedings{kumar2016ask,
  author = {Ankit Kumar and Ozan Irsoy and Jonathan Su and James Bradbury and Robert English and Brian Pierce and Peter Ondruska and Ishaan Gulrajani and Richard Socher},
  title = {{Ask Me Anything: Dynamic Memory Networks for Natural Language Processing}},
  booktitle = {International Conference on Machine Learning},
  year = {2016},
  url = {https://openreview.net/forum?id=SkZbssZ_br},
}
Figure