TTTV tentamen 2

Hoorcollege 8

Events and the thematic roles of their participants

Different word classes have different kinds of meaning. For instance:

nouns refer to entities (objects, individuals (people), ‘things’, etc)

verbs refer to events (actions, states, ‘what happens’)

The verb in a sentence tells us what happens (introduces an event) while the NPs provide the arguments for the verb: they tell us which entities take part in the event. Arguments can play different roles in the event introduced by a verb:

Semantic role of the arguments (thematic role):

the journalist resigned.

Agent

the boss fired the journalist.

Agent – Patient/Theme

the journalist wrote an article.

Agent – Patient/Theme

the journalist lost his job.

Experiencer – Theme

Common thematic roles

Role

Example

Agent

The waiter spilled the soup.

Experiencer

John has a headache.

Force

The wind blows debris from the mall into our yards.

Patient/Theme

Dona broke the ice.

Result

Maike built new shelves for her cabinet.

Content

Tim asked “Would you like some tea?”

Instrument

Addison destroyed the door with a hammer.

Beneficiary

Tim made a reservation for his father

Source

Sophie came back from Groningen.

Goal

Jari biked to the Bijlmer.

Thematic roles are semantic!

Thematic roles are semantic functions of arguments, not syntactic functions. Thematic roles help us generalise over different surface realisations of predicate arguments:

  • Pim broke the window.
  • Pim broke the window with a rock.
  • The rock broke the window.
  • The window broke.
  • The window was broken by Pim.

These examples suggest that break has (at least) three possible semantic arguments – agent, patient, and instrument – but these arguments can be syntactically realised in different ways.

agent Subject NP, PP (by)

patient Object NP, Subject NP

instrument PP (with), Subject NP

Adding events and roles to logical formulae

Our FOL representation of verbs as simple predicates does not make explicit which thematic roles their arguments play.

a boss fired a journalist ⇝ ∃x.∃y .[Boss(x) ∧ Journalist(y ) ∧ Fire(x, y )]

We can make this more precise by including variables for events and additional predicates for thematic roles in our PL meaning representations.

∃e.∃x.∃y .[Boss(x) ∧ Journalist(y ) ∧ Firing(e) ∧ Agent(x, e) ∧ Theme(y , e)]

This is just an even finer-grained version of the neo-Davidsonian representations we saw last time!

Examples:

  • Anne drives to New York.

∃e.∃t1.∃t2.[Driving(e) ∧ Agent(a, e) ∧ Goal(ny , e) ∧ Start(t1, e) ∧ End(t2, e) ∧ (t1 ⪯ Now ⪯ t2)]

  • Anne drove to New York.

∃e.∃t.[Driving(e)∧Agent(a, e)∧Goal(ny , e)∧End(t, e)∧(t ≺ Now)]

  • Anne will drive to New York.

∃e.∃t.[Driving(e)∧Agent(a, e)∧Goal(ny , e)∧Start(t, e)∧(Now ≺ t)]

  • Pim broke the window

∃e.∃t.[Break(e) ∧ Agent(p, e) ∧ Theme(w , e) ∧ End(t, e) ∧ (t ≺ Now)]

  • Pim broke the window with a rock

∃e.[Break(e) ∧ Agent(p, e) ∧ Theme(w , e) ∧ Instrument(r, e) ∧ End(t, e). . . ]

  • The rock broke the window.

∃e.[Break(e) ∧ Theme(w , e) ∧ Instrument(r, e) ∧ End(t, e). . . ]

  • The window broke.

∃e.[Break(e) ∧ Theme(w , e) ∧ End(t, e). . . ]

  • The window was broken by Pim.

∃e.[Break(e) ∧ Theme(w , e) ∧ Agent(p, e) ∧ End(t, e). . . ]

Lexical semantics

A bank can hold investments in the name of a client.

We must protect the bank for the river to survive.

Most languages have many homonyms: lemmas that are morphologically and syntactically identical but nonetheless have multiple semantic senses.

How can we be sure that a language processing system ‘understands’ these differing word senses?

Lexical semantics: word forms vs. word senses

One aspect that makes lexical semantics a challenging problem is that the relation between form and meaning is not one-to-one.

  • One lemma can mean different things: homonymy.
  • bank:

bank1 the slope of land adjoining a body of water

bank2 a business establishment in which money is kept

  • Homonymy is a source of lexical ambiguity.

Different lemmas can have the same meaning: synonymy.

  • buy / purchase
  • car / automobile

Word senses are the meanings associated with lemmas.

  • We may use the terms word or word form to refer to lemmas, but remember that we are dealing with lemmas – i.e., we ignore the distinction between ‘buy’, ‘buys’, ‘bought’, and ‘buying’.

Relations between senses

synonymy: a relation of (near) semantic identity between senses

buy/purchase big/large shore/bank

antonymy: a relation of semantic oppositeness between senses

tall/short dead/alive buy/sell

Synonymy and antonymy are symmetric relations: if A is a synonym/antonym of B, then B is a synonym/antonym of A.

  • Synonymy can be characterised logically: ∀x.[A(x) ↔ B(x)]

