December 9th, 2011

As part of debugging the text parser I am working on, I have been delving into phrase structures that are in the Penn Treebank for the utterances from the Wall Street Journal.

This is an example of phrase ‘more than a xxx’ as labeled in the Treebank.   In the ~40,000 utterances, the phrase is found about 13 times, 8 times with the flat structure (NP or noun phrase) and 5 times with the branching structure (QP  or quantifier phrase).

The phrase is found with different nouns at the end: ‘quarter’, ‘year’ and ‘decade’.  Year is found 6 times (2 branch, 4 flat), decade is found 6 times (3 each branch and flat) and quarter is found only once in the flat structure.   It is interesting how ‘year’ and ‘decade’ are split between the two structures.

I haven’t yet found any clues in the sentences that contain these phrases as to why the individual instances are labeled differently.   Maybe someday when I have time to go read the literature, I will be able to find the reason for this.

Phrase Rules and Zipf’s Law

December 6th, 2011

I have been working with the Penn Treebank for about 4 years.  It is a list of sentences from the Wall Street Journal that have been manually tagged for part of speech tags and phrase/sentence structure . Only now, have I understood one of the primary issues with the way language works – as reflected by this corpus. The phrase structures in the corpus are Zipfian.

It is easier to understand Zipfian nature by studying words in a text corpus. Word occurrences are well known to have a Zipfian distribution. Some words occur very often. For example ‘the’, ‘of’ or ‘and’ occur many times in the WSJ corpus. In the first 10,895 sentences of the corpus, these words occur 13,542, 6,390 and 4,696 times respectively. Then there is a long list of words that occur fewer times that this, but still more than once. And then there is a long list of words that only occur once.

  • 10,895 Lines in the section of the corpus
  • 233,815 Total words
  • 19,570 Distinct words
  • 11,720 words that only occur once.

More than half of the words are only found once. Nothing new here. This is covered in all introductions to text processing.

Now, we move to phrase structure rules. By phrase structure rules, I mean those things that define how words can be put together to create a phrase. For example ‘the cat’ is a noun phrase. The rule for this phrase says that a noun phrase is made up of a determiner (the) followed by a noun (cat). In language, there are a variety of phrase types: noun phrase, verb phrase, prepositional phrase, adjective phrase and of course sentences. The entire list of phrase types used in the Penn Treebank corpus can be found at this link.   PennTags

There are many different rules for noun phrases. Here are some examples.

  • Determiner followed by a noun (dt nn)  ”The cat”
  • Determiner, adjective, noun (dt jj cat) “The fat cat”
  • Cardinal number, plural noun (cd nns) “Three cats”

In the Penn Treebank corpus, there are about 2685 distinct rules for noun phrases (depending on how you count).

What I didn’t understand or internalize until now is that phrase structure rules are also Zipfian. Of the 2685 rules for noun phrases. The rule ‘dt nn’ is found 8166 times, ‘np pp’ is found 7607 times. There are many rules with fewer occurrences, and then there are 1458 rules with only one occurrence. There are 6797 rules for all rule types (noun, verbs, adjective, etc). Of those rules 3767 are only used once (more than half of the rules). When I found this, I said to myself “that is a lot!”. So I dug further into this: there are 3003 sentences out of 10,895 that have a constituent branch with one of these single instance rules.   Almost one-third of the sentences have at least one phrase that has a unique rule.

A typical test for a parser is to train the parser on one part of the corpus, and test on a separate part of the corpus. This means we learn the available phrase rules on the training section and then apply those rules and only those rules to the test section. But by what we just found out, about one-third of any group of sentences that we use for testing, have phrase rules that aren’t found anywhere else. So one-third of the test sentences can never be parsed correctly by a parser that is applied in this manner.

The Power of the Human Mind

February 22nd, 2010

I received this text in an email.  It pretty much says it all.

i cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno’t mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!

More Ideas from Yoav Seginer

February 6th, 2010

Yoav Seginer wrote his dissertation on the Incremental Parser.  The paper is pretty easy to read – accessible.  The introduction is an especially well written introduction to unsupervised grammar induction.

