Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct...

118
Natural Language Learning with Formal Semantics Wenhu Chen 1

Transcript of Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct...

Page 1: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Natural Language Learning with Formal Semantics

Wenhu Chen

1

Page 2: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Outline1. Introduction2. Formal Semantics3. Its Application in NLP4. My Work & Future Direction

2

Page 3: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Meaning

3

Meaning

Page 4: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Meaning

4

Meaning

Semantics PragmaticsCognitive Social Science

Page 5: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Meaning

5

Linguists can barely reach an agreement on the definition of “meaning”

Page 6: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Meaning

6

1. Simple2. Straightforward

Raw-String

Bag of wordsUnigram/Bigram

Page 7: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Meaning

7

1. Simple2. Straightforward

Raw-String

Bag of wordsUnigram/Bigram

Formal Semantics

1. Compositional2. Explainable

Lambda CalculusMontague Semantics

Page 8: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Meaning

8

1. Simple2. Straightforward

Raw-String Formal Semantics

1. Compositional2. Explainable

Real-valued Vector

1. Data-Drive2. Computation

Efficient

Word2Vec/GloveBERT

Bag of wordsUnigram/Bigram

Lambda CalculusMontague Semantics

Page 9: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Meaning

9

What aspects do you need the meaning representation to capture?

Page 10: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Meaning

10

What aspects do you need the meaning representation to capture?

Can it lean meaning or just similarity between meaning?

Can it lean grounded meaning or learn lexical meaning?

Page 11: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

1. Raw-String Representation- Cannot directly link to the external world knowledge.- Cannot combine pieces of knowledge together to perform inference.

11

Utterance1: John has an appleUtterance2: John has a banana

Utterance: John has an apple and a banana.

Page 12: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

1. Raw-String Representation- Assuming we want to build an NLP system to understand math questions?

a. Such system cannot leverage the mathematical knowledge.b. The sample complexity becomes extremely high.

12

MathWorld

Utterance: What is the largest prime less than 10?

Page 13: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

2. Formal Semantics (Montague)- We construct the meaning of natural language in terms of variables,

predicates, arguments.

13

Page 14: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

2. Formal Semantics (Montague)- We construct the meaning of natural language in terms of variables,

predicates, arguments.- Formal Semantics aim to use explicit and grounded meaning representation

to convey information.

14

Page 15: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

2. Formal Semantics (Montague)- We construct the meaning of natural language in terms of variables,

predicates, arguments.- Formal Semantics aim to use explicit and grounded meaning representation

to convey information.- The formal semantics can help us understand human language from a

mathematical logic perspective.

15

Page 16: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

2. Formal Semantics (Montague)

16

Utterance: What is the largest prime less than 10?

MathWorld

Page 17: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

3. Vector Representation- Data-driven learning process- Suitable for deep learning framework

17

Page 18: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

3. Vector Representation- Data-driven learning process- Suitable for deep learning framework

18

Page 19: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

3. Vector Representation

19

Utterance Behavior

We don’t need to worry about the structure of computation in the middle

Page 20: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

3. Vector Representation

20

Tight coupling between machine learning and representation means there’s always risk that some new semantic phenomenon arises and suddenly our model is useless

Utterance Behavior

Page 21: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Evaluation Chart

21

Type Meaning Similarity Meaning Grounded Meaning Lexical Meaning

String

Vector

Formal

Page 22: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Evaluation Chart

22

Type Meaning Similarity Meaning Grounded Meaning Lexical Meaning

String

Vector

Formal

Page 23: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Evaluation Chart

23

Type Meaning Similarity Meaning Grounded Meaning Lexical Meaning

String

Vector

Formal

Page 24: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Formal Semantics- For a long time, such an explicit meaning representation has dominated the

research of NLP community- Reasoning- Perception- Action

24

Page 25: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Formal Semantics- For a long time, such an explicit meaning representation has dominated the

research of NLP community- Reasoning- Perception- Action

25

Utterance Parser

Page 26: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Formal Semantics- For a long time, such an explicit meaning representation has dominated the

research of NLP community- Reasoning- Perception- Action

26

Utterance Parser

Semantic Form1

Semantic Form2

Semantic Form3

QuestionAnswering

LanguageNavigation

Textual Inference

Page 27: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

List of Semantic Forms- Introduction of formal semantics

- Lambda Calculus (Turing 1937)- Combinatory categorial grammar (CCG) (Steedman et al. 1996, 2000)- Weighted linear CCG (Clark & Currant et. al 2007)- Dependency-based compositional semantics (DCS) (Liang et al. 2011)- Lambda DCS (Liang et al. 2013)- Abstract Meaning Representation (Banarescu et al. 2013)- Domain Specific Languages (DSL)