∀x.[Big(x) ↔ Large(x)] ∀x.∀y .[Buy(x, y ) ↔ Purchase(x, y )]

  • How can antonymy be logically defined? → it cannot!

Hyponymy and hypernymy

hyponymy and hypernymy: a relation of semantic inclusion that holds between a more general term (the hypernym) and a more specific term (the hyponym)

bird is a hypernym of seagull seagull is a hyponym of bird

  • Hyponymy and hypernymy are not symmetric. They are complements of each other.
  • If A is a hyponym of B (and hence B is a hypernym of A), then ∀x.[A(x) → B(x)] (but ∀x.[B(x) → A(x)] is not true).
  • Both relations are transitive: if A is a hyponym of B and B is a hyponym of C, then A is a hyponym of C.

meronymy vs. holonymy: a part–whole relation

wheel is a meronym of bike bike is a holonym of wheel

The class-inclusion relation defined by hyponymy and hypernymy gives rise to a concept hierarchy or taxonomy. Fragment of a possible concept hierarchy:

  • golden, elstar, granny_smith, apple, and pear

are hyponyms of fruit

  • fruit is the direct hypernym of apple and pear

and the inherited hypernym of golden, elstar,

and granny_smith

  • apple is the co-hyponym or sister term of pear
  • golden, elstar, and granny_smith are

co-hyponyms or sister terms

WordNet

WordNet is the most widely used lexical resource in computational linguistics.

It is a lexical database organised as an ontology: you can think of it as a dictionary with sense relations. It is organised as an ontology as follows.

  • The nodes in the taxonomy are senses, called synsets for ‘sets of synonyms’ (sets of synonymous lemmas).
  • The main sense relation (besides synonymy) represented in WordNet is hypernymy/hyponymy. This generates a hierarchy of concepts, from more general at the root to more specific.
  • Other relations are also present, e.g. meronymy or antonymy for adjectives.

WordNet can be searched online at:

http://wordnetweb.princeton.edu/perl/webwn

When you search for a lemma, amongst other things you can explore the following.

  • the possible senses of a lemma (to which synsets it belongs)
  • the set of synonyms in each synset the lemma belongs to
  • a dictionary style definition (also called a gloss) for each sense
  • a set of usage examples for each sense
  • for each sense (synset) the direct hypernyms/hyponyms and the inherited hypernyms/hyponyms – the path in the taxonomy

NLTK also has an interface for WordNet, but without a graphical interface, it is harder to get an intuition for WordNet’s power.

Semantics

Earlier we have seen:

  • that verbs refer to events and their arguments to the participants in these events, and
  • that verbs constrain the thematic roles their arguments can play.

Besides thematic roles, verbs impose another type of semantic constraints on their arguments: selectional restrictions.

The student ate the smoke. The chair eats the pizza. Muffins eat books.

Why are these sentences weird?

Verbs impose semantic constraints on the type of entities that can fill in their thematic roles. In this case, there seem to be violations of the semantic restrictions imposed by eat.

[N.B.: Verbs also impose syntactic selectional restrictions: recall agreement features!]

Selectional restrictions and WordNet

We can exploit an ontology like WordNet to express the selectional restrictions of verbs.

  • eat has at least two semantic arguments Agent, Theme
  • We can express semantic constraints on arguments in the form of a concept in an ontology (a WordNet synset), any hyponym of such a concept should be an appropriate argument.
  • A sentence respects the verb’s selectional restrictions if the entities that fill in the arguments are hyponyms of the relevant concepts.

Example:

  • Verb: eat
  • Thematic roles of arguments: Agent, Patient/Theme
  • Selectional restrictions imposed on each role:

Agent : concept1, Patient/Theme : concept2

  • Assign WordNet synsets to each concept. For example:

– concept1: {living thing, animate thing}

– concept2: {food, nutrient}

Summary

We have started to look into lexical semantics. At the interface of compositional and lexical semantics, we have seen:

  • A more expressive way to represent the meaning of verbs and their arguments by introducing events to first-order logic formulae. This allows us to:
  • make explicit the thematic roles that verb arguments play, and
  • express temporal relations.
  • These event representations are known as neo-Davidsonian after the philosopher Donald Davidson.
  • Word forms are not the same as word senses
  • Lexical semantic relations can hold between word senses.
  • synonymy
  • antonymy
  • hypernymy / hyponymy
  • meronymy / holonymy
  • Senses (concepts) can be organised into a concept hierarchy (an ontology) such as WordNet.
  • Verbs may impose additional constraints on the kind of concepts that can realise their thematic roles.
  • We can exploit an ontological structure like WordNet to express these selectional restrictions.

Next time, we will look into lexical semantic ambiguity (more than one sense per lemma) and at methods for sense disambiguation.

Hoorcollege 9

Recap

We started to look into lexical semantics, the sub-discipline of semantics concerned with the meaning of words.

  • Event semantics: thematic roles, and selectional restrictions
  • Word forms vs. word senses
  • a word can have more than one sense (express more than one concept)
  • Lexical semantic relations
  • synonymy & antonymy
  • hyponymy & hypernymy
  • meronymy & holonymy
  • WordNet: a computational ontology organized around synonymy (synsets), and hypernymy/hyponymy

