Learning to Map Sentences to Logical Form: Structured Classification with Probabilistic Categorial Grammars

Learning to Map Sentences to Logical Form: Structured Classification with Probabilistic Categorial Grammars

Learning to Map Sentences to Logical Form: Structured Classification with Probabilistic Categorial Grammars Luke S. Zettlemoyer and Michael Collins MIT CSAIL [email protected], [email protected] Abstract The training data in our approach consists of a set of sen- tences paired with logical forms, as in this example. This paper addresses the problem of mapping This is a particularly challenging problem because the natural language sentences to lambda–calculus derivation from each sentence to its logical form is not an- encodings of their meaning. We describe a learn- notated in the training data. For example, there is no di- ing algorithm that takes as input a training set of rect evidence that the word states in the sentence corre- sentences labeled with expressions in the lambda sponds to the predicate state in the logical form; in gen- calculus. The algorithm induces a grammar for eral there is no direct evidence of the syntactic analysis of the problem, along with a log-linear model that the sentence. Annotating entire derivations underlying the represents a distribution over syntactic and se- mapping from sentences to their semantics is highly labor- mantic analyses conditioned on the input sen- intensive. Rather than relying on full syntactic annotations, tence. We apply the method to the task of learn- we have deliberately formulated the problem in a way that ing natural language interfaces to databases and requires a relatively minimal level of annotation. show that the learned parsers outperform pre- vious methods in two benchmark database do- Our algorithm automatically induces a grammar that maps mains. sentences to logical form, along with a probabilistic model that assigns a distribution over parses under the grammar. The grammar formalism we use is combinatory categorial 1 Introduction grammar (CCG) (Steedman, 1996, 2000). CCG is a con- venient formalism because it has an elegant treatment of a Recently, a number of learning algorithms have been pro- wide range of linguistic phenomena; in particular, CCG has posed for structured classification problems. Structured an integrated treatment of semantics and syntax that makes classification tasks involve the prediction of output labels use of a compositional semantics based on the lambda y from inputs x in cases where the output labels have rich calculus. We use a log-linear model—similar to models internal structure. Previous work in this area has focused used in conditional random fields (CRFs) (Lafferty et al., on problems such as sequence learning, where y is a se- 2001)—for the probabilistic part of the model. Log-linear quence of state labels (e.g., see (Lafferty, McCallum, & models have previously been applied to CCGs by Clark and Pereira, 2001; Taskar, Guestrin, & Koller, 2003)), or nat- Curran (2003), but our work represents a major departure ural language parsing, where y is a context-free parse tree from previous work on CCGs and CRFs, in that structure for a sentence x (e.g., see Taskar et al. (2004)). learning (inducing an underlying discrete structure, i.e., the grammar or CCG lexicon) forms a substantial part of our In this paper we investigate a new type of structured classi- approach. fication problem, where the goal is to learn to map natural language sentences to a lambda calculus encoding of their Mapping sentences to logical form is a central problem in semantics. As one example, consider the following sen- designing natural language interfaces. We describe exper- tence paired with a logical form representing its meaning: imental results on two database domains: Geo880, a set of 880 queries to a database of United States geography; Sentence: what states border texas and Jobs640, a set of 640 queries to a database of job list- Logical Form: λx.state(x) ∧ borders(x, texas) ings. Tang and Mooney (2001) described previous work on these data sets. Previous work by Thompson and Mooney The logical form in this case is an expression representing (2002) and Zelle and Mooney (1996) used a subset of the the set of entities that are states, and that also border Texas. Geo880 corpus. We evaluated the algorithm’s accuracy in returning entirely correct logical forms for each test sen- a) What states border Texas tence. Our method achieves over 95% precision on both of λx.state(x) ∧ borders(x, texas) these domains, with recall of 79% on each domain. These are highly competitive results when compared to the previ- b) What is the largest state ous work. arg max(λx.state(x), λx.size(x)) c) What states border the state that borders the most states 2 Background λx.state(x) ∧ borders(x, arg max(λy.state(y), λy.count(λz.state(z) ∧ borders(y, z)))) This section gives background material underlying our learning approach. We first describe the lambda–calculus Figure 1: Examples of sentences with their logical forms. expressions used to represent logical forms. We then de- scribe combinatory categorial grammar (CCG), and the ex- tension of CCG to probabilistic CCGs (PCCGs) through • Additional quantifiers: The expressions involve log-linear models. the additional quantifying terms count, arg max, arg min, and the definite operator ι. An example of a count expression is count(λx.state(x)), which 2.1 Semantics returns the number of entities for which state(x) is true. arg max expressions are of the form The sentences in our training data are annotated with ex- arg max(λx.state(x), λx.size(x)). The first argu- pressions in a typed lambda–calculus language similar to ment is a lambda expression denoting some set of en- the one presented by Carpenter (1997). The system has tities; the second argument is a function of type he, ri. three basic types: e, the type of entities; t, the type of truth In this case the arg max operator would return the set values; and r, the type of real numbers. It also allows func- of items for which state(x) is true, and for which tional types, for example he, ti, which is the type assigned size(x) takes its maximum value. arg min expres- to functions that map from entities to truth values. In spe- sions are defined analogously. Finally, the definite op- cific domains, we will specify subtype hierarchies for e. erator creates expressions such as ι(λx.state(x)). In For example, in a geography domain we might distinguish this case the argument is a lambda expression denot- different entity subtypes such as cities, states, and rivers. ing some set of entities. ι(λx.state(x)) would return Figure 1 shows several sentences from the geography the unique item for which state(x) is true, if a unique (Geo880) domain, together with their associated logical item exists. If no unique item exists, it causes a pre- form. Each logical form is an expression from the lambda supposition error. calculus. The lambda–calculus expressions we use are formed from the following items: 2.2 Combinatory Categorial Grammars • Constants: Constants can either be entities, numbers The parsing formalism underlying our approach is that of or functions. For example, texas is an entity (i.e., it combinatory categorial grammar (CCG) (Steedman, 1996, is of type e). state is a function that maps entities to 2000). A CCG specifies one or more logical forms—of the truth values, and is of type he, ti. size is a function type described in the previous section—for each sentence that maps entities to real numbers, and is therefore of that can be parsed by the grammar. type he, ri (in the geography domain, size(x) returns the land-area of x). The core of any CCG is a lexicon, Λ. In a purely syntactic version of CCG, the entries in Λ consist of a word (lexical • Logical connectors: The lambda–calculus expres- item) paired with a syntactic type. A simple example of a sions include conjunction (∧), disjunction (∨), nega- CCG lexicon is as follows: tion (¬), and implication (→). Utah := NP • Quantification: The expressions include universal Idaho := NP quantification (∀) and existential quantification (∃). borders := (S\NP )/NP For example, ∃x.state(x)∧borders(x, texas) is true if and only if there is at least one state that borders In this lexicon Utah and Idaho have the syntactic type NP , Texas. Expressions involving ∀ take a similar form. and borders has the more complex type (S\NP )/NP .A syntactic type can be either one of a number of primitive • Lambda expressions: Lambda expressions represent categories (in the example, NP or S), or it can be a com- functions. For example, λx.borders(x, texas) is a plex type of the form A/B or A\B where both A and B function from entities to truth values, which is true of can themselves be a primitive or complex type. The prim- those states that border Texas. itive categories NP and S stand for the linguistic notions a) Utah borders Idaho b) What states border Texas NP (S\NP )/NP NP (S/(S\NP ))/N N (S\NP )/NP NP utah λx.λy.borders(y, x) idaho λf.λg.λx.f(x) ∧ g(x) λx.state(x) λx.λy.borders(y, x) texas > > > (S\NP ) S/(S\NP )(S\NP ) λy.borders(y, idaho) λg.λx.state(x) ∧ g(x) λy.borders(y, texas) < > S S borders(utah, idaho) λx.state(x) ∧ borders(x, texas) Figure 2: Two examples of CCG parses. of noun-phrase and sentence respectively. Note that a sin- application rules are then extended as follows: gle word can have more than one syntactic type, and hence (2) The functional application rules (with semantics): more than one entry in the lexicon. a. A/B : f B : g ⇒ A : f(g) In addition to the lexicon, a CCG has a set of combinatory b.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us