- Functional program semantics (Liang et al. 2017, Dawn et al. 2018)- SQL, etc (Zhong et al. 2017, Yu et al. 2018)

27

Page 28: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Semantic Forms

28

Yoav et. al, Learning Compact Lexicons for CCG Semantic Parsing, 2014Yoav et. al, Weakly Supervised Learning of Semantic Parsers for Mapping Instructions to Actions, 2013Luke et. al, Learning to Map Sentences to Logical Form: Structured Classification with Probabilistic Categorial Grammars, 2005Steedman et. al, Surface Structure and Interpretation. 1996Steedman et. al, The Syntactic Process. 2000

- Combinatory Categorial Grammar- Definition- Rules- Learning

- Dependency-based compositional semantics- Definition- Rules- Learning

- Neural Symbolic Machine (Functional-Program)- Definition- Learning

Page 29: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Combinatory Categorial Grammar- Categorial Formalism

- Compositional- Puts information on the words

29

Page 30: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Combinatory Categorial Grammar- Categorial Formalism

- Compositional- Puts information on the words

- Transparent interface between syntax and semantics

30

Page 31: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Combinatory Categorial Grammar- Categorial Formalism

- Compositional- Puts information on the words

- Transparent interface between syntax and semantics- Including Predicate-argument structure, quantification and information

structure.

31

Page 32: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Combinatory Categorial Grammar- Categorial Formalism

- Compositional- Puts information on the words

- Transparent interface between syntax and semantics- Including Predicate-argument structure, quantification and information

structure.- Same expressive power as lambda calculus.

32

Page 33: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

- Basic Building Block- Capture Syntactic and Semantic Information Jointly

CCG Categories

33

ADJ :ADJ

Page 34: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

- Basic Building Block- Capture Syntactic and Semantic Information Jointly

CCG Categories

34

Syntax ADJ Semantic:

Page 35: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

- Primitive symbols: N, S, NP, ADJ and PP- Syntactic combination operation (/,\)- Slashes specify argument order

CCG Categories

35

Syntax ADJ Semantic:

Syntax (S\NP)/ADJ Semantic:

Syntax NP SemanticS:

Page 36: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

- Pair words and phrases with meaning- Meaning captured by a CCG category

CCG Lexical Entries

36

Natural Language

fun

CCG Category

|- ADJ:

Page 37: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

- Pair words and phrases with meaning- Meaning captured by a CCG category

CCG Lexical Entries

37

fun ADJ:

(S\NP)/ADJ:

CCG NP: CCG

fun

is

|-

|-

|-

Page 38: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

- Equivalent to function application

- Two direction of application

CCG Operations

38

Page 39: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

- Equivalent to function application

- Two direction of application

CCG Operations

39

Argument Function Result

Page 40: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

- Use Lexicon to match words and phrases with their CCG categories

- Combine categories using operators

CCG Parsing

40

Page 41: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

- Use Lexicon to match words and phrases with their CCG categories

- Combine categories using operators

CCG Parsing

41

Page 42: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

- Use Lexicon to match words and phrases with their CCG categories

- Combine categories using operators

CCG Parsing

42

Page 43: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Lexicon Problem- Key component of CCG- Same words often paired with many different categories- Difficult to learn from limited data

43

Page 44: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Lexicon Problem- Key component of CCG- Same words often paired with many different categories- Difficult to learn from limited data

44

The house dog

The dog of the house

house |- ADJ:

house |- N:

Page 45: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Factored Lexicons

45

house |- N:

house |- ADJ:

garden |- N:

Similar

Page 46: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Factored Lexicons

46

house |- N:

house |- ADJ:

garden |- N:

Lexemes

(garden, {garden})(house, {house})

Templates

Page 47: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Factored Lexicons

47

Compress

Page 48: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Factored Lexicons- Capture systematic variations in word usage- Each variation can then be applied to compact units in lexical matching- Abstracts the compositional nature of the word

48

Page 49: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Learning (Data)- (Natural Language, Lambda Form)

49

Page 50: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Learning (Structure Prediction)

50

Lexicon CombinatorsPredefined

Log-Linear

Page 51: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Learning (Log-Linear Scorer)

51

Page 52: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Learning (Log-Linear Scorer)

52

Page 53: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

GENLEX

53

Latent

Page 54: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

GENLEX

54

Lexical Generation Procedure

Given:Sentence Validation Function Log-Linear Model Lexicon

Page 55: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

GENLEX

55

Lexical Generation Procedure Lexemes