Ambiguity

We saw last time that the relation between word forms and word senses is not one to one.

  • Different lemmas can have the same meaning: synonymy
  • buy / purchase
  • car / automobile
  • One lemma can mean different things: homonymy
  • bank:

bank1:the slope of land adjoining a body of water

bank2:a business establishment in which money is kept

Both synonymy and homonymy are sources of ambiguity. Which one poses a difficulty for natural language generation and which one instead for natural language understanding?

Both synonymy and homonymy are sources of ambiguity, which one poses a difficulty for natural language generation and which one instead for natural language understanding?

  • Synonymy is a source of ambiguity for natural language generation: which word to use to express a concept.
  • Homonymy is a source of ambiguity for natural language understanding (e.g. machine translation and question answering)

WordNet

Some of the senses of the noun “book”, indexed and with glosses:

  • book1: a written work (printed on pages bound together)
  • book5: a record in which commercial accounts are recorded
  • book9: the sacred writings of the Christian religions

Each sense is linked to its SynSet, the set of near-synonyms:

{ledger1, book of account1, book5}

WordNet represents the concept of a word sense as a list of related word senses. The meaning of words is thus not defined by logical terms, but by semantic similarity between words.

Homonymy vs. polysemy

Lexical ambiguity: one phonological form, several senses.

But not all ambiguous forms exhibit the same kind of ambiguities:

Homonymy: accidental ambiguity between unrelated senses

  1. a. Mary walked along the bank of the river.

b. ABN Amro is the richest bank in the city.

  1. a. Nadia’s plane taxied to the terminal.

b. The central data storage device is served by multiple terminals.

c. He disliked the angular planes of his cheeks and jaw.

Polysemy: ambiguity between semantically related senses

  1. a. The bank raised its interest rates yesterday.

b. The store is next to the newly constructed bank.

  1. a. The lamb is running in the field.

b. John ate lamb for dinner.

  1. a. John spilled coffee on the newspaper

b. The newspaper fired its editor.

In dictionaries, it is common to have a different lexical entry for each homonymous sense or group of senses, but to group polysemous senses within one lexical entry.

The distinction between homonymy and polysemy is one of degree: there is no hard threshold for how related two senses must be to be considered polysemous.

Homophones and homographs

There are two other types of lexical ambiguity that cause problems when dealing with spoken language.

break / brake knows / nose

to / too / two waste / waist

Homophones: one pronunciation (within a dialect) but several forms and several senses

Homographs: one form but several senses and several pronunciations

All candidates are PRE-sent today. She entered a math CON-test.

The boss will pres-ENT the award at 10:00. We con-TEST the results.

Homophones and homographs both cause difficulties when it comes to applications dealing with speech. Which one causes problems for speech synthesis and which one for speech recognition?

Homophones and homographs both cause difficulties when it comes to applications dealing with speech. Which one causes problems for speech synthesis and which one for speech recognition?

  • Homophones cause problems for speech recognition.
  • Homographs cause problems for speech synthesis.

Word sense disambiguation

Word sense disambiguation (WSD): the task of detecting which sense of a word is being used in a given context.

Nadia’s plane taxied to the terminal.

The central data storage device is served by multiple terminals.

He disliked the angular planes of his cheeks and jaw.

The compositional approach we looked at last week ignored this problem. But it is critical for many NLP applications.

Task for WSD algorithms:

  1. Take as input a word in context (e.g. a sentence)
  2. Return as output the correct word sense for that use.

Input and output vary across applications. For instance:

  • machine translation: Input word in language A and a list of possible translations in language B.
  • speech synthesis: Input word and a list of possible pronunciations (homographs).

Methods

Different methods are used to perform word sense disambiguation.

  • Supervised machine-learning methods: Given a corpus of sense-tagged words, we can train supervised machine learning algorithms to predict which is the most likely sense in each context.

Two examples in §20.2.2 of the book: naive Bayes and decision lists

  • Dictionary- and thesaurus-based methods : Exploit knowledge encoded in a taxonomy such as WordNet to choose the most likely sense.

Many approaches combine these styles: machine-learning algorithms that exploit information from WordNet.

Supervised corpus-based approaches

Most approaches see disambiguation as a classification task.

  • Tokens (word occurrences) are the items to be classified.
  • Word senses are the classes.

A classifier is called supervised if it is built based on training data containing the correct label for each item.

  • SemCor: 234k words from Brown Corpus tagged with WordNet senses
  • SensEval data sets

Each item is represented as feature vector encoding evidence that can help to determine its class.

The output of training is a classification system capable of assigning one or more classes to each item based on information provided by the features.

Features for WSD classifiers

There are two major types of features used in classifiers for word sense disambiguation.

An electric guitar and bass player stand off to the side of the band.

Collocational features record information about specific positions to the left and right of a target word.

  • → Mainly the neighboring words, but also part of speech tags .

[guitar, NN, and, CC, player, NN, stand, VB]

Bag-of-words features record information about the general context (e.g. the whole sentence).

  • → Bag-of-words features are often (sparse) binary vectors showing which of the most common words in the corpus are present.

fishing big sound player fly rod double playing guitar band

0 0 0 1 0 0 0 0 1 1