I was surprised to read what he had to say about substitutability.   Substitutability is the capacity to replace phrases with other phrases that are of the same type.  For example ‘the dog’ in ‘the dog ran to town’ can be replaced with ‘it’.   So in some sense, the phrase ‘the dog’ and ‘it’ can be substituted for each other.  This is one of the cornerstones of linguistic theory and is used as a basis of many parsing techniques.  The PCFG parser uses probabilities for a phrase type that can be traded out in a given context.

However, Seginer makes the claim that substitutability is not required for his incremental parser.

Substitutability, the essential idea of the Harris method, which has been seen as a starting point for the induction process for so long, turns out to be unnecessary in unsupervised parsing.

 …unlabeled parsing which only requires the parser to identify the constituents (or dependency links) but does not require them to be labeled, is purely syntagmatic (by definition).   A parser induction algorithm can therefore focus on learning to detect syntactic units while ignoring substitutability. (p20)

Another fresh idea (to me) from Seginer’s paper is the skewness of language structure.

The syntactic structure of natural language is skewed. This simply means that when the syntactic structure of an utterance is represented by a tree, each node in the tree has at least one short branch. The shorter the shortest branch is, the greater the skewness.  (p22)

Essentially how the incremental parser takes advantage of skewness is to expect skewness in the parse result.  This reduces the search size and thereby make the parsing process more efficient.

…context free grammars, allow (a-priori) any tree structure and, therefore, a learning algorithm for such representations must discover by itself the skewness property of syntactic trees. However, if this property is indeed universal, there is no need to burden the learning algorithm with its discovery and it is possible to code skewness directly into the parser.  (p23)

He claims that ‘coding the skewness’ into the syntactic representation and the parser, i.e., expecting branches to be of mixed depths, does not retract from the accuracy of the parse result.

Here is a link to Yoav’s dissertation.  Dissertation

Since graduating in 2007, it looks like Yoav Seginer is working at a  small company in Amsterdam, Mondria Technologies Ltd (according to LinkedIn.com).  The company website doesn’t say anything yet.  I wonder if they are working on a project that uses the incremental parser.

Incremental Unsupervised Grammar Learning

February 5th, 2010

This paper by Yoav Seginer is very exciting.  It covers a method of learning a language grammar that resonates with my mental model of how a young child learns language.  These are some aspects of the Seginer algorithm.

Incremental Learning.  The system adds information to the grammar with each new sentence.  In other approaches (CCM by Manning and Klein, UDOP by Bod), the entire corpus is processed as a block to collect the parameters of the grammar and the entire corpus is repeatedly processed until the learning converges on final result.  In Seginer’s approach, the corpus is processed one sentence at a time.  After each sentence, the grammar weights are updated.  That sentence is not revisited for further training.

Simpler Math.  The approach by Seginer uses much simpler math for computing the parameters of the resulting grammar.   There are a few ratios, some accumulation of values into other, and some comparison of weights to choose which one to apply for a given step.  There are no long chains of probabilities to compute the best parse.  I don’t have any principled reason why this makes more sense for a model of how the brain works – it just fits my gut feeling better.

Not Restricted to Binary Trees.  The CMM approach and others approaches that are referenced in Seginer’s paper all give binary parse trees as the result.  But natural languages aren’t limited to binary trees.  Although it is possible to represent any non-binary tree as a binary tree, forcing a binary representation onto natural language is not adding to the value of the result.  Seginer’s process gives parse trees that include constructions of more than two nodes.

Exocentric Constructions.   A phrase like ‘the boy’ has links going both directions between the two words.  Either word can be considered the head of the phrase – which in some way matches the disagreement between linguists about which word is actually the head of the phrase.

Link depths.  His algorithm result include a depth value on dependency links.  This value can be used to distinguish between internal and external arguments to a phrase.

Incremental Parsing.  For each word read into the sentence, links can only be added to or from the new word.

             I know the boy (sleeps)

When the algorithm encounters the word sleeps it can only add a link to or from this word.  No links that were generated at earlier steps can be affected.   This reduces the search space and contributes to the overall speed of the parser.  Another advantage is that the links in ‘I know the boy’ are an exact subset of the links in ‘I know the boy sleeps’.  There is no decision necessary about dropping links that were previously discovered.

No Clustering.  Seginer’s approach groups words with class labels that in some respect are part of speech classes.  However, the approach does not require clustering of words into specific classes.  It finds similarities between the and a but it does not require that all determiners are grouped together in a well defined class.  This makes the approach better able to deal with noise in the training data.