(garden, {garden})(house, {house})

Templates

Lexicon

OverlyGenerate

Given:Sentence Validation Function Log-Linear Model Lexicon

Page 56: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

GENLEX

56

Lexical Generation Procedure

Given:Sentence Validation Function Log-Linear Model Lexicon

Lexicon

Prune

Page 57: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Unified Learning Algorithm

57

Page 58: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Unified Learning Algorithm

58

Iterate over data

Page 59: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Lexical generation

59

Generate a large set of potential lexical entries

Page 60: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Lexical generation

60

Get top parses

Page 61: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Lexical generation

61

Get lexical entries from highest scoring

valid parses

Page 62: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Lexical generation

62

Update model’s lexicon

Page 63: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Update parse scorer

63

Re-parse parsers and divide them into

“good” and “bad” ones

Page 64: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Update parse scorer

64

Pick the “good” and “bad” parsers violating

the margin

Page 65: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Update parse scorer

65

Update towards ‘good’ parses and against

‘bad’ parses

Page 66: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Update parse scorer

66Output Lexicon &Log-Linear Model

Page 67: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Semantic Forms

67

Liang et. al, Learning dependency-based compositional semantics, 2011Liang et. al, Lambda dependency-based compositional semantics, 2013Jonathan et. al, Semantic parsing on Freebase from question-answer pairs, 2013Jonathan et. al, Semantic parsing via paraphrasing, 2014

- Combinatory Categorial Grammar- Definition- Rules- Learning

- Dependency-based compositional semantics- Definition- Rules- Learning

- Neural Symbolic Machine (Functional-Program)- Definition- Learning

Page 68: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Dependency-based Compositional Semantics- Weakness of CCG Parse

- Too much hand-coded rules for lexicon construction.- Learning algorithm is complicated.- The grammar rules are too strict.- Learning requires annotating logic form.

68

Page 69: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Dependency-Based Compositional Semantics (DCS)

69

DCS

major cities in CA

Page 70: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Dependency-Based Compositional Semantics (DCS)

70

DCS

major cities in CA

Predicate

Page 71: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Dependency-Based Compositional Semantics (DCS)

71

DCS

major cities in CA

1st elem of “city” equals 1st elem of “major”

Page 72: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Dependency-Based Compositional Semantics (DCS)

72

DCS

Weak-Supervision

Few hand-coded lexical rules

Align Syntactic & Semantic

Page 73: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Strong vs. Weak Supervision

73

Page 74: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Strong vs. Weak Supervision

74

Page 75: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Lexicon vs. Triggers

75

requires strict grammar rule during parsing and harsh type constraint

CCG

Page 76: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Lexicon vs. Triggers

76

{(city, city),(city, state),(city, river), . . . }

requires strict grammar rule during parsing and harsh type constraint

CCG DCS

requires only trigger words for predicates without grammar rule

Page 77: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Syntactic & Semantic Alignment

77

city

major

amod

CA

nmod

incase

Utterance: major cities in CA

DependencyParsing

Page 78: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Syntactic & Semantic Alignment

78

city

major

amod

CA

nmod

incase

Utterance: major cities in CA

DependencyParsing

Dependency-basedCompositional Semantics

Page 79: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Parsing: Lexical Triggers

79

Page 80: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Parsing: Lexical Triggers

80

Page 81: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Parsing: Predicates to DCS Trees (DP)

81

Page 82: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Parsing: Predicates to DCS Trees (DP)

82

Page 83: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Parsing: Predicates to DCS Trees (DP)

83

Page 84: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Denotation

84

Assuming we have our world knowledge containing 1) unary predicates 2) binary predicates in a database.

Page 85: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Denotation

85

How can we assign values to different nodes?

?

?

?

Page 86: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Denotation

86

Constraint 1: the value in the each node should come from its corresponding predicate table.

Page 87: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Denotation

87

Constraint 2: the assignment of adjacent nodes need to meet the requirement in the edge.

Page 88: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Constraint Satisfaction Problem

88

A DCS tree assignment becomes a constraint satisfaction problem (CSP)

Page 89: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Constraint Satisfaction Problem

89