Naive Bayes for WSD

Given a set of word senses S and a feature vector f, we want to find a

most likely sense:

Given a particular word, our features never change, and thus:

We make the naive Bayes assumption that features are conditionally independent given the word sense:

We ‘train’ our classifier by counting the relative frequencies of each word sense (per word) and features (per word sense) in the corpus.

Decision list for WSD (more details in J&M)

Given a set of word senses S and a feature vector f, we want to find a most likely sense:

  • Apply a sequence of tests to each target-word feature vector, where each test is indicative of a particular sense

Note on learning methods

Many different supervised learning algorithms have been used for WSD. Pretty much any supervised machine learning method has been used for WSD: Naive Bayes, Maximum Entropy, Decision Trees, Support Vector Machines, Neural Networks, etc.

  • Learning methods deserve an entire course of their own
  • You will learn about machine learning methods in the course ‘Leren’ next year.
  • In section 20.2.2 of J&M you have sketches of two methods: Naive Bayes and Decision Lists - I don’t expect you to know all the details of these methods
  • In the course ‘Natuurlijke Taalmodellen en Interfaces’ you will see learning methods applied to NLP.

What is the main disadvantage of supervised learning algorithms?

Dictionary and thesaurus methods

Supervised algorithms are the best-performing algorithms for WSD but labelled training data sets are expensive and limited.

We can use WordNet as an indirect kind of supervision.

The best known WordNet-based algorithm is the Lesk algorithm.

  • A family of algorithms that take into account the amount of overlap between the context of the input word and the gloss and examples (the signature) of each potential sense.
  • Often used as a baseline when evaluating more sophisticated supervised-learning models.

The simplified Lesk algorithm

It chooses the sense whose signature shares most words with the context of the input word. If there is none, because there is no overlap, it takes the most frequent sense. (Why?)

When calculating overlap, we ignore stop words that occur too frequently in the language to help disambiguate.

The Lesk Algorithm Family

  • Simplified Lesk: We have just seen it.
  • Original Lesk: The signatures of the context words are compared to the signatures of the input word.
  • Corpus Lesk: This is the best-performing version.
  • Take a sense-tagged corpus (e.g., SemCor).
  • For each possible sense, consider not only the signature of that sense in WordNet, but also the sentences in the corpus with that word sense.
  • Instead of simply counting up overlap, we weight by inverse document frequency: the overlap has more weight if it involves a less frequent word.

We will revisit IDF when we see information retrieval next week.

WSD and selectional restrictions

The selectional restrictions of predicates can also help us to disambiguate the words that fill in their arguments.

Each kid ate a cookie.

She deleted a cookie.

The cookie served a simple hearty dinner.

The selectional restrictions of eat, delete, and serve give us clues as to which sense of cookie is being used in each case.

Word similarity

Word similarity or semantic distance is a metric that tells us how similar the meanings of two words are. It is a looser concept than the lexical relations of synonymy, antonymy, hyponymy, etc.

  • two word senses are more similar if they share more features of meaning
  • and they are less similar (or have greater semantic distance) if they have fewer features of meaning in common.

Computing word similarity is important for many NLU applications.

  • In information retrieval and question-answering systems, we may want to check how similar the words in a query are to the words in potential answers.
  • In automatic summarisation, we need to make sure that the words used in a summary are similar enough to the words used in the original text.

We will look into two approaches to word similarity:

  • Ontology-based methods (today)
  • Distributional methods (next week)

Ontology-based method 1: path-length similarity

In an ontological structure such as WordNet, word senses (or synsets) are connected by hyponymy/hypernymy relations. This allows us to represent it as a tree-like hierarchy. We can define the path-length between two senses or concepts c1 and c2 (two synsets in WordNet) as the number of edges in the shortest path between nodes c1 and c2.

  • Path-length(c1, c2) = number of edges in shortest path
  • The lower the path length, the higher the similarity.
  • Path-length is defined on concepts in an ontology. To approximate word similarity based on path-length, we take the minimum path-length between all pairs of senses for (w1, w2).

Path-length similarity

Path-length similarity treats all edges equally, as if they all represented the same degree of semantic distance. But this is not always in accordance to our intuitions.

Ontology-based method 2: Resnik Similarity

Resnik similarity implements the intuition that nodes that are further up in the hierarchy are at further distance.

It does so by adding probabilities to the nodes in the hierarchy.

  • The probability of a sense or concept P[c] is the probability that a random word is associated with that concept.
  • We can calculate these probabilities from a corpus: each word in the corpus counts as an occurrence of all of its hypernyms.

where words(c) is the set of words with senses that are hyponyms of c (words subsumed by c) and N is the total of words in the corpus.

Resnik Similarity

We can augment the nodes in the tree-like hierarchy with these probabilities.

Resnik similarity between c1 and c2: the probability of their most specific common hypernym. The lower this probability, the higher the similarity.

We can augment the nodes in the tree-like hierarchy with these probabilities.

  • What is the Resnik similarity between “hill” and “coast”?
  • What is the Resnik similarity between “natural-elevation” and “shore”?

Ontology-based method 3: extended Lesk similarity