Homophony.  When a word has more than one meaning, it can confuse any machine algorithm.  Seginer’s algorithm deals with homophony by comparing labels between target pairs of words.  In the example that follows, words in brackets are possible labels for the target words.  When an underscore appears in the label, it means look at  the label of the preceding or following word.

             This[the] year[_the]    (this is a determiner)

            This[is_] was [is]          (this is a pronoun).

In the example given above, in one case this is a determiner.  One of its labels is [the] because this and the occur in similar places.  In the second line a label for this is [is_] which means that this is frequently followed by is.  The algorithm finds pairs of labels such as [the] and [_the] or [is_] and [is] to decide where to put links.

I think Seginer’s approach has some real merit.  It is a greedy algorithm – it learns as it goes and does not need to revisit previous sentences.  It uses simple math.  It has results that seem to match psycholinguistic models.   It would be great to see this approach extended to take advantage of other linguistic phenomena such as morphology.

 A link to the paper can be found here.  Paper

 A link to a video presentation on the approach can be found here.    Video

Important Language Characteristic

January 10th, 2010

Today I was pondering the issue of head directionality of languages – does the head of a phrase come before or after the remaining portion of the phrase.  This parameter has been largely disregarded because most languages are inconsistent its use.

However, it occurred to me that infants could rely on the heavy weighting of head directionality when they are first learning a language.  By choosing the direction that is predominant and ignoring the incoming utterances of the opposite direction, it would simplify the initial learning phase.

Perhaps someone has already proposed this little insight into child language acquisition.

As I was pondering this, it also occurred to me that the single most important characteristic of a language is that it can be learned by an infant.  If the majority of infants in a culture can’t learn the language of their parents, then that language will not persist.  It will die out.

Perhaps someone else has already proposed this little insight as well.

Videos on Unsupervised Learning of Syntax

January 1st, 2010

Here are two links to videos on Unsupervised Learning of natural language syntax.

Chris Manning gave this talk at MLCS 2007.  It is a fairly detailed discussion of the work that Chris did with Dan Klein on learning syntax structure.  Dan used the material for his dissertation.

Chris Manning Video

Dan Klein gave this talk at UAI 2008.  It is more high level, and describes how Dan and his students have applied their work to a few other areas of unsupervised learning.

Dan Klein Video

Both these videos are worth watching.

Learning is a life long adventure

September 2nd, 2009

I finished my MA degree at the University of Washington.  Many thanks to the faculty and staff that helped me finish.  Many thanks to my wife and family that supported me while I struggled through it.

However, this week I was reminded that there are limits to how much you can learn in a degree program that lasts only 5 quarters.   A blog at LingPipe (a review of my blog) (lingpipe-blog.com) pointed out several errors in what I had written about here in one of my posts.  Well, lucky for me I hadn’t intended the text to be submitted to a conference jury for review.  The paper was just a one-week assignment.  As I remember, I passed the class, so the paper probably met the requirements for the course even though it has very clear short comings in the eye of the LingPipe reviewer.

Maybe I will find the time to dig out the code that was used for that paper, and compare it against the evaluation at LingPipe and see if I can understand what the LingPipe objections were.  I might even try to re-implement the code following the expert’s directions.

Another way I look at this is: the more you know, the more you know that you don’t know.  It has been healthy for me to receive some constructive criticism of my post.  I have been writing software for only 30 years, so maybe in the next 30 years, I can learn how to fix the problems that LingPipe pointed out.  For now, I am just an average software engineer.  Code reviews are part of the process.

The Stuff of Thought

June 5th, 2009

I have been reading The Stuff of Thought by Steven Pinker which is a survey of different ways language gives clues to how the mind works.  (See my related entry dated September 28, 2007)  In the fourth chapter, he gives a very enlightening portrayal of how language describes objects in space. 

“Languages tend to have terms for contact, vertical alignment, attachment, containment, and proximity, as if there were a cognitive alphabet of spatial relationships more basic than the prepositions of a given language.”  (p. 178)

“A light bulb is considered to be in a socket when its base is inserted, since that allows it to be illuminated, but a person is not in a car if only his arm extends in through a window, since that doesn’t allow the car to move him or even shelter him.” (p. 187)  The meaning of the preposition in depends on the objects that are being described.