A DCS tree assignment becomes a constraint satisfaction problem (CSP)Dynamic Programming => time complexity = O(#node)

Page 90: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Learning

90

Page 91: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Learning

91

Page 92: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Learning

92

Page 93: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Semantic Forms

93

Liang, Chen et al. Neural Symbolic Machines: Learning Semantic Parsers on Freebase with Weak Supervision. 2017Liang, Chen et al. Memory Augmented Policy Optimization for Program Synthesis and Semantic Parsing. 2018Agarwal et al. Learning to Generalize from Sparse and Underspecified Rewards. 2019

- Combinatory Categorial Grammar- Definition- Rules- Learning

- Dependency-based compositional semantics- Definition- Rules- Learning

- Neural Symbolic Machine (Functional-Program)- Definition- Learning

Page 94: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Neural Symbolic Machine- Weakness of traditional Semantic Parsing

- The previous methods heavily rely on the predicate mapping, the mapping procedure is based on rules.

- The coverage is problematic when dealing with more complex utterance.- The previous frameworks are dominated by the composition rules enforced as prior,

only few parameters to learn.- The symbolic executor and the ranking model are separated without interaction.

94

Page 95: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Neural Symbolic Machine

95

Page 96: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Neural Symbolic Machine

96

NSM

Simplified Domain Specific Language

Almost no rules/triggers required

Interacted Learning & Search

Learning-driven framework

Page 97: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Domain Specific Language

97

Page 98: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Domain Specific Language

98

CCG DCS DSL

Evolution

1. CCG/DCS are both general-purpose semantic form.

2. Evolve gradually towards more domain-specific languages.

3. Sacrifice some generalization, but greatly simplify the induction procedure.

Loose Loose

Page 99: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Function definitions- (Hop v p): entities reached from v using relation p- (ArgHop v1 v2 p): entities in v1 from which v2 can be reached using relation p- (ArgMin v n): entities in v which have the lowest number in field n- (ArgMax v n): entities in v which have the highest number in field n- …- (Count v): number of entities in v

99

Page 100: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Compositionality

100

(USA) CityIn

(Hop v0 CityIn)

(Argmax v1 Population)

Population

x: Largest city in the US => y: NYC

Page 101: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Memory-aided Sequence

101

(USA) CityIn (Hop v0 CityIn) (Argmax v1 Population)

x: Largest city in the US => y: NYC

v0 (USA)

v1 (Hop ...)

v0 (USA)

The graph structure is flattened as sequence

Page 102: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Large Search Space

102

( Argmax v1 Population )

Hop

Count

v0 Size

Elevation

Page 103: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Compiler-aided prune

103

( Argmax v1 Population )

Hop

Count

v0 Size

Elevation

Code assistance

Page 104: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Semantic Parsing as Seq-to-Seq

104

Page 105: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Semantic Parsing as Seq-to-Seq

105

Page 106: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Semantic Parsing as Seq-to-Seq

106

Page 107: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Semantic Parsing as Seq-to-Seq

107

Page 108: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Memory Enc-Dec Model- Overall model is conditional distribution over all token sequences.

108

Page 109: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Memory Enc-Dec Model- Overall model is conditional distribution over all token sequences.

- NSM models the probability at each time step conditioned on previous output tokens and utterance

109

Page 110: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Memory Enc-Dec Model- Overall model is conditional distribution over all token sequences.

- NSM models the probability at each time step conditioned on previous output tokens and utterance

- NSM uses interpreter to aid the decoder by removing impossible tokens at each step to dramatically shrink search space.

110

Page 111: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Memory Enc-Dec Model

111

Page 112: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Syntactic Constraint

112

Page 113: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Semantic Constraint

113

Page 114: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Augmented REINFORCE- REINFORCE (explore)- Iterative Maximum Likelihood (exploit)

114

Page 115: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Wrap up- Formal Semantics does have many advantages like strong compositionality,

explainability.- However, the annotation effort or rigid structure makes it hard to scale up to

large-scale domains or more realistic datasets.- The vectorized representation in Deep Learning is still the favorable by the

community.- How to neuralize the formal semantics and apply it to modern architecture

remains an open problem.

115

Page 116: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

My Work1. Natural Language Understanding on Structured Data

a. Relation Question Answering on Knowledge Graph (Chen et al. NAACL 18)b. Table-based Fact Verification on semi-structured table (Chen et al. Arxiv)c. Multi-model Question Answering on structured scene graph (Chen et al. Arxiv)

2. Natural Language Generation on Structured Dataa. Semantically conditioned dialog generation on structured semantic form (Chen et al. ACL 19)

116

Page 117: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Open Question

- Philosophical problem

117

Meaning

Language Inference

Machine Translation

Summarization

Meaning serves for the success of downstream tasks

Page 118: Natural Language Learning with Formal Semantics · 2. Formal Semantics (Montague) - We construct the meaning of natural language in terms of variables, predicates, arguments. - Formal

Open Question

- Philosophical problem

118

Meaning

Language Inference

Machine Translation

Summarization

If we can already achieve high accuracy, why do we still need to care about meaning?