47
単語埋込みモデルによる 意味論,統語論,隠喩,暗喩の計算(仮) Shin Asakawa <[email protected]>

2016word embbed supp

Embed Size (px)

Citation preview

Page 1: 2016word embbed supp

単語埋込みモデルによる意味論,統語論,隠喩,暗喩の計算(仮)

浅川伸一 Shin Asakawa <[email protected]>

Page 2: 2016word embbed supp

2

謝辞

発表の機会を与えてくださいました京都大

学楠見孝先生に感謝申し上げます。

Page 3: 2016word embbed supp

3

自己紹介浅川伸一 東京女子大学 情報処理センター勤務。早稲田大

学在学時はピアジェの発生論的認識論に心酔する。卒業後

エルマンネットの考案者ジェフ・エルマンに師事,薫陶を受け

る。以来人間の高次認知機能をシミュレートすることを目指

している。知的情報処理機械を作ることを通して知的情報処

理とは何かを考えたいと思っている。著書に「Pythonで実践する深層学

習」( 2016) コロナ社. 「ディープラーニング,ビッグデータ,機械学習 --- あるいはその心理学」

(2015) 新曜社。「ニューラルネットワークの数理的基礎」「脳損傷とニューラルネットワークモデ

ル,神経心理学への適用例」いずれも守一雄他編 コネクショニストモデルと心理学(2001) 北

大路書房などがある

Page 4: 2016word embbed supp

4

師匠ジェフ・エルマンとUCSDキャンパス内 2002年ころ

Page 5: 2016word embbed supp

5

←2016年

2015年→

Page 6: 2016word embbed supp

6

表記と基本グラフ

h

y

x

y: 出力層ニューロン

h: 中間層ニューロン

x: 入力層ニューロン

Page 7: 2016word embbed supp

7

h

y

x

再帰結合(recurrent connections)

Page 8: 2016word embbed supp

8

h

y

x

Wx

Wy

Wh

Wy:結合係数行列(中間から出力)

Wh:結合係数行列(再帰結合)

Wx:結合係数行列(入力から中間)

Page 9: 2016word embbed supp

9

h

y

x

Wx+bx

Wy+by

Wh+bh

by:バイアス(中間から出力)

bh:バイアス(再帰結合)

bx:バイアス(入力から中間)

Bias terms will be omitted, henceforth以降バイアス項は省略します

Page 10: 2016word embbed supp

10

h0

y0

x0

h1

y1

x1

Digits subscripted indicate time t:= 0... 下付き添字は時刻を表す。カッコで表記する流儀もある(e.g. x(t))

Page 11: 2016word embbed supp

11

h0

y0

x0

h1

y1

x1

h1

y1

x1

h2

y2

x2

h3

y3

x3

h4

y4

x4

h4

y4

x4

h5

y5

x5

Page 12: 2016word embbed supp

12

h0

y0

x0

h1

y1

x1

h1

y1

x1

h2

y2

x2

h3

y3

x3

h4

y4

x4

h4

y4

x4

h5

y5

x5

teacher

error

Loss(t,y)

Wh Wh Wh Wh Wh

Page 13: 2016word embbed supp

13

h0

y0

x0

h1

y1

x1

h1

y1

x1

h2

y2

x2

h3

y3

x3

h4

y4

x4

h4

y4

x4

h5

y5

x5

teacher

error

Loss(t,y)

Wh Wh Wh Wh Wh

Page 14: 2016word embbed supp

14

h0

y0

x0

h1

y1

x1

h1

y1

x1

h2

y2

x2

h3

y3

x3

h4

y4

x4

h4

y4

x4

h5

y5

x5

teacher

error

Loss(t,y)

Wh Wh Wh Wh Wh

Page 15: 2016word embbed supp

15

h0

y0

x0

h1

y1

x1

h1

y1

x1

h2

y2

x2

h3

y3

x3

h4

y4

x4

h4

y4

x4

h5

y5

x5

teacher

error

Loss(t,y)

Wh Wh Wh Wh Wh

teacher

Page 16: 2016word embbed supp

16

h0

y0

x0

h1

y1

x1

h1

y1

x1

h2

y2

x2

h3

y3

x3

h4

y4

x4

h4

y4

x4

h5

y5

x5

teacher

error

Loss(t,y)

Wh Wh Wh Wh Wh

Page 17: 2016word embbed supp

17

Full BPTT

h0

y0

x0

h1

y1

x1

h1

y1

x1

h2

y2

x2

h3

y3

x3

h4

y4

x4

h4

y4

x4

h5

y5

x5

teacher

error

Loss(t,y)

Wh Wh Wh Wh Wh

Page 18: 2016word embbed supp

18

Trancated BPTT(window width=5)

ht+0

yt+0

xt+0

h1

y1

x1

ht+1

yt+1

xt+1

ht+2

yt+2

xt+2

ht+3

yt+3

xt+3

h4

y4

x4

ht+4

yt+4

xt+4

ht+5

yt+5

xt+5

teacher

error

Loss(t,y)

Wh Wh Wh Wh Wh

Page 19: 2016word embbed supp

19

LSTM

Page 20: 2016word embbed supp

改良可能?Can we improve?

Page 21: 2016word embbed supp

ゲートの導入 introducing gates to control hidden state

ht-1

yt-1

xt-1

h1

y1

x1

ht

yt

xt

gate

Page 22: 2016word embbed supp

ゲートの導入 introducing gates to control hidden state

ht-1

yt-1

xt-1

h1

y1

x1

ht

yt

xt

gate

でも,

なぜゲート?

Why gates?

Page 23: 2016word embbed supp

忘却ゲートの導入

ht-1

yt-1

xt-1

h1

y1

x1

ht

yt

xt

gate

Who can controlgates?誰がどうやってゲート制御?

Page 24: 2016word embbed supp

忘却ゲートの導入

ht-1

yt-1

xt-1

h1

y1

x1

ht

yt

xt

gate

Who can controlgates?誰がどうやってゲート制御?

Who can tell me how can I

control myself?

Page 25: 2016word embbed supp

忘却ゲートの導入

ht

yt

xt

h1

y1

x1

ht+1

yt+1

xt+1

gate

who can control gates?誰がどうやってゲートを制御?

3つ候補

Page 26: 2016word embbed supp

忘却ゲートの導入

ht

yt

xt

h1

y1

x1

ht+1

yt+1

xt+1

gate

who can control gates?誰がどうやってゲートを制御?

3つ候補1. ht

Page 27: 2016word embbed supp

It’s me

忘却ゲートの導入

ht

yt

xt

h1

y1

x1

ht+1

yt+1

xt+1

gate

who can control gates?誰がどうやってゲートを制御?

3つ候補1. ht

Page 28: 2016word embbed supp

Me, too

忘却ゲートの導入

ht

yt

xt

h1

y1

x1

ht+1

yt+1

xt+1

gate

who can control gates?誰がどうやってゲートを制御?

3つ候補1. ht

2. yt

Page 29: 2016word embbed supp

I can, too

忘却ゲートの導入

ht

yt

xt

h1

y1

x1

ht+1

yt+1

xt+1

gate

who can control gates?誰がどうやってゲートを制御?

3つ候補1. ht

2. yt

3. xt+1

Page 30: 2016word embbed supp

忘却ゲートの導入

ht

yt

xt

h1

y1

x1

ht+1

yt+1

xt+1

gate

ゲート制御

1. ht

2. yt

3. xt+1

ht+1 = ht s(x)

● s(x) = (1+e-x)-1

● x = Wf (yt + ht + xt+1)

Page 31: 2016word embbed supp

ゲートによって長距離依存LTDを解消可能

Page 32: 2016word embbed supp

もっと改良可能?Can we improve more?

Page 33: 2016word embbed supp

入力ゲートの導入

ht

yt

xt

ht+1

yt+1

xt+1

gate

gate

ht+1 = ht s(w(ht + xt+1))

● s(x) = (1+e-x)-1

● x = yt + ht + xt+1

Page 34: 2016word embbed supp

もっともっと可能?You need more?

Page 35: 2016word embbed supp

出力ゲートの導入

ht

yt

xt

ht+1

yt+1

xt+1

gate

gate

gate

ht+1 = ht s(w(ht + xt+1 + yt+1))

● s(x) = (1+e-x)-1

● x = yt + ht + xt+1

Page 36: 2016word embbed supp

LSTM

Page 37: 2016word embbed supp

LSTM の生理学的対応物

http://kybele.psych.cornell.edu/~edelman/Psych-2140/week-2-2.html

Page 38: 2016word embbed supp

How does LSTM work?1. LSTM replaces logistic or tanh hidden units with “memory cells” that

can store an analog value.

2. Each memory cell has its own input and output gates that control.

3. There is a forget gate which the analog value stored in the memory celldecays.

4. For periods when the input and output gates are off and the forget gate is

not causing decay, a memory cell simply holds its value over time.

Le, Jaitly, & Hinton (2015)

Page 39: 2016word embbed supp

別モデル GRU An alternative of the LSTM

h~h

x

y

r: resetgate

input

output

u update

gate

ut = s (W

u + u

u )

ht = f (W

h + u

h (u

t @ )

rt = s (W

r + u

r h

t-1)

tilde(h) = (1- rt) h

t + r

t tilde(h

t-1)

yt = W

y tilde(h

t)

Page 40: 2016word embbed supp

別モデル GRU An alternative of the LSTM

h~h

x

y

r: resetgate

input

output

u update

gate

ut = σ (Wuxt + Uuht−1) .ht = ϕ (Wxt + Uh (ut ⊙ht−1)) ,rt = σ (Wrxt + Urht−1) ,h̃t = ( 1 − rt) ht + rth̃t−1,yt = Wyh̃t

Page 41: 2016word embbed supp

双方向RNN (Bidirectional RNN)

前行ステート

逆行ステート

yt-1

xt-1

yt

xt

yt+1

xt+1

Page 42: 2016word embbed supp

グレーブス (Graves, 2013)の生成 LSTM出力

中 間 層

入力

Page 43: 2016word embbed supp

深層 LSTM Depth Gated LSTM

ht− 1

( a ) 直 前 ( b ) 生 成 ( c ) 再 帰 ( d ) 推 論 ( e ) 全関与

ht

zt

x t

ht− 1 ht

zt

x t

ht− 1 ht

zt

x t

ht− 1 ht

zt

x t

ht− 1 ht

zt

x t

図 4.31 種々の LSTM 変種

Page 44: 2016word embbed supp

Pascanu (2014) よりy( t )

h( t )h( t− 1)

x( t )

y( t )

h( t )h( t − 1)

x( t )

y( t )

h( t )h( t − 1)

x( t )

( a ) ( b ) ( c )

y( t )

h( t )h( t − 1)

x( t )

y( t )

h( t − 1)

x( t ) z( t )

z( t )h( t )

( d ) ( e )図 4.27 パスカヌらの文献 108) の図 2 を改変

Page 45: 2016word embbed supp

Pascanu (2014) より

I * x i

m

h

m ′1h ′1

m ′2

h ′2

m 1h 1

m 2

h 2

m ′

h ′

h ′

2 次元格子状 LSTMブロック

標準の LSTMブロック

1 次元格子状 LSTMブロック

3 次元格子状 LSTMブロック

Page 46: 2016word embbed supp

Pascanu (2014) より出力層

入力層

隠れ層

T1 T2 Tg

図 4.33 時 計 状 LSTM

Page 47: 2016word embbed supp

47

Actor is Schmithuber who proposed LSTM https://www.youtube.com/watch?v=-OodHtJ1saY