Question Answering with Subgraph Embeddings
Antoine Bordes, Sumit Chopra, Jason Weston
Introduction
Teaching machines how to automatically answer questions asked in natural language on any topic or in any domain has always been a long standing goal in Artificial Intelligence. With the rise of large scale structured knowledge bases (KBs), this problem, known as open-domain question answering (or open QA), boils down to being able to query efficiently such databases with natural language. These KBs, such as Freebase encompass huge ever growing amounts of information and ease open QA by organizing a great variety of answers in a structured format. However, the scale and the difficulty for machines to interpret natural language still makes this task a challenging problem.
The state-of-the-art techniques in open QA can be classified into two main classes, namely, information retrieval based and semantic parsing based. 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 . On the other hand, semantic parsing methods focus on the correct interpretation of the meaning of a question by a semantic parsing system. A correct interpretation converts a question into the exact database query that returns the correct answer. Interestingly, recent works have shown that such systems can be efficiently trained under indirect and imperfect supervision and hence scale to large-scale regimes, while bypassing most of the annotation costs.
Yet, even if both kinds of system have shown the ability to handle large-scale KBs, they still require experts to hand-craft lexicons, grammars, and KB schema to be effective. This non-negligible human intervention might not be generic enough to conveniently scale up to new databases with other schema, broader vocabularies or languages other than English. In contrast, proposed a framework for open QA requiring almost no human annotation. Despite being an interesting approach, this method is outperformed by other competing methods. introduced an embedding model, which learns low-dimensional vector representations of words and symbols (such as KBs constituents) and can be trained with even less supervision than the system of while being able to achieve better prediction performance. However, this approach is only compared with which operates in a simplified setting and has not been applied in more realistic conditions nor evaluated against the best performing methods.
In this paper, we improve the model of by providing the ability to answer more complicated questions. sThe main contributions of the paper are: (1) a more sophisticated inference procedure that is both efficient and can consider longer paths ( considered only answers directly connected to the question in the graph); and (2) a richer representation of the answers which encodes the question-answer path and surrounding subgraph of the KB. Our approach is competitive with the current state-of-the-art on the recent benchmark WebQuestions without using any lexicon, rules or additional system for part-of-speech tagging, syntactic or dependency parsing during training as most other systems do.
Task Definition
Our main motivation is to provide a system for open QA able to be trained as long as it has access to: (1) a training set of questions paired with answers and (2) a KB providing a structure among answers. We suppose that all potential answers are entities in the KB and that questions are sequences of words that include one identified KB entity. When this entity is not given, plain string matching is used to perform entity resolution. Smarter methods could be used but this is not our focus.
We use WebQuestions as our evaluation bemchmark. Since it contains few training samples, it is impossible to learn on it alone, and this section describes the various data sources that were used for training. These are similar to those used in .
This dataset is built using Freebase as the KB and contains 5,810 question-answer pairs. It was created by crawling questions through the Google Suggest API, and then obtaining answers using Amazon Mechanical Turk. We used the original split (3,778 examples for training and 2,032 for testing), and isolated 1k questions from the training set for validation. WebQuestions is built on Freebase since all answers are defined as Freebase entities. In each question, we identified one Freebase entity using string matching between words of the question and entity names in Freebase. When the same string matches multiple entities, only the entity appearing in most triples, i.e. the most popular in Freebase, was kept. Example questions (answers) in the dataset include “Where did Edgar Allan Poe died?” (baltimore) or “What degrees did Barack Obama get?” (bachelor_of_arts, juris_doctor).
Freebase
Freebase is a huge and freely available database of general facts; data is organized as triplets (subject, type1.type2.predicate, object), where two entities subject and object (identified by mids) are connected by the relation type type1.type2.predicate. We used a subset, created by only keeping triples where one of the entities was appearing in either the WebQuestions training/validation set or in ClueWeb extractions. We also removed all entities appearing less than 5 times and finally obtained a Freebase set containing 14M triples made of 2.2M entities and 7k relation types.WebQuestions contains 2k entities, hence restricting Freebase to 2.2M entities does not ease the task for us. Since the format of triples does not correspond to any structure one could find in language, we decided to transform them into automatically generated questions. Hence, all triples were converted into questions “What is the predicate of the type2 subject?” (using the mid of the subject) with the answer being object. An example is “What is the nationality of the person barack_obama?” (united_states). More examples and details are given in a longer version of this paper .
ClueWeb Extractions
Freebase data allows to train our model on 14M questions but these have a fixed lexicon and vocabulary, which is not realistic. Following , we also created questions using ClueWeb extractions provided by . Using string matching, we ended up with 2M extractions structured as (subject, “text string”, object) with both subject and object linked to Freebase. We also converted these triples into questions by using simple patterns and Freebase types. An example of generated question is “Where barack_obama was allegedly bear in?” (hawaii).
Paraphrases
The automatically generated questions that are useful to connect Freebase triples and natural language, do not provide a satisfactory modeling of natural language because of their semi-automatic wording and rigid syntax. To overcome this issue, we follow and supplement our training data with an indirect supervision signal made of pairs of question paraphrases collected from the WikiAnswers website. On WikiAnswers, users can tag pairs of questions as rephrasings of each other: harvested a set of 2M distinct questions from WikiAnswers, which were grouped into 350k paraphrase clusters.
Embedding Questions and Answers
Inspired by , our model works by learning low-dimensional vector embeddings of words appearing in questions and of entities and relation types of Freebase, so that representations of questions and of their corresponding answers are close to each other in the joint embedding space. Let denote a question and a candidate answer. Learning embeddings is achieved by learning a scoring function , so that generates a high score if is the correct answer to the question , and a low score otherwise. Note that both and are represented as a combination of the embeddings of their individual words and/or symbols; hence, learning essentially involves learning these embeddings. In our model, the form of the scoring function is:
We now describe possible feature representations for a single candidate answer. (When there are multiple correct answers, we average these representations, see Section 3.4.) We consider three different types of representation, corresponding to different subgraphs of Freebase around it.
Single Entity. The answer is represented as a single entity from Freebase: is a 1-of- coded vector with 1 corresponding to the entity of the answer, and 0 elsewhere.
Path Representation. The answer is represented as a path from the entity mentioned in the question to the answer entity. In our experiments, we considered 1- or 2-hops paths (i.e. with either 1 or 2 edges to traverse): (barack_obama, people.person.place_of_birth, honolulu) is a 1-hop path and (barack_obama, people.person.place_of_birth, location. location.containedby, hawaii) a 2-hops path. This results in a which is a 3-of- or 4-of- coded vector, expressing the start and end entities of the path and the relation types (but not entities) in-between.
Our hypothesis is that including more information about the answer in its representation will lead to improved results. While it is possible that all required information could be encoded in the dimensional embedding of the single entity (i), it is unclear what dimension should be to make this possible. For example the embedding of a country entity encoding all of its citizens seems unrealistic. Similarly, only having access to the path ignores all the other information we have about the answer entity, unless it is encoded in the embeddings of either the entity of the question, the answer or the relations linking them, which might be quite complicated as well. We thus adopt the subgraph approach. Figure 1 illustrates our model.
2 Training and Loss Function
As in , we train our model using a margin-based ranking loss function. Let be the training set of questions paired with their correct answer . The loss function we minimize is
where is the margin (fixed to ). Minimizing Eq. (2) learns the embedding matrix so that the score of a question paired with a correct answer is greater than with any incorrect answer by at least . is sampled from a set of incorrect candidates . This is achieved by sampling 50% of the time from the set of entities connected to the entity of the question (i.e. other candidate paths), and by replacing the answer entity by a random one otherwise. Optimization is accomplished using stochastic gradient descent, multi-threaded with Hogwild! , with the constraint that the columns of remain within the unit-ball, i.e., .
3 Multitask Training of Embeddings
Since a large number of questions in our training datasets are synthetically generated, they do not adequately cover the range of syntax used in natural language. Hence, we also multi-task the training of our model with the task of paraphrase prediction. We do so by alternating the training of with that of a scoring function , which uses the same embedding matrix and makes the embeddings of a pair of questions similar to each other if they are paraphrases (i.e. if they belong to the same paraphrase cluster), and make them different otherwise. Training is similar to that of except that negative samples are obtained by sampling a question from another paraphrase cluster.
We also multitask the training of the embeddings with the mapping of the mids of Freebase entities to the actual words of their names, so that the model learns that the embedding of the mid of an entity should be similar to the embedding of the word(s) that compose its name(s).
4 Inference
Once is trained, at test time, for a given question the model predicts the answer with:
where is the candidate answer set. This candidate set could be the whole KB but this has both speed and potentially precision issues. Instead, we create a candidate set for each question.
We recall that each question contains one identified Freebase entity. is first populated with all triples from Freebase involving this entity. This allows to answer simple factual questions whose answers are directly connected to them (i.e. 1-hop paths). This strategy is denoted .
Since a system able to answer only such questions would be limited, we supplement with examples situated in the KB graph at 2-hops from the entity of the question. We do not add all such quadruplets since this would lead to very large candidate sets. Instead, we consider the following general approach: given that we are predicting a path, we can predict its elements in turn using a beam search, and hence avoid scoring all candidates. Specifically, our model first ranks relation types using Eq. (1), i.e. selects which relation types are the most likely to be expressed in . We keep the top types ( was selected on the validation set) and only add 2-hops candidates to when these relations appear in their path. Scores of 1-hop triples are weighted by since they have one less element than 2-hops quadruplets. This strategy, denoted , is used by default.
A prediction can commonly actually be a set of candidate answers, not just one answer, for example for questions like “Who are David Beckham’s children?”. This is achieved by considering a prediction to be all the entities that lie on the same 1-hop or 2-hops path from the entity found in the question. Hence, all answers to the above question are connected to david_beckham via the same path (david_beckham, people.person.children, *). The feature representation of the prediction is then the average over each candidate entity’s features (see Section 3.1), i.e. where are the individual entities in the overall prediction . In the results, we compare to a baseline method that can only predict single candidates, which understandly performs poorly.
Experiments
We compare our system in terms of F1 score as computed by the official evaluation scriptAvailable from www-nlp.stanford.edu/software/sempre/ (F1 (Berant)) but also with a slightly different F1 definition, termed F1 (Yao) which was used in (the difference being the way that questions with no answers are dealt with), and precision @ 1 (p@1) of the first candidate entity (even when there are a set of correct answers), comparing to recently published systems.Results of baselines except have been extracted from the original papers. For our experiments, all hyperparameters have been selected on the WebQuestions validation set: was chosen among , the learning rate on a log. scale between and and we used at most paths in the subgraph representation. The upper part of Table 3 indicates that our approach outperforms , and , and performs similarly as .
The lower part of Table 3 compares various versions of our model. Our default approach uses the Subgraph representation for answers and as the candidate answers set. Replacing by induces a large drop in performance because many questions do not have answers thatare directly connected to their inluded entity (not in ). However, using all 2-hops connections as a candidate set is also detrimental, because the larger number of candidates confuses (and slows a lot) our ranking based inference. Our results also verify our hypothesis of Section 3.1, that a richer representation for answers (using the local subgraph) can store more pertinent information. Finally, we demonstrate that we greatly improve upon the model of , which actually corresponds to a setting with the Path representation and as candidate set.
We also considered an ensemble of our approach and that of . As we only had access to their test predictions we used the following combination method. Our approach gives a score for the answer it predicts. We chose a threshold such that our approach predicts 50% of the time (when is above its value), and the other 50% of the time we use the prediction of instead. We aimed for a 50/50 ratio because both methods perform similarly. The ensemble improves the state-of-the-art, and indicates that our models are significantly different in their design.
Conclusion
This paper presented an embedding model that learns to perform open QA using training data made of questions paired with their answers and of a KB to provide a structure among answers, and can achieve promising performance on the competitive benchmark WebQuestions.