Question Answering has always been a challenge in natural language processing. There has been lots of works on question answering based on Information Retrieval, Semantic Parsing and Neural Networks(MemNN). Information Retrieval systems first retrieve a broad set of candidate answers by querying the search API of KBs with a transformation of the question into a valid query and then use fine-grained detection heuristics to identify the exact answer. Semantic parsing methods focus on the correct interpretation of the meaning of a question by a semantic parsing system. Recently, J. Weston et. al. propose to train a neural network(MemNN) with a memory to answer various kinds of questions, and got quite promising results.
Memory Neural Network(MemNN)
MemNN takes a set of inputs that are to be stored in the memory, a question , and outputs an answer . Each of the contains words from a vocabulary .
MemNN consists of 3 modules: attention module(input memory representation), reading module (output memory representation) and response generation module:
Each input will be projected into a continuous input vector , in the simplest way using embedding matrix generated by SkipGram or Glove. The question will also be projected into a continuous vector by another matrix . Then the MemNN will generate a weight for each memory . These weights will be used in the reading module to retrieve the input:
Each input will be projected into a continuous output vector using another embedding matrix . Then the reading module will output a sum of all output vectors weighted by :
Response Generation Module
This module will generate a prediction based on the question vector u as well as the output of the reading module .
The overall model is showed in Fig. 1(a).During training, all three embedding matrices and as well as are jointly learning by minimizing a cross-entropy loss between and the true label .
We can also stack multiple MemNN to get a multiple-layer MemNN by using the sum of the question input and the output of the current layer: as the input to the upper layer, as shown in the Fig 1(b).
During training, all embedding matrices as well as are jointly learned by minimizing the cross-entropy loss between and the true label .
There are several improvements based on MemNN. A. Sordoni et. al. propose a new iterative alternating attention methods which allows a fined-grained exploration of both the question and the document(memory), A. Miller et. al. propose a Key-Value MemNN which makes reading document more viable by utilizing different encoding methods for lookup and reading respectively.
Iterative Alternating Attention
The iterative alternating attention can be considered as an inference chain which focus on different part of the question and documents at each search step, where the inference chain is modeled by a GRU. In particular, at search step : (1) It first perform an attentive read on the question, resulting a question glimpse , and (2) given the query glimpse, it extract a conditional document glimpse , representing the part of document that is relevant the current query glimpse. Both attentive reads are based on the previous hidden state of the inference GRU, summarizing the information that has been gathered so far at search step .
Question Attentive Reading
We denote as the encodings for the word in the question as the question attention weights, then the query glimpse at step can be calculated by:
where as the previous hidden state of GRU.
Document Attentive Reading
The notation is very similar with the question attentive reading, note that the document reading weight is also conditioned on the query weight , then the document glimpse at step can be calculated by:
Key-Value MemNN is a generation of MemNN of the way that the documents are stored in memory. In MemNN, the attention and reading are based on different vectors of the same document using different embedding matrices. MemNN generalizes this by using a key vector for attention and a value vector for reading, while the key and the value can be quite different, for example, we can split the document to windows of words where the center is an entity. We can use the whole window as key while only the center entity as the value. Then the memory attention and reading can be performed as following.
Where are feature maps of dimension , is the question vectors, is the key vector of the memory i
Where is the value vector of memory
. J. Weston, S. Chopra, A. Bordes. Memory Networks. arXiv, 2015.
. S. SukhbaatarM A. Szlam, J. Weston, R. Fergus. End-to-End Memory Networks. arXiv, 2015.
. A. Sordoni, P. Bachman, Y. Bengio. Iterative Alternating Neural Attention for Machine Reading.. arXiv, 2016.
. A. Miller, A. Fisch, J. Dodge, A. Karimi, A. Bordes, J. Weston. Key-Value Memory Networks for Directly Reading Documents. arXiv, 2016.
. A. Bordes, J. Weston, S. Chopra. Question Answering with Subgraph Embedding. arXiv, 2014.