Skip to content
MLG 020 Natural Language Processing 3 episode artwork

Jul 23, 2017 40 min

MLG 020 Natural Language Processing 3

from Machine Learning Guide

Syntax parsing turns a tagged sentence into a tree, by probabilistic context-free grammars with CKY or, more often today, dependency parsing; classical NLP then combines it with TF-IDF and named entity recognition to answer questions. Also covers the Penn Treebank, TextRank summarization, statistical vs neural machine translation and NLP data pipelines. Links Notes and resources at ocdevel.com/mlg/20 Join the free MLG group: listen to my other AI shows, ask me questions, and talk with other listeners Classical NLP pipeline Text moves through stages, each feeding the next one downstream: ingest documents -> clean (tokenize, lowercase, stem/lemmatize, drop stop words) -> POS tagging -> syntax parsing -> goal Text classification with naive Bayes needs only the bag of words, and search uses TF-IDF with cosine similarity (MLG 019). Named entity recognition (NER) is both a goal and a tool for later stages. At scale each stage gets its own machines. Hadoop and Spark are the classic distributed data-processing frameworks, and Spark is the one still in wide use. Constituency parsing with context-free grammars Syntax parsing builds a tree over a part-of-speech-tagged sentence. A constituency parse groups words into phrases: in "The boy with blonde hair walked up the mountain", "the boy with blonde hair" is a noun phrase (NP) and "walked up the mountain" a verb phrase (VP), each breaking down further to POS tags. A context-free grammar (CFG) writes these groupings as production rules: S -> NP VP VP -> V NP NP -> Det N | Adj NP Hand-written rules fail on ambiguity: the headline "Pope's baby steps on gays" parses two ways. A probabilistic CFG (PCFG) learns how often each production occurs from parsed sentences. The CKY (Cocke–Kasami–Younger) algorithm, a dynamic-programming parser for grammars in Chomsky normal form, then finds the most likely tree. Penn Treebank and WordNet The Penn Treebank is an annotated corpus: sentences tagged with their parse trees in bracketed notation, used to train parsers and POS taggers. WordNet is a lexical database of English that groups words into synonym sets; NLTK includes it. Dependency parsing A dependency parse draws arcs from head words to the words that depend on them, optionally labeled with the relation. In "Alice saw Bob reading in the hallway", "saw" is the root, with arcs to its subject "Alice" and to "Bob". Dependency parsing is the common approach today. Transition-based parsers read left to right with a stack and a buffer, at each step moving a word onto the stack or attaching words with an arc; a greedy parser takes the best-scoring move each time. Google's SyntaxNet and its English model Parsey McParseface (2016) are retired. spaCy and Stanford's Stanza ship neural dependency parsers, and transformer models, LLMs included, are state of the art for parsing. Relationship extraction and Google's knowledge panel A parse shows which entity does what to which, so relationship extraction can pull facts like spouse(A, B) out of a sentence. Google's knowledge panel, the card beside the results for a person, company or band, shows facts from its Knowledge Graph: birth date, spouse, founders, members. Question answering with classical NLP For "Who is the prime minister of the United Kingdom?": TF-IDF and cosine similarity retrieve documents containing the rare query words. Common words like "who" and "the" score low, so they needn't be removed. TF-IDF narrows each document to a few candidate sentences. Parse the question, replace the question word ("who") with a blank, and score candidate sentences by how well their parse trees match, in either word order ("_ is the prime minister" or "the prime minister is _"). The question word sets the entity type NER must find: who means a person, when a date. The answer most sentences agree on wins: in 2017, Theresa May, prime minister from 2016 to 2019. That uses four tools: POS tagging, syntax parsing, TF-IDF with cosine similarity, and NER. Google shows answers like this as a featured snippet. Text summarization: TF-IDF and TextRank TF-IDF: score each sentence by the rare words it carries, take the top few, and drop near-duplicates by cosine similarity. TextRank (Mihalcea and Tarau, 2004): sentences become nodes in a graph, edges carry their similarity, and a PageRank-style ranking picks the most central sentences. Query-based summarization: pick the sentences relevant to a query, such as those that answered the question. These are extractive: they splice existing sentences. Transformers and LLMs are state of the art for summarization and question answering, including abstractive summaries that write new sentences. TextRank remains a simple extractive baseline. Statistical vs neural machine translation Classical statistical machine translation combined a translation model and a language model (the noisy-channel model), aligned words between the two languages, and used beam search to choose among candidate translations, with each component trained separately. Neural machine translation replaced it with one model trained end to end, first RNN encoder-decoders (MLG 022) and now transformers (MLG 033). Deep learning now leads on most of the tasks in MLG 018 to 020: parsing, named entity recognition, classification, question answering, summarization and translation. BM25, a refinement of TF-IDF, remains a strong search baseline. The classical methods are still faster, need less data, and lay out the structure of each task. Where to learn classical NLP The same as MLG 018 and MLG 019: Speech and Language Processing by Jurafsky and Martin. Stanford CS224N. The NLTK book, Natural Language Processing with Python. Next: MLG 022, on deep NLP: word embeddings and recurrent neural networks.

Episode details come from the podcast's RSS feed.

Embed this episode

Ready to play

MLG 020 Natural Language Processing 3

0:00 40:37

No transcript yet.

Requests help us decide what to transcribe next.

Frequently asked questions

How long is this episode of Machine Learning Guide?

This episode is 40 minutes long.

When was this Machine Learning Guide episode published?

This episode was published on July 23, 2017.

Can I download this Machine Learning Guide episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.