Two senses/concepts are more similar the more overlap there is between their glosses.

  • For each string of words of length n that overlaps, we add a score n2 (longer overlaps get more weight).
  • We sum all these scores to get a general overlap score.

drawing paper: paper that is specially prepared for use in drafting

decal: the art of transferring designs from specially prepared paper to a wood or glass or metal surface

“paper”, “specially prepared”

Overlap score: 12 + 22 = 5

  • The extended overlap score takes into account also the overlap between any glosses of concepts related to c1 and c2 (the overlap between the glosses of the hypernyms of c1 and c2, their hyponyms, their sister terms, etc.).
  • The higher the extended overlap score, the higher the similarity.

Summary

  • Lexical ambiguity: one lemma, more than one sense. We can distinguish between homonymy and polysemy.
  • Word sense disambiguation (WSD) is the task of choosing the appropriate sense of a lexically ambiguous word in context.
  • Two types of approaches to WSD:
  • Supervised machine-learning approaches (e.g. naive Bayes)
  • WordNet-based approaches (e.g. the Lesk family)
  • Word semantic similarity
  • Thesaurus-based methods (e.g. path-length, Resnik, extended Lesk)

Hoorcollege 10

Recap

We looked into lexical semantics: focusing on the meaning of words.

  • Lexical ambiguity
  • homonymy vs. polysemy
  • word sense disambiguation using thesaurus methods: the Lesk family
  • Semantic similarity (today!)
  • thesaurus-based methods: exploit an ontology like WordNet
    • path-length based similarity
    • Resnik similarity
    • extended Lesk similarity

Limitations of thesaurus-based methods

Limitations of thesaurus-based methods for semantic similarity:

  • not all words may be included in a thesaurus WordNet
  • they are built manually: time-consuming and resource intensive

Distributional semantics: bardiwac

What is the meaning of bardiwac?

  • He handed her her glass of bardiwac.
  • Beef dishes are made to complement the bardiwacs.
  • Nigel staggered to his feet, face flushed from too much bardiwac.
  • Malbec, one of the lesser-known bardiwac grapes, responds well to Australia’s sunshine.
  • I dined on bread and cheese and this excellent bardiwac.
  • The drinks were delicious: blood-red bardiwac as well as light, sweet Rhenish.

We are able to guess the meaning of bardiwac because the contexts in which it occurs (its distribution) are similar to the contexts where other known words appear:

similar distributions ⇔ similar meaning

The distributional hypothesis

The basic idea behind distributional methods is that word meaning depends on the contexts in which words are used.

  • → From the contexts in which it occurs, we can infer that bardiwac is a heavy red alcoholic beverage made from grapes

This type of information can be looked up directly in corpora, without need to use a manually constructed resource. They are motivated by the so-called Distributional Hypothesis.

‘The degree of semantic similarity between two linguistic expressions A and B is a function of the similarity of the linguistic contexts in which A and B can appear.’ (Harris 1954)

‘You shall know a word by the company it keeps!’ (Firth 1957)

Distributional methods and similarity

Distributional methods for semantic similarity are motivated by the Distributional Hypothesis.

‘The degree of semantic similarity between two linguistic expressions A and

B is a function of the similarity of the linguistic contexts in which A and B can appear.’ (Harris 1954)

But, to use it, we need to make this hypothesis computationally precise.

  • representations that capture the distribution of a word
  • methods to compare two distributional meaning representations to calculate word similarity

Vector representations

We can represent the meaning of a word as a vector of features that indicate whether it appears in a certain context.

w = (f1, f2, f3, . . . , fn)

f1 : w appears in the context of w1 (yes/no or how many times it appears)

f2 : w appears in the context of w2 (yes/no or how many times it appears)

Let’s assume fi takes value 1 if w appears in the context of wi and 0 otherwise:

glass dish grape drink sunshine wheel ride

bardiwac 1 1 1 1 1 0 0

wine 1 1 1 1 ? 0 0

bike 0 0 0 1 1 1 1

bardiwac = (1, 1, 1, 1, 1, 0, 0)

Distributional semantic models

A distributional semantic model (DSM) is a co-occurence matrix M:

  • rows correspond to the vector representations of our target terms (these are the “words” for which we want to compute similarity) and
  • columns correspond to the features or dimensions in the vector, representing elements that co-occur with the target terms.

Some DSM parameters

When constructing a DSM, there are several parameters to take into account. For instance:

  • the target terms (rows) and the dimensions (columns)
  • the context where we look for co-occurrences
  • the features values that measure the degree of association between target and dimension
  • the similarity measure used to compare vector representations

The target words will typically be lemmas of content (open class) words.

Target terms and dimensions

The target terms can be word forms (tokens) or lemmas (types). In traditional DSMs they are typically only content words (nouns, verbs, adjectives).

The dimensions should correspond to what is considered important to characterize the distributional meaning of a target term. For instance

  • lemmas of content words
  • a specific sub-set of “interesting” words or lemmas
  • more complex notions, including syntactic information:

Context of co-occurrence

Once we have defined our target terms and our dimensions, where do we look for co-occurrences?

We need to decide on the size or type of context where to look for co-occurrences. For instance:

  • within a window of k words around the target
  • within a particular linguistic unit:
  • a sentence
  • a paragraph
  • a document or web page

