15
Recursive Structure

Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Recursive Structure

Page 2: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

x1

h0 f h1

x2

f

x3

h2 f

x1

h1

f

x2 x3

Application: Sentiment Analysis

x4

h3 f g

x4

f

h2

f

h3 gWord Sequence

sentiment

Recurrent Structure

Recursive Structure

Special case of recursive structure

How to stack function f is already determined

same dimension

word vector

Page 3: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Recursive Model

not very good

not very good

syntactic structure

word sequence:

How to do it is out of the scope

Page 4: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Recursive Model

f

By composing the two meaning, what should the meaning be.

Meaning of “very good”V(“very good”)

not very good

syntactic structure

not very good

V(“not”) V(“very”) V(“good”)

Dimension of word vector = |Z|

Input: 2 X |Z|, output: |Z|

Page 5: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Recursive Model

not very good

V(“not”) V(“very”) V(“good”)

f

not very good

syntactic structureV(wA wB) ≠ V(wA) + V(wB)

“good”: positive

“not”: neutral

“not good”: negative Meaning of “very good”V(“very good”)

Page 6: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Recursive Model

V(wA wB) ≠ V(wA) + V(wB)

“棒”: positive

“好棒”: positive

“好棒棒”: negative

not very good

V(“not”) V(“very”) V(“good”)

f

not very good

syntactic structure

Meaning of “very good”V(“very good”)

network

Page 7: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Recursive Model

not very good

V(“not”) V(“very”) V(“good”)

f

not very good

syntactic structure

f

“not” “good”

f

“not” “bad”

“not bad”“not good”

“not”: “reverse” another input

Meaning of “very good”V(“very good”)

Page 8: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Recursive Model

not very good

V(“not”) V(“very”) V(“good”)

f

not very good

syntactic structure

f

“very” “good”

f

“very” “bad”

“very bad”“very good”

“very”: “emphasize” another input

Meaning of “very good”V(“very good”)

Page 9: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

f

f

V(“not”) V(“very”) V(“good”)

g

-

output5 classes

( -- , - , 0 , + , ++ )

not very good

ref

f

g

Train both …V(“not very good”)

Page 10: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Recursive Neural Tensor Network

f

𝑎 𝑏

𝑝

W= 𝜎

Little interaction between a and b

+= 𝜎

x

xT

W

𝑖,𝑗

𝑊𝑖𝑗𝑥𝑖𝑥𝑗

Page 11: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Experiments

5-class sentiment classification ( -- , - , 0 , + , ++ )

Demo: http://nlp.stanford.edu:8080/sentiment/rntnDemo.html

Page 12: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Experiments

Socher, Richard, et al. "Recursive deep models for semantic compositionality

over a sentiment treebank." Proceedings of the conference on empirical

methods in natural language processing (EMNLP). Vol. 1631. 2013.

Page 13: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

f

Matrix-Vector Recursive Network

inherent meaning

how it changes the others

not good

𝑎 𝐴 𝑏 𝐵Zero? Identity?

Informative?−1 00 −1

?

=

=W𝜎 = WM

=

Page 14: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

Tree LSTMht-1

xt

LSTM

mt-1

ht

mt

h1 m1 h2m2

LSTM

h3 m3

Typical LSTM

Tree LSTM

Page 15: Recursive Structure - 國立臺灣大學speech.ee.ntu.edu.tw/~tlkagk/courses/MLDS_2018/Lecture/Recursive.pdf · •Sentence relatedness NN Sentence 1 Sentence 2 Recursive Neural Network

More Applications

• Sentence relatedness

NN

Sentence 1 Sentence 2

Recursive Neural

Network

Recursive Neural

Network

Tai, Kai Sheng, Richard Socher, and

Christopher D. Manning. "Improved

semantic representations from tree-

structured long short-term memory

networks." arXiv preprint

arXiv:1503.00075 (2015).