Recurrent Neural Network Agenda Recurrent Neural Network - - PowerPoint PPT Presentation

recurrent neural network agenda
SMART_READER_LITE
LIVE PREVIEW

Recurrent Neural Network Agenda Recurrent Neural Network - - PowerPoint PPT Presentation

Recurrent Neural Network Agenda Recurrent Neural Network NER sequence tagging RNN


slide-1
SLIDE 1

Recurrent Neural Network

slide-2
SLIDE 2

Agenda

  • Recurrent Neural Network ทําไมถึงเหมาะกับการทํา NER หรือ

sequence tagging

  • RNN มีิวิธีการทํางานอย่างไร มี parameter อะไรบ้าง
slide-3
SLIDE 3

x = feature vector h = hidden activation Peter Griffin lives in Quahog B-PER I-PER O O B-LOC y = label output

slide-4
SLIDE 4

Peter B-PER h1 = [x1; h0] Wh + tanh ( ) bh y1 = softmax(Wy h1 + by)

slide-5
SLIDE 5

Peter B-PER h2 = [x2; h1] Wh + tanh ( ) bh Griffin I-PER y2 = softmax(Wy h2 + by)

slide-6
SLIDE 6

Peter B-PER h3 = [x3; h2] Wh + tanh ( ) bh y3 = softmax(Wy h3 + by) Griffin I-PER O lives

slide-7
SLIDE 7

Peter Griffin lives in Quahog B-PER I-PER O O B-LOC

slide-8
SLIDE 8

Recurrent Neural Network Parameters

[xt; ht-1] Wh + = tanh ( ) bh ht = tanh(Wh ⋅ [xt; ht−1]) + bh yt = softmax(Wy ⋅ ht + by) ht + ) by ht Wy softmax (

slide-9
SLIDE 9

x = feature vector h = hidden activation Peter Griffin lives in Quahog B-PER I-PER O O B-LOC y = label output

slide-10
SLIDE 10

Peter Griffin lives in Quahog label = Neutral

RNN as a Classifier

slide-11
SLIDE 11

Recurrent Neural Network

  • เหมาะกับ Sequence Labeling ที่ต้องใช้บริบทกว้าง เช่น Language

Modeling, NER, ตัดคํา

  • เหมาะกับการใช้เป็น classifier เพราะเก็บบริบทได้ครบ
  • ในทางปฏิบัติแล้ว train ลําบาก
slide-12
SLIDE 12

Training RNN

slide-13
SLIDE 13

Concept ที่สําคัญ

  • Backpropagation Through Time (BPTT) algorithm
  • Exploding gradient
  • Vanishing gradient
slide-14
SLIDE 14

Backpropagation Through Time

slide-15
SLIDE 15

Exploding Gradient

slide-16
SLIDE 16

Vanishing Gradient

slide-17
SLIDE 17

การเทรน RNN

  • RNN Parameter น้อย แต่ว่าเทรนลําบาก
  • Exploding gradient ทําให้ Loss เป็น NaN หรือ parameter แกว่ง

มากในแต่ละ iteration --> Gradient Clipping

  • Vanishing gradient ทําให้ network ไม่เขยื้อน —> GRU, LSTM
slide-18
SLIDE 18

Gated Recurrent Unit (GRU) + Long Short-Term Memory (LSTM)

slide-19
SLIDE 19

RNN Cell

Peter ct = tanh(Wc ⋅ [ct−1; xt] + bc)

slide-20
SLIDE 20

RNN Cell

ct = tanh(Wc ⋅ [ct−1; xt] + bc) Peter RNN Cell

slide-21
SLIDE 21

(Simplified) Gated Recurrent Unit

˜ ct = tanh(Wc ⋅ [ct−1; xt] + bc)

Γu = σ(Wu ⋅ [ct−1; xt] + bu)

ct = Γu * ˜ ct + (1 − Γu) * ct−1

Peter B-PER

slide-22
SLIDE 22

(Simplified) Gated Recurrent Unit

˜ ct = tanh(Wc ⋅ [ct−1; xt] + bc)

Peter

slide-23
SLIDE 23

(Simplified) Gated Recurrent Unit

˜ ct = tanh(Wc ⋅ [ct−1; xt] + bc)

Γu = σ(Wu ⋅ [ct−1; xt] + bu)

Peter

slide-24
SLIDE 24

(Simplified) Gated Recurrent Unit

˜ ct = tanh(Wc ⋅ [ct−1; xt] + bc)

Γu = σ(Wu ⋅ [ct−1; xt] + bu)

ct = Γu * ˜ ct + (1 − Γu) * ct−1

Peter B-PER

slide-25
SLIDE 25

(Simplified) Gated Recurrent Unit

˜ ct = tanh(Wc ⋅ [ct−1; xt] + bc)

Γu = σ(Wu ⋅ [ct−1; xt] + bu)

ct = Γu * ˜ ct + (1 − Γu) * ct−1

Peter B-PER

slide-26
SLIDE 26

Gated Recurrent Unit

Peter B-PER ct GRU Cell ct−1

slide-27
SLIDE 27

Peter B-PER c1 GRU Cell c0 lives GRU Cell O c2 in GRU Cell O c3

slide-28
SLIDE 28

Long Short-Term Memory Unit

Peter B-PER ht LSTM Cell ht−1 ct−1 ct

slide-29
SLIDE 29

Peter B-PER c1 LSTM Cell c0 lives LSTM Cell O c2 in LSTM Cell O c3

slide-30
SLIDE 30

Peter Griffin lives in Quahog B-PER I-PER O O B-LOC

slide-31
SLIDE 31

Peter Griffin lives in Quahog B-PER I-PER O O B-LOC RNN

slide-32
SLIDE 32

Gated Recurrent Unit

  • RNN โดยทั่วไป เรียกว่า Vanilla RNN
  • GRU และ LSTM เป็น RNN แบบที่เทรนง่ายขึ้นเพราะ แก้ปัญหา

Vanishing gradient ได้ดี แต่ parameter เยอะขึ้น

slide-33
SLIDE 33

Bidirectional RNN

slide-34
SLIDE 34

Bidirectional RNN

  • Bidirectional Gated Recurrent Unit (Bi-GRU)
  • Bidirectional Long Short-Term Memory (Bi-LSTM)
  • BiLSTM + CRF
slide-35
SLIDE 35

x = feature vector h = hidden activation Peter Griffin lives in Quahog B-PER I-PER O O B-LOC y = label output

slide-36
SLIDE 36

Peter lives in Rhode Island B-PER O O B-LOC I-LOC

slide-37
SLIDE 37

Peter lives in Rhode Island ht

slide-38
SLIDE 38

Peter lives in Rhode Island ht ht

slide-39
SLIDE 39

Peter lives in Rhode Island ht ht B-PER O O B-LOC I-LOC [ht; ht]

BI-LSTM / BI-GRU

slide-40
SLIDE 40

Peter lives in Rhode Island ht ht B-PER O O B-LOC I-LOC [ht; ht]

BI-LSTM-CRF

slide-41
SLIDE 41

Bi-LSTM-CRF in Practice

slide-42
SLIDE 42

Word Embedding vs Discrete Features

Huang, Zhiheng, Wei Xu, and Kai Yu. "Bidirectional LSTM-CRF models for sequence tagging." arXiv preprint arXiv:1508.01991 (2015).

  • Discrete features เหมาะกับ CRF
  • Word embedding เหมาะกับ LSTM
slide-43
SLIDE 43

ควรใช้ Pre-trained Embedding

Huang, Zhiheng, Wei Xu, and Kai Yu. "Bidirectional LSTM-CRF models for sequence tagging." arXiv preprint arXiv:1508.01991 (2015).

slide-44
SLIDE 44

Almost State-of-the-art POS tagging

Huang, Zhiheng, Wei Xu, and Kai Yu. "Bidirectional LSTM-CRF models for sequence tagging." arXiv preprint arXiv:1508.01991 (2015).

slide-45
SLIDE 45

Almost State-of-the-art NER

Huang, Zhiheng, Wei Xu, and Kai Yu. "Bidirectional LSTM-CRF models for sequence tagging." arXiv preprint arXiv:1508.01991 (2015).

slide-46
SLIDE 46

สรุปคือยังไง

  • Bi-LSTM-CRF เป็นโมเดลที่มีประสิทธิภาพ เทรนไม่ยากมาก และใช้กัน

แพร่หลายตอนนี้ (ปี 2020)

  • ควรจะใช้ pre-trained embedding + discrete features
  • ไม่แน่เสมอไปว่าจะดีกว่า CRF หรือแม้แต่ Maximum Entropy