Feature values

The feature values (the values in the matrix cells) indicate the level of association of a target word with a dimension in a particular context.

  • We have seen two simple options: binary values (0/1) and frequency counts.
  • Better results are obtained if we apply a weight to the co-occurrence values that gives more importance to surprising events than to expected events:
  • the less frequent the target and the context, the higher the weight given to the observed co-occurrence count (because their expected co-occurrence from random chance is low).

One common weighting measure is mutual information, which expresses how much observing w1 tells you about w2:

  • If w1 and w2 always or never occur together, their MI is high: observing w1 gives you a lot of information about w2
  • If w1 and w2 are completely independent, their MI is low: observing w1 does not tell you anything about w2

Dimensionality reduction

The co-occurrence frequency matrix is often unmanageably large and can be extremely sparse (many cells with 0 counts).

We can compress the matrix by reducing its dimensionality, i.e. reducing the number of columns.

Projection into a subspace is one of the most common means to reduce dimensionality, and several mathematical techniques from linear algebra can be used, e.g.:

  • principal component analysis (PCA)
  • singular value decomposition (SVD)
  • . . .

(no worries, we won’t cover the details of these techniques)

DSMs and word similarity

We have represented the meaning of a word as a vector encoding its distribution (the contexts where it appears).

To compute word similarity, we need a measure that compares vectors and tells us how similar or distant they are.

Similarity measures

Cosine measure of similarity: (cosine of the) angle between two vectors

  • Result: scalar value between -1 and 1 (or 0 and 1). ‘0 means “unrelated”, 1 means “the same”.
  • In most cases, vectors should be normalized to unit length (dividing the vector by its length) - what matters is the angle. The cosine formula does this automatically.
  • Other popular distance measures: Euclidean distance, Manhattan distance

Information retrieval

Information retrieval is usually associated with web search, but it is in fact a wider field related to the storage and retrieval of different types of media.

We will focus on document retrieval in web search:

⇒ The primary task of an IR system for document retrieval is to return documents with

content that is relevant to a user’s information need.

We will focus on the vector space model of information retrieval:

⇒ This method has many parallels with the distributional semantic models for word similarity

we have seen.

document

  • an item or unit in the system available for retrieval, which may satisfy the user’s information need (web pages, news reports, encyclopedia articles, emails, paragraphs, sentences. . . )

collection

  • the set of documents the system has access to.

term

  • any word or phrase that occurs in a collection and that serves to characterise a document may be a term.

query

  • representation of the user’s information need

Basic procedure: a user poses a query to an IR system, which returns a (possibly ordered) set of potentially relevant documents from a given collection.

Vector space models of IR: preliminaries

Recall the distributional semantic models for word similarity

In this type of co-occurrence matrices, both the columns and rows are words and our representations are in the rows:

We can compare the vectors of two words (e.g. by calculating the cosine of the vectors) to quantify how semantically similar they are.

The vector space model of IR uses very similar matrices, which we call term-by-document matrices.

  • Rows represent the terms (as before). . .
  • . . . but now columns represent the documents in the collection.

In this case, our focus is on the columns.

  • The columns correspond to vector representations of documents.
  • They give clues about the topic of a document by indicating which words a document contains (bag-of-words approach).

Terms and Feature Values

The terms are typically lemmas of open-class words, excluding very high-frequency words (stop list).

The values in the cells of a term-by-document matrix (the vector features) indicate how important each term is in each document:

  • the term’s frequency in each document: tf (unweighted; either raw or normalised).
  • tf is important: terms that occur more frequently in a document reflect its topic more strongly.
  • Terms that appear only in a few documents are useful for characterising those documents, while terms that appear frequently everywhere are less useful.

Term weighting

Inverse document-frequency (IDF): the total number N of documents in the collection divided by the total number nt of documents where term t appears: N/nt

due to the large number of documents this measure is usually logarithmically scaled

  • tf-idf weighting scheme: we can multiply the term frequency by the inverse document frequency to obtain a more meaningful weight for a term in a document:

tf-idf = tft × idft .

  • tf-idf weights are higher for words that are frequent in a given document but rare in the collection.

The retrieval procedure

Given a query and a collection of documents, how do we retrieve the documents that are the most relevant to the query?

  • We represent the documents as vectors (the columns in a term-by-document matrix).
  • We also represent the query as a vector.
  • We compare the query vector to each of the documents vectors.
  • We return those documents that are the most similar to the query.

Summary

We have seen approaches related to meaning and semantics that don’t rely on logical notions, but rather on frequency and statistics.

  • Distributional semantic models for word similarity
  • co-occurrence matrix: the rows correspond to the vector representation of target terms
  • We can compute how similar the vectors of two words are.
  • Vector-space model of information retrieval
  • term-by-document matrix: the columns correspond to vector representations of documents
  • Queries are also represented as vectors.
  • We can compute how similar the query vector is to the documents vectors.

Hoorcollege 11

Recap

Meaning and semantics based on frequency and statistics.

Distributional semantic models for word similarity

  • co-occurrence matrix: the rows correspond to the vector representation of target terms
  • We can compute how similar the vectors of two words are.

