NLP Applications and Foundations Explained
NLP Applications and Foundations Explained
■ Text summarization
■ Search engines
2
Machine Translation
A-
3
Conversational Agents
● Conversational agents
— core components
■ Speech recognition
■ Language analysis
■ Dialogue processing
■ Information retrieval
■ Text-to-Speech
4
Conversational Agents — Question Answering
5
Text Summarization
7
Text Generation
● Example: Image Captioning
8
Other Applications
● Spelling correction
● Document clustering
■ Sentiment analysis
■ Authorship attribution
9
Natural Language Processing: Foundations
■ Not formal, yet systematic: rules can emerge which were not previously defined
(this includes that many rules can be bent until reaching a breaking point)
● Text / Writing
■ Visual representation of verbal communication (i.e., Natural Language)
■ Writing system: agreed meaning behind the sets of characters that make up a text
(most importantly: letters, digits, punctuation, white space characters: spaces, tabs, new lines, etc.)
11
Core Building Blocks of (Written) Language
● Basic symbol of written language
Character
(letter, numeral, punctuation mark, etc.)
r, e, a, c, t, i, o, n
Clause
(1..n phrases)
● Phrase with a subject and verb his quick reaction saved him
12
Core Building Blocks of (Written) Language
● Self-contained unit of discourse in writing Bob lost control of his car. His quick reaction
Paragraph
(1..n sentences) saved him from the oncoming traffic. Luckily
dealing with a particular point or idea.
nobody was hurt and the damage to the cae
was minimal.
(Text) Document
● Written representation of thought
(1..n paragraphs)
13
Morphemes
● Morpheme
■ Smallest meaning-bearing unit in a language ➜ word = 1..n morphemes
■ Assign a particular grammatical property to that word (e.g., tense, number, possession, comparison)
14
Examples
Prefix Prefix Stem Suffix Suffix Suffix
dogs dog -s
15
Using Language Before ~1950
● Verbal communication between people
■ Day-to-day conversations
■ Oral history
Analysis
Natural Some abstract internal
Language representation / model of
language and the world
Generation
morphemes
(understanding structure & meaning of words) ● Normalization ● Lemmatization
words
● Part-of-Speech Tagging
Syntactic Analysis
(organization of words into sentences) ● Syntactic parsing (constituents, dependencies)
phrases
clauses
sentences ● Word Sense Disambiguation
Semantic Analysis ● Named Entity Recognition
(meaning of words and sentences)
● Semantic Role Labeling
19
What is NLP? — The Big Picture
NLP
Artificial
Intelligence
Machine Learning
Deep Learning
20
Natural Language Processing: Foundations
■ Text preprocessing
(e.g., tokenization, normalization)
■ Part-of-Speech Tagging
rely on
rely on
● Higher-level tasks, e.g.:
"deeper"
■ Intent recognition
22
Lexical Analysis — Tokenization
● Tokenization
■ Splitting a sentence or text into meaningful / useful units
character-
based She ' s d r i v i ng f as t e r t han a l l owe d .
subword-
based She 's driv ing fast er than allow ed .
word-
based She's driving faster than allowed .
23
Syntactic Analysis — Part-of-Speech Tagging
● Part-of-Speech (POS) tagging
■ Labeling each word in a text corresponding to a part of speech
■ Basic POS tags: noun, verb, article, adjective, preposition, pronoun, adverb, conjunction, interjection
24
Syntactic Analysis — Syntactic Parsing
● Dependency parsing
■ Analyze the grammatical structure in a sentence
■ Find related words & the type of the relationship between them
25
Semantic Analysis — Word Sense Disambiguation
● Word Sense Disambiguation (WSD)
■ Identification of the right sense of a word among all possible senses
sloping land
depository financial institution
arrangement of similar objects
...
She heard a loud shot from the bank during the time of the robbery.
a consecutive series of pictures (film)
the act of firing a projectile
an attempt to score in a game
...
26
Semantic Analysis — Named Entity Recognition
● Named Entity Recognition (NER)
■ Identification of named entities: terms that represent real-world objects
27
Semantic Analysis — Semantic Role Labeling
● Semantic Role Labeling (SRL)
■ Identification of the semantic roles of these words or phrases in sentences
28
Discourse Analysis — Coreference Resolution
● Coreference Resolution
■ Identification of expressions that refer to the same entity in a text
Mr Smith didn't see the car. Then the car hit Mr Smith.
29
Discourse Analysis — Ellipsis Resolution
● Ellipsis Resolution
■ Inference of ellipses using the surrounding context
30
Pragmatic Analysis — Textual Entailment
● Textual Entailment
■ Determining the inference relation between two short, ordered texts
"I'm hungry!"
Intent: Action:
Additional context:
➜ Writer is looking ➜ Search for vegetarian restaurants in
● The writer is vegetarian
● The writer is near VivoCity
for a place to eat and around VivoCity that are open.
● It's 1pm: lunch time
● ...
32
Natural Language Processing: Foundations
● ambiguous ● expressive
● redundant ● sparse
● changing ● variable
● unbounded ● "large-scale"
● imprecise ● …
34
Ambiguity
● Ambiguity at different levels, e.g.:
■ Word senses: bank (financial institute or edge of river?), cancer (disease or zodiac sign?)
■ Part of Speech: run (verb or noun?), fast (verb or noun or adjective or adverb?)
■ Syntactic structure: "I see the man with a telescope" ➜ affects semantics!
35
Ambiguity
● Anaphoric ambiguity
■ Ambiguous resolution of anaphora / coreferences (without additional context)
??? ???
Who is "she" and "her" referring to?
Alice and Sarah went for dinner. She invited her.
Useful context: It was Sarah's birthday.
???
What is "it" referring to?
The box didn't fit in the car because it was too big.
Resolution requires the understanding of
vs. ● Objects can contain other objects
???
● Physical size of objects
The box didn't fit in the car because it was too small. ● Physical limitations due to size
36
Ambiguity
● Winograd Schema (Challenge)
■ A pair of sentences differing in only one or two words and
containing an ambiguity that is resolved in opposite ways
● Example
???
I poured water from the bottle into the cup until it was full.
vs. ???
I poured water from the bottle into the cup until it was empty.
37
Ambiguity
● Pragmatic Ambiguity
■ Unclear semantics if context is unknown
"Yes!"
(interpreted as Yes/No question)
38
Expressivity
● In general, the same meaning can be expressed with different forms
Alice gave Bob the book. vs. Alice gave the book to Bob.
39
Expressivity
● Idioms It's raining cats and dogs today.
He was over the moon to see her.
● Neologisms
■ May be added to the selfie, retweet, photobomb, staycation, binge-watching,
dictionary over time crowdfunding, adulting, chillax, noob, kudos, etc.
40
Variation
● No one-size-fits-all NLP solutions
■ Difference in underlying task
(tokenizing, stemming, syntax parsing, part-of-speech tagging, entity recognizing, etc.)
■ Different domains: news articles, social media, scientific papers, ancient literature, etc.
(particularly: different vocabularies, formal vs. informal language (e.g., slang), narrative vs. dialogue)
41
Sparsity
Rank Word Freq.
1 the 14,767
2 of 10567
3 and 5920
● Sparsity in text corpora 4 in 5477
5 to 4837
■ Word frequencies inversely proportional 6 a 3460
to their rank ➜ Zipf's Law 7 that 2764
8 as 2242
■ Example: "On the Origin of Species" 9 have 2121
(Charles Darwin, 1859; 212k+ words) 10 be 2116
... ... ...
101 mr 263
102 parts 260
103 often 260
104 period 259
105 common 256
... ... ...
1001 increasing 25
1002 expected 25
1003 egg 25
1004 fly 25
1005 aquatic 25
... ... ...
42
Sparsity
The Hound of the Baskervilles (63k+ words) On the Origin of Species (212k+ words) 100MB Wikipedia dump (14.4M+ words)
➜ Regardless of size and domain of a corpus, there will be a lot of infrequent words!
43
Scale
● ~6,500 languages and ~150 language families
44
Unmodeled Representation
● The meaning / interpretation of a sentence often depends on:
■ The current context or situation
➜ How to capture this in ?
■ Shared understanding about the world
"I killed all the children." "I slipped and fell hard on the floor."
45
Natural Language Processing: Foundations
47
NLP in the Press — For the Wrong Reasons
Source: [Link]
48
NLP in the Press — For the Wrong Reasons
49
Natural Language Processing: Foundations
■ Good ML needs bias and assumptions ➜ NLP: linguistic theory & representations
● NLP as linguistics
■ NLP must contend with NL data as found in the world
51
What is NLP? — The Big Picture
"Language shapes the way we think, and
Fields with Connections to NLP
determines what we can think about."
■ Cognitive Science Benjamin Lee Whorf
■ Information Theory
"Knowledge of languages is the doorway to wisdom."
■ Data Science
Roger Bacon
■ Political Science
■ Ethical considerations
53
NLP is Changing
● Increases in computing power
■ Deep Learning = matrix operations ➜ Game changer: GPUs
54
Course Meta Topics
● Linguistic Issues
■ What is the range of language phenomena?
55
Section 1 — Summary
● Main takeaway messages
56