“If Sally has one big stone and Jenny three much smaller stones, who has more?  The question by itself is unanswerable: it depends on whether you mean “more stone”, or “more stones.”  (p. 173)   The meaning of more depends on whether it is referring to the number of objects (stones) or the mass/volume/weight of the object (stone).

“The part of the mind that interfaces with language treats objects schematically.  … Every morsel of matter has a length, a width, and a thickness, but when we speak of these morsels we pretend that some of the dimensions aren’t there. … A road, a river, or a ribbon is conceptualized as an unbounded line (its length which serves as its single primary dimension) fattened out by a bounded line (its width which serves as a secondary dimension), resulting in a surface.”  (pp. 179, 180)

 ”Since words and syllables aren’t free, languages economize when they can. … Imagine you are in a rainstorm, ten feet away from an overhanging ledge.  Move one foot toward it, you still get wet.  Move over another foot; you still get wet.  Keep moving, and at some point you no longer get wet.  Continue to move another foot in the same direction, you don’t get any dryer.  So nature has set up a discontinuity between the segment of the path where gradual changes of position leave you equally wet and the segment where gradual changes leave you equally dry.  And it is exactly at that discontinuity that one would begin to describe your position using under rather than near.”  (P 186)

“Spatial terms quantize space at the cusps where causal events play out differently on each side.  As your palm gradually [wraps] around a marble, the curvature at which you stop saying the marble is on the hand and start saying it’s in is more or less the shape that would prevent it from rolling off when you jiggle it.”  (P 186)

Dr. Pinker’s premise in this book is that language reflects our thoughts.  By disecting our language, we get a glimpse of how the thought engine behind the language works.  We use count nouns and mass nouns in language because our minds see countable items such as chairs or dogs and our minds also see non-countable mass objects such as water or furniture.  We use a preposition like along to describe proximity to a one-dimensional line and we use inside to describe containment in a two or three dimensional object. 

All languages take slightly different approaches to describing space, but there are similarities that can possibly be used to infer an underlying brain structure that helps define our language.  “Most of the world’s languages divide the space around the speaker into just two regions, though about a quarter of them (including Spanish) make a three-way distinction among ‘near me’, ‘far from me’, and ‘in between,’ and a very few go to four, adding ‘very far from me’.” (p. 178)  He is referring to the English terms here (near me) and there (far from me).

“Not all languages carve [spatial relationships] up in the same way.  Presumably this is because each language trades off expressiveness, precision, word length, and vocabulary size in a different way.  But the quantization of spatial relations is universal, and causally important relations like contact, attachment, alignment, verticality and proximity make their appearance in all the spatial vocabularies of the world.”  (p. 187)

The book is an excellent example of Dr. Pinker’s writing – it is entertaining while at the same time being specific and to the point.  He digs into the issues and comes at them from all aspects – cognitive psychology, neuro-science, pathology, and child language acquisition.  He is an academic, and at the same time he presents his material in a way that is concise and engaging.

Open Domain Question Answering

May 19th, 2008

As part of the CLMA program here at University of Washington, we were asked to investigate an area of interest and write a short summary of what we read about.

So I chose to look at the TREC Question Answering challenge and read about some of the techniques that were used for submissions to that evaluation.  The kinds of questions that are used for this include simple factoid questions such as “How many calories are in a Big Mac?”, list questions such as “Which past and present NFL players have the last name of Johnson?”, and definition question such as “What is a Golden Parachute?”.

Many of the system descriptions submitted to TREC have pipelined architectures.  Here are some examples of components that were described:

  • Question Type Classification – Decide what the answer should be like.  Is it asking for a name, a date, a description or a list, etc.
  • Question Rewrite – Convert the question to search terms that are used for the IR search.  This step typically expands the list of words used in the search by adding synonyms.  This gives a broader list of pages returned that can then be further analyzed.
  • IR Search – generally a simple search using established technologies.
  • Passage Selection – deciding which portions of the text returned by the IR search to include in the results.
  • Answer extraction and ranking – creating the actual text that will be returned as answers.

The paper is not intended to be a thorough description of the field.  It helped me get a handle on what current designs are being developed.

Here is the link to my exploration paper: QuestionAnsweringAtTrec