Vector-space model of information retrieval

  • term-by-document matrix: the columns correspond to vector representations of documents
  • Queries are also represented as vectors.
  • We can compute how similar the query vector is to the document vectors.

Evaluation

How can we measure how good an IR or system is at returning documents which are relevant to the user’s information need?

  • Note that relevance is difficult to define precisely!
  • But let us assume we can divide the returned items into relevant and non-relevant.

We can then use the following standard measures:

precision the proportion of returned documents that are relevant.

recall the proportion of relevant documents in the collection that are part of the returned set

Evaluation: F-measure

Precision and recall tend to have an inverse relationship

  • systems that are very precise tend to have low recall
  • systems with high recall tend to be very imprecise

Therefore, usually we combine precision and recall into a single value measure:

  • F -score or F -measure: a harmonic mean of P and R
  • F is 1 when P = R = 1 and 0 when P or R are 0.
    • It penalises low values of P or R:
  • It is very easy to obtain high precision (just return very few documents) or high recall (return all documents).

Evaluation of ranked results

In a very large collection such as the World Wide Web, recall is difficult to compute because there is no easy way to check every page for relevance.

The results of web search engines are ordered: we can measure precision for result sets of different sizes:

  • for instance, precision at rank 5 (precision in the top 5 results)
  • or precision at rank 10, or at rank 50, etc.

Mean average precision (MAP)

A common single-number summary (buyer beware!) of performance on ranked items is the mean average precision.

  • We calculate ranked-specific precision values at each position within the set of ranked items.
  • We descend through the ranked list up to a particular threshold rank r .
  • We take all the precision values obtained at points where a relevant document was retrieved.
  • We sum them up and compute the average.
  • We then average these averages across the test set.

where n is the total number of relevant documents retrieved at rank r and Pi is the precision value at a rank i ≤ r where a relevant document was returned.

As the course has developed, we have looked at steadily more complex models for various aspects of language.

  • Do we need this complexity?

n-gram models are a very simple language models that rely completely on distribution: no morphology, syntax, or semantics.

  • Count all sequences of n tokens (e.g. letters or words) in a corpus.
  • 1-grams are usually known as unigrams
  • 2-grams are usually known as bigrams
  • 3-grams are usually known as trigrams

Use the relative frequencies of these n-grams to predict the next token

Applications of n-grams

The appeal of n-gram models is that they are cheap and simple.

  • For some NLP tasks we need more subtle models, but
  • But for others we can do a surprising amount with simple n-gram models

Machine translation:Which of these four sentences is best? Why?

  1. He briefed to reporters on the chief contents of the statement.
  2. He briefed reporters on the chief contents of the statement.
  3. He briefed to reporters on the main contents of the statement.
  4. He briefed reporters on the main contents of the statement.

Spelling/grammar correction:Do these words make sense in context?

  1. They are leaving in about fifteen minuets to go to her house.
  2. The design an construction of the system will take more than a year.

Next word-prediction in speech recognition systems

Language models

A language model is a model that defines a probability distribution over a sequence of words. We can define this as the product of the conditional probabilities of all the words in the sentence given the words before it:

When using n-gram models of a particular order n, we make the Markov assumption that the probability of a word (or end token) depends only on the n − 1 previous words (or beginning tokens). So, for a bigram model we get:

Training and testing

When working with n-gram models, we always run a risk of over-fitting to our corpus.

In order to get an impression of how our model would perform on new data, we often split the corpus:

  • training set the (usually) larger portion of the data that we use to count n-grams
  • testing set the (usually) smaller portion of the data we use for evaluating our n-gram model
  • hold-out set an optional third set to use for training parameters other than n-gram probabilities

Evaluating n-gram models

Intrinsic evaluation:

What about this model is directly measurable and likely helpful?

Perplexity: How probable is the test set?

where W is a corpus {w1w2 . . . wN } and n is the order of the model.

→ The lower the perplexity, the better!

→ This type of mean is called a geometric mean

Extrinsic evaluation:

Does this model improve performance of the larger task at hand?

Extrapolating beyond your corpus

Most n-gram models are extremely specific to their corpora.

Random Quadrigram Shakespeare

King Henry. What! I will go seek the traitor Gloucester.

Exeunt some of the watch. A great banquet serv’d in; Will

you not tell me who I am? It cannot be but so. Indeed the

short and the long. Marry, ’tis a noble Lepidus.

Random Quadrigram Wall Street Journal

They also point to ninety nine point six billion dollars from

two hundred four oh six three percent of the rates of interest

stores as Mexico and Brazil on market conditions.

→ Watch out for models that are being used where they shouldn’t be!

Smoothed n-gram estimates

There is a serious problem with our algorithm from the last slides, especially with large values of n:

→ What about combinations that never appear in the corpus?

Usually, we implement some kind of smoothing to avoid zero probabilities propagating through our models.

  • Laplace smoothing: Add one to every count, including non-zero counts!
  • Good–Turing discounting: Use the hapax legomenon (things that appear once) to estimate things that never appear.
  • interpolation and backoff (for next year)

