Mathematical Foundations for a Compositional Distributional Model of Meaning

Bob Coecke, Mehrnoosh Sadrzadeh, Stephen Clark

Introduction

The symbolic and distributional theories of meaning are somewhat orthogonal with competing pros and cons: the former is compositional but only qualitative, the latter is non-compositional but quantitative. For a discussion of these two competing paradigms in Natural Languge Processing see . Following in the context of Cognitive Science, where a similar problem exists between the connectionist and symbolic models of mind, argued for the use of the tensor product of vector spaces and pairing the vectors of meaning with their roles. In this paper we will also use tensor spaces and pair vectors with their grammatical types, but in a way which overcomes some of the shortcomings of . One shortcoming is that, since inner-products can only be computed between vectors which live in the same space, sentences can only be compared if they have the same grammatical structure. In this paper we provide a procedure to compute the meaning of any sentence as a vector within a single space. A second problem is the lack of a method to compute the vectors representing the grammatical type; the procedure presented here does not require such vectors.

The use of Pregroups for analysing the structure of natural languages is a recent development by Lambek and builds on his original Lambek (or Syntactic) calculus , where types are used to analyze the syntax of natural languages in a simple equational algebraic setting. Pregroups have been used to analyze the syntax of a range of different languages, from English and French to Polish and Persian , and many more; for more references see .

But what is particularly interesting about Pregroups, and motivates their use here, is that they share a common structure with vector spaces and tensor products, when passing to a category-theoretic perspective. Both the category of vector spaces, linear maps and the tensor product, as well as pregoups, are examples of so-called compact closed categories. Concretely, Pregroups are posetal instances of the categorical logic of vector spaces, where juxtaposition of types corresponds to the monoidal tensor of the monoidal category. The mathematical structure within which we compute the meaning of sentences will be a compact closed category which combines the two above. The meanings of words are vectors in vector spaces, their grammatical roles are types in a Pregroup, and tensor product of vector spaces paired with the Pregroup composition is used for the composition of (meaning, type) pairs.

Type-checking is now an essential fragment of the overall categorical logic, and the reduction scheme to verify grammatical correctness of sentences will not only provide a statement on the well-typedness of a sentence, but will also assign a vector in a vector space to each sentence. Hence we obtain a theory with both Pregroup analysis and vector space models as constituents, but which is inherently compositional and assigns a meaning to a sentence given the meanings of its words. The vectors s\overrightarrow{s} representing the meanings of sentences all live in the same meaning space SS. Hence we can compare the meanings of any two sentences s,tS\overrightarrow{s},\overrightarrow{t}\in S by computing their inner-product st\langle\overrightarrow{s}|\overrightarrow{t}\rangle.

Compact closed categories admit a beautiful purely diagrammatic calculus that simplifies the meaning computations to a great extent. They also provide reduction diagrams for typing sentences; these allow for a high level comparison of the grammatical patterns of sentences in different languages . This diagrammatic structure, for the case of vector spaces, was recently exploited by Abramsky and the second author to expose the flows of information withing quantum information protocols . Here, they will expose the flow of information between the words that make up a sentence, in order to produce the meaning of the whole sentence. Note that the connection between linguistics and physics was also identified by Lambek himself .

Two ‘camps’ within computational linguistics

We briefly present the two domains of Computational Linguistics which provide the linguistic background for this paper, and refer the reader to the literature for more details.

The key idea behind vector space models of meaning can be summed up by Firth’s oft-quoted dictum that “you shall know a word by the company it keeps”. The basic idea is that the meaning of a word can be determined by the words which appear in its contexts, where context can be a simple nn-word window, or the argument slots of grammatical relations, such as the direct object of the verb eat. Intuitively, cat and dog have similar meanings (in some sense) because cats and dogs sleep, run, walk; cats and dogs can be bought, cleaned, stroked; cats and dogs can be small, big, furry. This intuition is reflected in text because cat and dog appear as the subject of sleep, run, walk; as the direct object of bought, cleaned, stroked; and as the modifiee of small, big, furry.

Meanings of words can be represented as vectors in a high-dimensional “meaning space”, in which the orthogonal basis vectors are represented by context words. To give a simple example, if the basis vectors correspond to eat, sleep, and run, and the word dog has eat in its context 6 times (in some text), sleep 5 times, and run 7 times, then the vector for dog in this space is (6,5,7).In practice the counts are typically weighted in some way to reflect how informative the contextual element is with respect to the meaning of the target word. The advantage of representing meanings in this way is that the vector space gives us a notion of distance between words, so that the inner product (or some other measure) can be used to determine how close in meaning one word is to another. Computational models along these lines have been built using large vector spaces (tens of thousands of context words/basis vectors) and large bodies of text (up to a billion words in some experiments). Experiments in constructing thesauri using these methods have been relatively successful. For example, the top 10 most similar nouns to introduction, according to the system of , are launch, implementation, advent, addition, adoption, arrival, absence, inclusion, creation.

The other main approach to representing lexical semantics is through an ontology or semantic network, typically manually created by lexicographers or domain experts. The advantages of vector-based representations over hand-built ontologies are that:

they are created objectively and automatically from text;

they allow the representation of gradations of meaning;

they relate well to experimental evidence indicating that the human cognitive system is sensitive to distributional information .

Vector-based models of word meaning have been fruitfully applied to many language processing tasks. Examples include lexicon acquisition , word sense discrimination and disambiguation , text segmentation , language modelling , and notably document retrieval . Within cognitive science, vector-based models have been successful in simulating a wide variety of semantic processing tasks ranging from semantic priming to episodic memory , and text comprehension . Moreover, the cosine similarities obtained within vector-based models have been shown to substantially correlate with human similarity judgements and word association norms .

2 Algebra of Pregroups as a type-categorial logic

We provide a brief overview of the algebra of Pregroups from the existing literature and refer the reader for more details to .

A partially ordered monoid (P,,,1)(P,\leq,\cdot,1) is a partially ordered set, equipped with a monoid multiplication -\cdot- with unit 11, where for p,q,rPp,q,r\in P, if pqp\leq q then we have rprqr\cdot p\leq r\cdot q and prqrp\cdot r\leq q\cdot r. A Pregroup (P,,,1,()l,()r)(P,\leq,\cdot,1,(-)^{l},(-)^{r}) is a partially ordered monoid whose each element pPp\in P has a left adjoint plp^{l} and a right adjoint prp^{r}, i.e. the following hold:

Some properties of interest in a Pregroup are:

Adjoints are order reversing: pq    qrprandqlplp\leq q\implies q^{r}\leq p^{r}\,\text{and}\,q^{l}\leq p^{l}.

The unit is self adjoint: 1l=1=1r1^{l}=1=1^{r}.

Multiplication is self adjoint:(pq)r=qrpr(p\cdot q)^{r}=q^{r}\cdot p^{r} and (pq)l=qlpl(p\cdot q)^{l}=q^{l}\cdot p^{l}.

Opposite adjoints annihilate each other: (pl)r=p=(pr)l(p^{l})^{r}=p=(p^{r})^{l}.

Same adjoints iterate: pllpl ⁣1 ⁣prprr,plllpll ⁣1 ⁣prrprrr,.p^{ll}p^{l}\leq\!1\!\leq p^{r}p^{rr},p^{lll}p^{ll}\leq\!1\!\leq p^{rr}p^{rrr},\ldots\,.

Recall that a Lambek Calculus (P,,,1,/,)(P,\leq,\cdot,1,/,\setminus) is also a partially ordered monoid, but there it is the monoid multiplication that has a right -\setminus- and a left /-/- adjoint. Roughly speaking, the passage from Lambek Calculus to Pregroups can be thought of as replacing the two adjoints of the monoid multiplication with the two adjoints of the elements. One can define a translation between a Lambek Calculus and a Pregroup by sending (p ⁣ ⁣q)(p\!\setminus\!q) to (prq)(p^{r}\cdot q) and (p/q)(p/q) to (pql)(p\cdot q^{l}), and via the lambda calculus correspondence of the former think of the adjoint types of a Pregroup as function arguments.

Pregroups formalize grammar of natural languages in the same way as type-categorial logics do. One starts by fixing a set of basic grammatical roles and a partial ordering between them, then freely generating a Pregroup of these types, the existence of which have been proved. In this paper, we present two examples from English: positive and negative transitive sentencesBy a negative sentence we mean one with a negation operator, such as not, and a positive sentence one without a negation operator., for which we fix the following basic types:

Compound types are formed from these by taking adjoints and juxtaposition. A type (basic or compound) is assigned to each word of the dictionary. We define that if the juxtaposition of the types of the words within a sentence reduces to the basic type ss, then the sentence is grammatical. It has been shown that this procedure is decidable. In what follows we use an arrow \to for \leq and drop the \cdot between juxtaposed types. The example sentence “John likes Mary”, has the following type assignmentThe brackets are only for the purpose of clarity of exposition and are not part of the mathematical presentation.:

and it is grammatical because of the following reduction:

Reductions are depicted diagrammatically, that of the above is:

Reduction diagrams depict the grammatical structure of sentences in one dimension, as opposed to the two dimensional trees of type-categorial logics. This feature becomes useful in applications such as comparing the grammatical patterns of different languages; for some examples see .

We type the negation of the above sentence as follows:

which is grammatical because of the following reduction:

The types used here for “does” and “not” are not the original ones, e.g. as suggested in , but are rather obtainable from the procedure later introduced in . The difference between the two is in the use of the glueing types; once these are deleted from the above, the original types are retrieved. The motivation behind introducing these glueing types is their crucial role in the development of a discourse semantics for Pregroups . Our motivation, as will be demonstrated in section 4, is that these allow for the information to flow and be acted upon in the sentence and as such assist in constructing the meaning of the whole sentence. Interestingly, we have come to realize that these new types can also be obtained by translating into the Pregroup notation the types of the same words from a type-categorial logic approach, up to the replacement of the intermediate nn’s with σ\sigma’s.

Modeling a language in a concrete category

Our mathematical model of language will be category-theoretic. Category theory is usually not conceived as the most evident part of mathematics, so let us briefly state why this passage is essential. The reader may consult the category theory tutorial which covers the background on the kinds of categories that are relevant here. Also the survey of graphical languages for monoidal categories could be useful – note that Selinger refers to ‘non-commutative’ compact closed categories as (both left and right) planar autonomous categories. So why do we use categories?

The passage from {\mboxtrue,false}\{\mbox{true, false}\}-valuations (as in Montague semantics) to quantitative meaning spaces requires a mathematical structure that can store this additional information, but which at the same time retains the compositional structure. Concrete monoidal categories do exactly that:

the axiomatic structure, in particular the monoidal tensor, captures compositionality;

the concrete objects and corresponding morphisms enable the encoding of the particular model of meaning one uses, here vector spaces.

The structural morphisms of the particular categories that we consider, compact closed categories, will be the basic building blocks to construct the morphisms that represent the ‘from-meaning-of-words-to-meaning-of-a-sentence’-process.

Even in a purely syntactic setting, the lifting to categories will allow us to reason about the grammatical structures of different sentences as first class citizens of the formalism. This will enable us to provide more than just a yes-no answer about the grammatical structure of a phrase, i.e. if it is grammatical or not. As such, the categorical setting will, for instance, allow us to distinguish and reason about ambiguities in grammatical sentences, where their different grammatical structures gives rise to different meaning interpretations.

We first briefly recall the basic notions of the theory of monoidal categories, before explaining in more detail what we mean by this ‘from-meaning-of-words-to-meaning-of-a-sentence’-process.

Here we consider the non-symmetric case of a compact closed category, non-degenerate Pregroups being examples of essentially non-commutative compact closed categories. The formal definition of monoidal categories is somewhat involved. It does admit an intuitive operational interpretation and an elegant, purely diagrammatic calculus. A (strict) monoidal category C{\bf C} requires the following data and axioms:

for each ordered pair of objects (A,B)(A,B) a corresponding set C(A,B){\bf C}(A,B) of morphisms; it is convenient to abbreviate fC(A,B)f\in{\bf C}(A,B) by f:ABf:A\to B;

for each ordered triple of objects (A,B,C)(A,B,C), each f:ABf:A\to B, and g:BCg:B\to C, there is a sequential composite gf:ACg\circ f:A\to C; we moreover require that:

for each object AA there is an identity morphism 1A:AA1_{A}:A\to A; for f:ABf:A\to B we moreover require that:

for each ordered pair of objects (A,B)(A,B) a composite object ABA\otimes B; we moreover require that:

there is a unit object I{\rm I} which satisfies:

for each ordered pair of morphisms (f:AC,g:BD)(f:A\to C,g:B\to D) a parallel composite fg:ABCDf\otimes g:A\otimes B\to C\otimes D; we moreover require bifunctoriality i.e.

There is a very intuitive operational interpretation of monoidal categories. We think of the objects as types of systems. We think of a morphism f:ABf:A\to B as a process which takes a system of type AA as input and provides a system of type BB as output, i.e. given any state ψ\psi of the system of type AA, it produces a state f(ψ)f(\psi) of the system of type BB. Composition of morphisms is sequential application of processes. The compound type ABA\otimes B represents joint systems. We think of I{\rm I} as the trivial system, which can be either ‘nothing’ or ‘unspecified’. More on this intuitive interpretation can be found in .

In the standard definition of monoidal categories the ‘strict’ equality of eqs. (1,2) is not required but rather the existence of a natural isomorphism between (AB)C(A\otimes B)\otimes C and A(BC)A\otimes(B\otimes C). We assume strictness in order to avoid coherence conditions. This simplification is justified by the fact that each monoidal category is categorically equivalent to a strict one, which is obtained by imposing appropriate congruences. Moreover, the graphical language which we introduce below represents (free) strict monoidal categories. This issue is discussed in detail in .

So what is particularly interesting about these monoidal categories is indeed that they admit a graphical calculus in the following sense :

An equational statement between morphisms in a monoidal category is provable from the axioms of monoidal categories if and only if it is derivable in the graphical language.

This fact moreover does not only hold for ordinary monoidal categories, but also for many kinds that have additional structure, including the compact closed categories that we will consider here.

In the graphical calculus for monoidal categories we depict morphisms by boxes, with incoming and outgoing wires labelled by the corresponding types, with sequential composition depicted by connecting matching outputs and inputs, and with parallel composition depicted by locating boxes side by side. For example, the morphisms

are depicted as follows in a top-down fashion:

When representing morphisms in this manner by boxes, eq.(3) comes for free !

The unit object I{\rm I} is represented by ‘no wire’; for example

2 The ‘from-meaning-of-words-to-meaning-of-a-sentence’ process

Monoidal categories are widely used to represent processes between systems of varying types, e.g. data types in computer programs. The process which is central to this paper is the one which takes the meanings of words as its input and produces the meaning of a sentence as output, within a fixed type SS (Sentence) that allows the representation of meanings of all well-typed sentences.

Diagrammatically we represent it as follows:

where all triangles represent meanings, both of words and sentences. For example, the triangle labeled ‘word 1’ represents the meaning of word 1 which is of grammatical type AA, and the triangle labeled ‘sentence’ represents the meaning of the whole sentence. The concatenation (word 1)\cdot\cdot (word n) is the sentence itself, which is of grammatical type AZA\otimes\ldots\otimes Z, and the way in which the list of meanings of words:

within the fixed type SS, is mediated by the grammatical structure. The concrete manner in which grammatical structure performs this role will be explained below. This method will exploit the common mathematical structure which vector spaces (used to assign meanings to words in a language) and Pregroups (used to assign grammatical structure to sentences) share, namely compact closure.

3 Compact closed categories

A monoidal category is compact closed if for each object AA there are also objects ArA^{r} and AlA^{l}, and morphisms

Compact closed categories are in a sense orthogonal to cartesian categories, such as the category of sets and functions with the cartesian product as the monoidal structure. Diagrammatically, in a cartesian category the triangles representing meanings of type ABA\otimes B could always be decomposed into a triangle representing meanings of type AA and a triangle representing meanings of type BB:

But if we consider a verb, then its grammatical type is nrsnln^{r}sn^{l}, that is, of the form NSNN\otimes S\otimes N within the realm of monoidal categories. Clearly, to compute the meaning of the whole sentence, the meaning of the verb will need to interact with the meaning of both the object and subject, so it cannot be decomposed into three disconnected entities:

In this graphical language, the topology (i.e. either being connected or not) represents when interaction occurs. In other words, ‘connectedness’ encodes ‘correlations’.

That we cannot always decompose triangles representing meanings of type ABA\otimes B in compact closed categories can be immediately seen in the graphical calculus of compact closed categories, which explicitly introduces wires between different types, and these will mediate flows of information between words in a sentence. A fully worked out example of sentences of this type is given in section 4.1.

When depicting the morphisms ηl,ϵl,ηr,ϵr\eta^{l},\epsilon^{l},\eta^{r},\epsilon^{r} as (read in a top-down fashion)

rather than as triangles, the axioms of compact closure simplify to:

Vector spaces, linear maps and tensor product as a compact closed category.

In eq. (5), the weighted sum ijcijviwj\sum_{ij}c_{ij}\,\overrightarrow{v}_{i}\otimes\overrightarrow{w}_{j} denotes a typical vector in a tensor space VWV\otimes W, where cijc_{ij}’s enumerate all possible weights for the tensored pair of base vectors viwj\overrightarrow{v}_{i}\otimes\overrightarrow{w}_{j}. If in the definition of ϵl=ϵr\epsilon^{l}=\epsilon^{r} we apply the restriction that vi=wi=ei\overrightarrow{v}_{i}=\overrightarrow{w}_{i}=\overrightarrow{e}_{i}, which we can do if we stipulate that ϵl=ϵr\epsilon^{l}=\epsilon^{r} is a linear map, then it simplifies to

A Pregroup as a compact closed category.

A Pregroup is an example of a posetal category, that is, a category which is also a poset. For a category this means that for any two objects there is either one or no morphism between them. In the case that this morphism is of type ABA\to B then we write ABA\leq B, and in the case it is of type BAB\to A we write BAB\leq A. The reader can then verify that the axioms of a category guarantee that the relation \leq on C|C| is indeed a partial order. Conversely, any partially ordered set (P,)(P,\leq) is a category. For ‘objects’ p,q,rPp,q,r\in P we take [pq][p\leq q] to be the singleton {pq}\{p\leq q\} whenever pqp\leq q, and empty otherwise. If pqp\leq q and qrq\leq r we define prp\leq r to be the composite of the ‘morphisms’ pqp\leq q and qrq\leq r.

A partially ordered monoid is a monoidal category with the monoid multiplication as tensor on objects; whenever prp\leq r and qzq\leq z then we have pqrzp\cdot q\leq r\cdot z by monotonicity of monoid multiplication, and we define this to be the tensor of ‘morphisms’ [pr][p\leq r] and [qz][q\leq z]. Bifunctoriality, as well as any equational statement between morphisms in posetal categories, is trivially satisfied, since there can only be one morphism between any two objects.

Finally, each Pregroup is a compact closed category for

and so the required equations are again trivially satisfied. Diagrammatically, the under-links representing the type reductions in a Pregroup grammar are exactly the ‘cups’ of the compact closed structure. The symbolic counterpart of the diagram of the reduction of a sentence with a transitive verb

4 Categories representing both grammar and meaning

We have described two aspects of natural language which admit mathematical presentations:

vector spaces can be used to assign meanings to words in a language;

Pregroups can be used to assign grammatical structure to sentences.

When we organize these vector spaces as a monoidal category by also considering linear maps, and tensor products both of vector spaces and linear maps, then these two mathematical objects share common structure, namely compact closure. We can think of these two compact closed structures as two structures that we can project out of a language, where PP is the free Pregroup generated from the basic types of a natural language: {diagram}

We aim for a mathematical structure that unifies both of these aspects of language, that is, in which the compositional structure of Pregroups would lift to the level of assigning meaning to sentences and their constituents, or dually, where the structure of assigning meaning to words comes with a mechanism that enables us to compute the meaning of a sentence. The compact closed structure of FVect{\bf FVect} alone is too degenerate for this purpose since Al=Ar=AA^{l}=A^{r}=A. Moreover, there are canonical isomorphisms VWWVV\otimes W\to W\otimes V which translate to posetal categories as ab=baa\cdot b=b\cdot a, and in general we should not be able to exchange words in a sentence without altering its meaning. Therefore we have to refine types to retain the full grammatical content obtained from the Pregroup analysis. There is an easy way of doing this: rather than objects in FVect{\bf FVect} we will consider objects in the product category FVect×P{\bf FVect}\times P: {diagram} Explicitly, FVect×P{\bf FVect}\times P is the category which has pairs (V,a)(V,a) with VV a vector space and aPa\in P a grammatical type as objects, and the following pairs as morphisms:

Note that if p≰qp\not\leq q then there are no morphisms of type (V,p)(W,q)(V,p)\to(W,q). It is easy to verify that the compact closed structure of FVect{\bf FVect} and PP lifts component-wise to one on FVect×P{\bf FVect}\times P. The structural morphisms in this new category are now:

5 Meaning of a sentence as a morphism in 𝐅𝐕𝐞𝐜𝐭×P𝐅𝐕𝐞𝐜𝐭𝑃{\bf FVect}\times P.

We refer to an object (W,p)(W,p) of Fvect×P{\bf Fvect}\times P as a meaning space . This consists of a vector space WW in which the meaning of a word lives wW\overrightarrow{w}\in W and the grammatical type pp of the word.

We define the vector w1wn\overrightarrow{w_{1}\cdots w_{n}} of the meaning of a string of words w1wnw_{1}\cdots w_{n} to be

where for (Wi,pi)(W_{i},p_{i}) meaning space of the word wiw_{i}, the linear map ff is built by substituting each pip_{i} in [p1pnx][p_{1}\cdots p_{n}\leq x] with WiW_{i}.

Thus for α=[p1pnx]\alpha=[p_{1}\cdots p_{n}\to x] a morphism in P{\bf P} and f=α[piWi]f=\alpha[p_{i}\setminus W_{i}] a linear map in Fvect{\bf Fvect}, the following is a morphism in Fvect×P{\bf Fvect}\times P:

We call ff the ‘from-meaning-of-words-to-meaning-of-a-sentence’ map.

According to this formal definition, the procedure of assigning meaning to a string of words can be roughly described as follows:

Assign a grammatical type pip_{i} to each word wiw_{i} of the string, apply the axioms and rules of the Pregroup grammar to reduce these types to a simpler type p1pnxp_{1}\cdots p_{n}\to x. If the string of words is a sentence, then the reduced type xx should be the basic grammatical type ss of a sentenceBy Lambek’s switching lemma the epsilon maps suffice for the grammatical reductions and thus xx already exists in the type of one of the words in the string..

Assign a vector space to each word of the sentence based on its syntactic type assignment. For the purpose of this paper, we prefer to be flexible with the manner in which these vector spaces are built, e.g. the vector spaces of the words with basic types like noun may be atomic and built according to the usual rules of the distributional model; the vector spaces of the words with compound types like verbs are tensor spaces.

Consider the vector of the meaning of each word in the spaces built above, take their tensor, and apply to it the diagram of the syntactic reduction of the string, according to the meaning spaces of each word. This will provide us with the meaning of the string.

6 Comparison with the connectionist proposal

Following the solution of connectionists , Pulman and the third author argued for the use of tensor products in developing a compositional distributional model of meaning . They suggested that to implement this idea in linguistics one can, for example, traverse the parse tree of a sentence and tensor the vectors of the meanings of words with the vectors of their roles:

This vector in the tensor product space should then be regarded as the meaning of the sentence “John likes Mary.”

The tensors (\mbox\emJohn\mbox\emsubj)(\overrightarrow{\mbox{\em John}}\otimes\overrightarrow{\mbox{\em subj}}) and (\mbox\emMary\mbox\emobj)(\overrightarrow{\mbox{\em Mary}}\otimes\overrightarrow{\mbox{\em obj}}) in the above are pure tensors, and thus can be considered as a pair of vectors, i.e. (\mbox\emJohn,\mbox\emsubj)(\overrightarrow{\mbox{\em John}},\overrightarrow{\mbox{\em subj}}) and (\mbox\emMary,\mbox\emobj)(\overrightarrow{\mbox{\em Mary}},\overrightarrow{\mbox{\em obj}}). These are pairs of a meaning of a word and its grammatical role, and almost the same as the pairs considered in our approach, i.e. that of a meaning space of each word. A minor difference is that, in the above, the grammatical role p\overrightarrow{p} is a genuine vector, whereas in our approach this remains a grammatical type. If needed, our approach can easily be adapted to also allow types to be represented in a vector space.

A more conceptual difference between the two approaches lies in the fact that the above does not assign a grammatical type to the verb, i.e. treats \mbox\emlikes\overrightarrow{\mbox{\em likes}} as a single vector. Whereas in our approach, the vector of the verb itself lives in a tensor space.

Computing the meaning of example sentences

In what follows we use the steps above to assign meaning to positive and negative transitive sentencesFor the negative example, we use the idea and treatment of previous work , in that we use eta maps to interpret the logical meaning of “does” and “not”, but extend the details of calculations, diagrammatic representations, and corresponding comparisons..

A positive sentence with a transitive verb has the Pregroup type n(nr ⁣snl)nn(n^{r}\!sn^{l})n. We assume that the meaning spaces of the subject and object of the sentence are atomic and are given as (V,n)(V,n) and (W,n)(W,n). The meaning space of the verb is compound and is given as (V S  W,nr ⁣snl)(V\otimes~{}S~{}\otimes~{}W,n^{r}\!sn^{l}). The ‘from-meaning-of-words-to-meaning-of-a-sentence’ linear map ff is the linear map which realizes the following structural morphism in FVect×P{\bf FVect}\times P:

and arises from a syntactic reduction map; in this case we obtain:

Noting the isomorphism VSWVWSVWSV\otimes S\otimes W\cong V\otimes W\otimes S\cong V^{*}\otimes W^{*}\to S obtained from the commutativity of tensor in the FVect{\bf FVect} and that V=VV^{*}=V and W=WW^{*}=W therein, and the universal property of the tensor with respect to product, we can think about the meaning space of a verb VWSV\otimes W\otimes S as a function space V×WSV\times W\to S. So the meaning vector of each transitive verb can be thought of as a function that inputs a subject from VV and an object from WW and outputs a sentence in SS.

In the graphical calculus, the linear map of meaning is depicted as follows:

The matrix of ff has dim(V)2×dim(S)×dim(W)2dim(V)^{2}\times dim(S)\times dim(W)^{2} columns and dim(S)dim(S) rows, and its entries are either or 11. When applied to the vectors of the meanings of the words, i.e. f(vΨw)Sf(\overrightarrow{v}\otimes\overrightarrow{\Psi}\otimes\overrightarrow{w})\in S for vΨwVSW\overrightarrow{v}\otimes\overrightarrow{\Psi}\otimes\overrightarrow{w}\in V\otimes S\otimes W we obtain, diagrammatically:

This map can be expressed in terms of the inner-product as follows. Consider the typical vector in the tensor space which represents the type of verb:

This vector is the meaning of the sentence of type n(nr ⁣snl)nn(n^{r}\!sn^{l})n, and assumes as given the meanings of its constituents vV\overrightarrow{v}\in V, ΨT\overrightarrow{\Psi}\in T and wW\overrightarrow{w}\in W, obtained from data using some suitable method.

Note that, in Dirac notation, f(vΨw)f(\overrightarrow{v}\otimes\overrightarrow{\Psi}\otimes\overrightarrow{w}) is written as:

Also, the diagrammatic calculus tells us that:

where the reversed triangles are now the corresponding Dirac-bra’s, or in vector space terms, the corresponding functionals in the dual space. This simplifies the expression that we need to compute to:

As mentioned in the introduction, our focus in this paper is not on how to practically exploit the mathematical framework, which would require substantial further research, but to expose the mechanisms which govern it. To show that this particular computation (i.e. the ‘from-meaning-of-words-to-meaning-of-a-sentence’-process) does indeed produce a vector which captures the meaning of a sentence, we explicitly compute f(vΨw)f(\overrightarrow{v}\otimes\overrightarrow{\Psi}\otimes\overrightarrow{w}) for some simple examples, with the intention of providing the reader with some insight into the underlying mechanisms and how the approach relates to existing frameworks.

One Dimensional Truth-Theoretic Meaning. Consider the sentence

We encode this sentence as follows; we have:

where we take VV to be the vector space spanned by men and WW the vector space spanned by women. In terms of context vectors this means that each word is its own and only context vector, which is of course a far too simple idealisation for practical purposes. We will conveniently assume that all men are referred to as male, using indices to distinguish them: mi. Thus the set of vectors {\mbox\emmi}i\{\overrightarrow{\mbox{\em m}}_{i}\}_{i} spans VV. Similarly every woman will be referred to as female and distinguished by fj, for some jj, and the set of vectors {\mbox\emfj}j\{\overrightarrow{\mbox{\em f}}_{j}\}_{j} spans WW. Let us assume that John in sentence (\refsentence)(\ref{sentence}) is m3 and that Mary is f4.

If we are only interested in the truth or falsity of a sentence, we have two choices in creating the sentence space SS: it can be spanned by two basis vectors 0|0\rangle and 1|1\rangle representing the truth values of true and false, or just by a single vector 1\overrightarrow{1}, which we identify with true, the origin 0\overrightarrow{0} is then identified with false (so we use Dirac notation for the basis to distinguish between the origin 0\overrightarrow{0} and the 0|0\rangle basis vector). This latter approach might feel a little unintuitive, but it enables us to establish a convenient connection with the relational Montague-style models of meaning, which we shall present in the last section of the paper.

The transitive verb \mbox\emlikes\overrightarrow{\mbox{\em likes}} is encoded as the superposition:

where \mbox\emlikesij=1\overrightarrow{\mbox{\em likes}}_{ij}=\overrightarrow{1} if mi likes fj and \mbox\emlikesij=0\overrightarrow{\mbox{\em likes}}_{ij}=\overrightarrow{0} otherwise. Of course, in practice, the vector that we have constructed here would be obtained automatically from data using some suitable method.

So we indeed obtain the correct truth-value meaning of our sentence. We are not restricted to the truth-value meaning; on the contrary, we can have, for example, degrees of meaning, as shown in section 5.

Example 1b.

Two Dimensional Truth-Theoretic Meaning. It would be more intuitive to assume that the sentence space SS is spanned by two vectors 0|0\rangle and 1|1\rangle, which stand for false and true respectively. In this case, the computing of the meaning map proceeds in exactly the same way as in the one dimensional case. The only difference is that when the sentence “John likes Mary” is false, the vector likesij takes the value 0|0\rangle rather than just the origin 0\overrightarrow{0}, and if it is true it takes the value 1|1\rangle rather than 1\overrightarrow{1}.

2 Negative Transitive Sentence

The types of a sentence with negation and a transitive verb, for example “John does not like Mary”, are:

Similar to the positive case, we assume the vector spaces of the subject and object are atomic (V,n),(W,n)(V,n),(W,n). The meaning space of the auxiliary verb is (VSJV,nrsjlσ)(V\otimes S\otimes J\otimes V,n^{r}sj^{l}\sigma), that of the negation particle is (VJJV,σrjjlσ)(V\otimes J\otimes J\otimes V,\sigma^{r}jj^{l}\sigma), and that of the verb is (VJW,σrjnl)(V\otimes J\otimes W,\sigma^{r}jn^{l}). The ‘from-meaning-of-words-to-meaning-of-a-sentence’ linear map ff is:

When applied to the meaning vectors of words one obtains:

where does\overrightarrow{does} and not\overrightarrow{not} are the vectors corresponding to the meanings of “does” and “not”. Since these are logical function words, we may decide to assign meaning to them manually and without consulting the document. For instance, for does we set:

which shows that we only relied on structural morphisms.

As we will demonstrate in the examples below, by relying only on η\eta-maps, does acts very much as an ‘identity’ with respect to the flow of information between the words in a sentence. This can be formalized in a more mathematical manner. There is a well-known bijective correspondence between linear maps of type VWV\to W and vectors in VWV\otimes W. Given a linear map f:VWf:V\to W then the corresponding vector is:

where {ei}i\{\overrightarrow{e}_{i}\}_{i} is a basis for VV. Diagrammatically we have:

Take this linear map to be the identity on VV and we obtain ηV\eta_{V}.

The trick to implement not will be to take this linear map to be the linear matrix representing the logical not. Concretely, while the matrix of the identity is (1001)\begin{pmatrix}1&0\\ 0&1\end{pmatrix}, the matrix of the logical not is (0110)\begin{pmatrix}0&1\\ 1&0\end{pmatrix}. In Dirac notation, the vector corresponding to the identity is 00+11|00\rangle+|11\rangle, while the vector corresponding to the logical not is 01+10|01\rangle+|10\rangle. While we have

Substituting all of this in f(vdoesnotΨw)f(\overrightarrow{v}\otimes\overrightarrow{does}\otimes\overrightarrow{not}\otimes\overrightarrow{\Psi}\otimes\overrightarrow{w}) we obtain, diagrammatically:

which by the diagrammatic calculus of compact closed categories is equal to:

where the configuration on the left always encodes the transpose and the matrix of the not is obviously self-transpose. In the language of vectors and linear maps, the left hand side of eq. (7) is:

Note that the above pictures are very similar to the ones encountered in which describe quantum informatic protocols such as quantum teleportation and entanglement swapping. There the morphisms η\eta and ϵ\epsilon encode Bell-states and corresponding measurement projectors.

Negative Truth-Theoretic Meaning. The meaning of the sentence

is calculated as follows. We assume that the vector spaces S=JS=J are spanned by the two vectors as in Example 1b, 1=(01)|1\rangle=\begin{pmatrix}0\\ 1\end{pmatrix} and 0=(10)|0\rangle=\begin{pmatrix}1\\ 0\end{pmatrix}. We assume that 1|1\rangle stands for true and that 0|0\rangle stands for false. Vector spaces VV and WW are as in the positive case above. The vector of like is as before:

Setting N=\left(\begin{array}[]{cc}0&1\\ 1&0\end{array}\right) we obtain:

That is, the meaning of “John does not like Mary” is true if like34\overrightarrow{like}_{34} is false, i.e. if the meaning of “John likes Mary” is false.

For those readers who are suspicious of our graphical reasoning, here is the full-blown symbolic computation. Abbreviating 10+01|10\rangle+|01\rangle to n\overline{n} and 00+11|00\rangle+|11\rangle to d\overline{d}, and setting f=hgf=h\circ g with

Comparing meanings of sentences

One of the advantages of our approach to compositional meaning is that the meanings of sentences are all vectors in the same space, so we can use the inner product to compare the meaning vectors. This measure has been referred to and widely used as a degree of similarity between meanings of words in the distributional approaches to meaning . Here we extend it to strings of words as follows.

Two strings of words w1wkw_{1}\cdots w_{k} and w1wlw^{\prime}_{1}\cdots w^{\prime}_{l} have degree of similarity mm iff their Pregroup reductions result in the same grammatical typeIf one wishes to do so, meaning of phrases that do not have the same grammatical types can also be compared, but only after transferring them to a common dummy space. and we have

where v\mid\overrightarrow{v}\mid is the norm of v\overrightarrow{v}, that is, v2=vv\mid\overrightarrow{v}\mid^{2}=\langle\overrightarrow{v}\mid\overrightarrow{v}\rangle, and f,ff,f^{\prime} are the meaning maps defined according to definition 3.2

Thus we use this tool to compare meanings of positive sentences to each other, meanings of negative sentences to each other, and more importantly meanings of positive sentences to negative ones. For example, we compare the meaning of “John likes Mary” to “John loves Mary”, the meaning of “John does not like Mary” to “John does not love Mary”, and also the meaning of the latter two sentences to “John likes Mary” and “John loves Mary”. To make the examples more interesting, we assume that “likes” has degrees of both “love” and “hate”.

Hierarchical Meaning. Similar to before, we have:

where \mbox\emlovesij=1\overrightarrow{\mbox{\em loves}}_{ij}=|1\rangle if \mbox\emmi{\mbox{\em m}}_{i} loves \mbox\emfj{\mbox{\em f}}_{j} and \mbox\emlovesij=0\overrightarrow{\mbox{\em loves}}_{ij}=|0\rangle otherwise, and \mbox\emhatesij=1\overrightarrow{\mbox{\em hates}}_{ij}=|1\rangle if \mbox\emmi{\mbox{\em m}_{i}} hates \mbox\emfj{\mbox{\em f}_{j}} and \mbox\emhatesij=0\overrightarrow{\mbox{\em hates}}_{ij}=|0\rangle otherwise. Define likes to have degrees of love and hate as follows:

The meaning of our example sentence is thus obtained as follows:

Example 4. Negative Hierarchical Meaning. To obtain the meaning of “John does not like Mary” in this case, one inserts 34lovesij+14hatesij{3\over 4}\overrightarrow{loves}_{ij}+{1\over 4}\overrightarrow{hates}_{ij} for likesij\overrightarrow{likes}_{ij} in the calculations and one obtains:

That is, the meaning of “John does not like Mary” is the vector obtained from the meaning of “John likes Mary” by swapping the basis vectors.

Example 5. Degree of similarity of positive sentences. The meanings of the distinct verbs lovesloves, likeslikes and hateshates in the different sentences propagate through the reduction mechanism and reveal themselves when computing inner-products between sentences in the sentence space. For instance, the sentence “John loves Mary” and “John likes Mary” have a degree of similarity of 3/4, calculated as follows:

In the above, we expand the definition of \mbox\emlikes34\overrightarrow{\mbox{\em likes}}_{34} and obtain:

\left\langle\overrightarrow{\mbox{\em loves}}_{34}\bigm{|}{3\over 4}\overrightarrow{\mbox{\em loves}}_{34}+{1\over 4}\overrightarrow{\mbox{\em hates}}_{34}\right\rangle=

and since \mbox\emloves34\overrightarrow{\mbox{\em loves}}_{34} and \mbox\emhates34\overrightarrow{\mbox{\em hates}}_{34} are always orthogonal, that is, if one is 1|1\rangle then the other one is 0|0\rangle, we have that

Hence the degree of similarity of these sentences is 34\frac{3}{4}. A similar calculation provides us with the following degrees of similarity. For notational simplicity we drop the square of norms from now on, i.e. we implicitly normalize meaning vectors.

\left\langle\overrightarrow{\mbox{\it John hates Mary}}\bigm{|}\overrightarrow{\mbox{\it John likes Mary}}\right\rangle=

\left\langle\overrightarrow{\mbox{\it John loves Mary}}\bigm{|}\overrightarrow{\mbox{\it John hates Mary}}\right\rangle=

Example 6. Degree of similarity of negative sentences. In the negative case, the meaning of the composition of the meanings of the auxiliary and negation markers (“does not”), applied to the meaning of the verb, propagates through the computations and defines the cases of the inner product. For instance, the sentences “John does not love Mary” and “John does not like Mary” have a degree of similarity of 3/4, calculated as follows:

\left\langle\overrightarrow{\mbox{\it John does not love Mary}}\bigm{|}\overrightarrow{\mbox{\it John does not like Mary}}\right\rangle= \left\langle f\big{(}\overrightarrow{m\!}_{3}\otimes\overrightarrow{does}\otimes\overrightarrow{not}\otimes\overrightarrow{\mbox{\em love}}\otimes\overrightarrow{f}_{4}\big{)}\Bigm{|}f\big{(}\overrightarrow{m\!}_{3}\otimes\overrightarrow{does}\otimes\overrightarrow{not}\otimes\overrightarrow{\mbox{\em like}}\otimes\overrightarrow{f}_{4}\big{)}\right\rangle =\left\langle\overrightarrow{\mbox{\em hates}}_{34}\Bigm{|}{1\over 4}\overrightarrow{\mbox{\em loves}}_{34}+{3\over 4}\overrightarrow{\mbox{\em hates}}_{34}\right\rangle ={1\over 4}\left\langle\overrightarrow{\mbox{\em hates}}_{34}\Bigm{|}\overrightarrow{\mbox{\em loves}}_{34}\right\rangle+{3\over 4}\left\langle\overrightarrow{\mbox{\em hates}}_{34}\Bigm{|}\overrightarrow{\mbox{\em hates}}_{34}\right\rangle={3\over 4}

Example 7. Degree of similarity of positive and negative sentences. Here we compare the meanings of positive and negative sentences. This is perhaps of special interest to linguists of distributional meaning, since these sentences do not have the same grammatical structure. That we can compare these sentences shows that our approach does not limit us to the comparison of meanings of sentences that have the same grammatical structure. We have:

The following is the most interesting case:

This value might feel non-intuitive, since one expects that “like” and “does not like” have zero intersection in their meanings. This would indeed be the case had we used our original truth-value definitions. But since we have set “like” to have degrees of “love” and “hate”, their intersection will no longer be 0.

Using the same method, one can form and compare meanings of many different types of sentences. In a full-blown vector space model, which has been automatically extracted from large amounts of text, we obtain ‘imperfect’ vector representations for words, rather than the ‘ideal’ ones presented here. But the mechanism of how the meanings of words propagate to the meanings of sentences remains the same.

Relations vs Vectors for Montague-style semantics

The reader can verify that this composition induces matrix multiplication of the corresponding matrices.

Interestingly, in the world of relations (but not functions) there is a notion of superposition . The relations of type r{}×Xr\subseteq\{*\}\times X (in matricial terms, all column vectors with ’s and 11’s as entries) are in bijective correspondence with the subsets of XX via the correspondence

Each such subset can be seen as the superposition of the elements it contains. The inner-product of two subsets is if they are disjoint and 11 if they have a non-empty intersection. So we can think of two disjoint sets as being orthogonal.

Since the abstract nature of our procedure for assigning meaning to sentences did not depend on the particular choice of FVect{\bf FVect} we can now repeat it for the following situation: {diagram} In FRel×P{\bf FRel}\times P we recover a Montague-style Boolean semantics. The vector spaces in this setting are encodings of sets of individuals and relations over these sets. Inner products take intersections between the sets and eta maps produce new relations by connecting pairs that are not necessarily side by side.

In all our examples so far, the vector spaces of subject and object were essentially sets that were encoded in a vector space framework. This was done by assuming that each possible male subject is a base in the vector space of males and similarly for the female objects. That is why the meaning in these examples was a truth-theoretic one. We repeat our previous calculations for example 1 in the relational setting of FRel×P{\bf FRel}\times P.

Example 1 revisited. Consider the singleton set {}\{*\}; we assume that it signifies the vector space SS. We assume that the two subsets of this set, namely {}\{*\} and \emptyset, will respectively identify true and false. We now have sets VV, WW and T=V×{}×WT=V\times\{*\}\times W with

where ij*_{ij} is either {}\{*\} or \emptyset. So we obtain

Future Work

This paper aims to lay a mathematical foundation for the new field of compositional distributional models of meaning in the realm of computational and mathematical linguistics, with applications to language processing, information retrieval, artificial intelligence, and in a conceptual way to the philosophy of language. This is just the beginning and there is so much more to do, both on the practical and the theoretical sides. Here are some examples:

On the logical side, our “not” matrix works by swapping basis and is thus essentially two dimensional. Developing a canonical matrix of negation, one that works uniformly for any dimension of the meaning spaces, constitutes future work. The proposal of in using projection to the orthogonal subspace might be an option.

A similar problem arises for the meanings of other logical words, such as “and”, “or”, “if then”. So we need to develop a general logical setting on top of our meaning category FVect×P{\bf FVect}\times{\bf P}. One subtlety here is that the operation that first come to mind, i.e. vector sum and product, do not correspond to logical connective of disjunction and conjunction (since e.g. they are not fully distributive). However, the more relaxed setting of vector spaces enables us to also encode words such as ”but”, whose meaning depends on the context and thus do not have a unique logical counterpart.

Formalizing the connection with Montague-semantics is another future direction. Our above ideas can be generalized by proving a representation theorem for Fvect×P{\bf Fvect}\times{\bf P} on the semiring of Booleans with respect to the category of FRel{\bf FRel} of sets and relations. It would then be interesting to see how the so called ‘non-logical’ axioms of Montague are manifested at that level, e.g. as adjoints to substitution to recover quantifiers.

Along similar semantic lines, it would be good to have a Curry-Howard-like isomorphism between non-commutative compact closed categories, bicompact linear logic , a version of lambda calculus. This will enable us to automatically obtain computations for the meaning and type assignments of our categorical setting.

Our categorical axiomatics is flexible enough to accommodate mixed states , so in principle we are able to study their linguistic significance, and for instance implement the proposals of .

Finally, and perhaps most importantly, the mathematical setting needs to be implemented and evaluated, by running experiments on real corpus data. Efficiency and the complexity of our approach then become an issue and need to be investigated, along with optimization techniques.

Acknowledgements

Support from EPSRC Advanced Research Fellowship EP/D072786/1 and European Committee grant EC-FP6-STREP 033763 for Bob Coecke, EPSRC Postdoctoral Fellowship EP/F042728/1 for Mehrnoosh Sadrzadeh, and EPSRC grant EP/E035698/1 for Stephen Clark are gratefully acknowledged. We thank Keith Van Rijsbergen, Stephen Pulman, and Edward Grefenstette for discussions, and Mirella Lapata for providing relevant references for vector space models of meaning.

References