Summary

  • n-gram models for when you can’t (or don’t want to) engage with the complexity of natural language.
    • Smoothing is usually necessary to handle missing combinations.
  • Evaluation of IR systems
    • extrinsic
  • recall, precision, and F -measure
  • true/false positives, true/false negatives
  • evaluation of ranked result
    • intrinsic
  • for n-grams: perplexity

What have we learned in this course?

Finite-state automata: formal definition

we can formally specify an FSA by the following 5 parameters:

Σ: an input alphabet

Q: a finite set of states

q0 ∈ Q: the start state

F : a set of final or accepting states (F ⊆ Q)

δ: a transition function between states that maps pairs of states and input symbols 〈q, i〉 to a new state q′ (Q × Σ → Q).

Finite-state transducers

Q: a finite set of states

Σ: an input alphabet

∆: an output alphabet

q0: the start state

a set F ⊂ Q of final states

δ: a transition function that maps pairs of states and symbols i ∈ Σ to pairs of states and symbols j ∈ ∆ (Q × Σ → Q × ∆).

Tree structures

We can represent the phrase structure of a sentence by means of a syntactic tree.

  • Each node in the tree represents a constituent.
  • The leaves of the tree correspond to the words in the sentences.
  • The symbol S denotes the whole sentence and corresponds to the top node.

Formal grammars

Formally, a grammar can be specified by 4 parameters:

Σ: a finite set of terminal symbols

N: a finite set of non-terminal symbols

S: a special symbol S ∈ N called the start symbol

R: a finite set of rules or productions containing :

  • a sequence of terminal or non-terminal symbols
  • the symbol ‘→’
  • another sequence of terminal or non-terminal symbols.
  • Rules have the form: α → β, where α, β ∈ (N ∪ Σ)∗

The Chomsky hierarchy

This classification acts as a subsumption hierarchy: the set of languages described by grammars of greater power subsumes the set of languages described by grammars of less power.

There is a balance between expressibility and computational efficiency: grammars with less expressive power are computationally more tractable.

Probabilitistic context-free grammars

How to compute the probability of a parse tree?

The probability of a parse tree for a given sentence P[t, S] is the product of the probabilities of all the grammar rules used in the sentence derivation.

Basic parsing algorithms

We worked with three basic parsing algorithms:

  • recursive descent, a top-down algorithm
  • shift–reduce, a bottom-up algorithm
  • left corner, an algorithm combining top-down and bottom-up strategies.

Next year:

  • the Cocke-Yonger-Kasami (CKY) algorithm (bottom up), an efficient algorithm for CFGs
  • the Earley algorithm (top down), enhanced with prediction.

All parsing algorithms require:

  • a grammar
  • an input string of words
  • a parsing goal (a constituent type, e.g., S, NP, . . . )

Logic as a semantic representation formalism

First-order logic can act as an intermediate representation level that allows us to connect language to the world:

  • We use FOL formulae as meaning representations for sentences.
  • We use FOL models to represent world situations.
  • We know how to check if a FOL formula is true given a model.

Compositional semantics with the λ-calculus

At each step of β-reduction (⇝), we substitute the λ-bound variable in the left-most position of the functor F with the argument A .

At the top node we need to obtain a FOL formula with no lambdas (⇒).

Event representations and time

Verbal tenses can be rather complex (and very different from language to language). For some tenses, it is useful to distinguish between the event time, the utterance time and a reference time (given by another event).

When Anne arrives, Bill will have eaten.

∃e1∃e2∃t1∃t2∃t′2[Arriving(e1) ∧ Agent(a, e1) ∧ Eating(e2) ∧ Agent(b, e2) ∧ Start(t1, e1) ∧ Start(t2, e2) ∧ End(t′2, e2) ∧ (U ≺ t2) ∧ (t′2 ≺ t1)]

Word-sense disambiguation and classifiers

There are two major types of features used in classifiers for word-sense disambiguation.

An electric guitar and bass player stand off to the side of the band.

Collocational features record information about specific positions to the left and right of a target word.

→ Parts of speech are often included along with the words themselves.

[guitar, NN, and, CC, player, NN, sand, VB]

Bag-of-words features record information about the general context (e.g., the whole sentence).

→ Bag-of-words features are often (sparse!) binary vectors showing which of the most common words in the corpus are present.

fishing big sound player fly rod double playing guitar band

0 0 0 1 0 0 0 0 1 1

Distributional semantic models (and vector-space ir)

A DSM is a matrix M where:

  • rows correspond to the vector representations of our target terms (these are the “words” for which we want to compute similarity)
  • columns correspond to the features or dimensions in the vector, representing elements that co-occur with the target terms.

Evaluation

Information retrieval has some common terminology:

  • Precision = Ra / A
  • Recall = Sensitivity = Ra / R
  • true positives (TP) = Ra (# of relevant docs retrieved)
  • false positives (FP) = A - TP (# of irrelevant docs retrieved)
  • false negative (FN) = R - TP (# of relevant docs not retrieved)
  • true negatives (TN) = Collection – (FN+FP+TP) (# of irrelevant docs not retrieved)
  • Specificity = TN / (TN + FP)

n-grams, smoothed and unsmoothed

unsmoothed counts:

Laplace-smoothed counts: