Top Banner
言言言言言言言言言言言言言言言言 Phillip Kazeto Yamamoto, Naoya Inoue, Kentaro Inui Tohoku Univ. NLP2015 1
53

言語処理のための仮説推論エンジン Phillip

Aug 04, 2015

Download

Kazeto Yamamoto
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 言語処理のための仮説推論エンジン Phillip

言語処理のための仮説推論エンジンPhillip

Kazeto Yamamoto, Naoya Inoue, Kentaro Inui

Tohoku Univ.

NLP2015

1

Page 2: 言語処理のための仮説推論エンジン Phillip

仮説推論って?

2

Page 3: 言語処理のための仮説推論エンジン Phillip

観測に対する最良の説明を導く推論 入力:背景知識 B, 観測 O :

– B : 一階述語論理の公理の集合– O : 一階述語論理のリテラルの論理積集合

出力: 解仮説 ( 説明 ) H* :評価関数 E に対して最も評価が高くなる仮説

    H* = arg max E(H)       H ∈ H

仮説推論( Abduction )

3

Page 4: 言語処理のための仮説推論エンジン Phillip

仮説推論( Abduction )

4

scientist(A)chimp(B)banana(C)give(E1)nsubj(E1,A)...

観測 O 背景知識 B

scientist(x) ⇒ human(x)chimp(x) ⇒ animal(x)kill(e1) ∧ dobj(e1,x) ⇒ die(e2) ∧ nsubj(e2,x)give(e1) ∧ dobj(e1,x) ∧ iobj(e1,y) ∧ food(y)

⇒ eat(e2) ∧ nsubj(e2,y) ∧ dobj(e2,x)...

解仮説 H*

入力

評価関数 E

H* = arg max E(H) H ∈ H

Page 5: 言語処理のための仮説推論エンジン Phillip

(∃e1,e2,x1,x2,y1,y2) John(x1) ∧ go(e1, x1, x2) ∧ bank(x2) ∧ he(y1) ∧ get(e2, y1, y2) ∧ loan(y2)

loan(y2) ⇒ (∃e2, y1, y3) issue(e2, y3, y2, y1) ∧ financial_inst(y3)

Interpretation as Abduction

issue(e2, y3, y2, y1)⇒ get(e2, y1, y2)

financial_inst(x2)⇒ bank(x2)

issue(e2, x2, x3, x1) ⇒ go(e2, x1, x2)

John went to the bank. He got a loan.

観測

入力

[Hobbs+, ‘93]

背景知識(公理)

Page 6: 言語処理のための仮説推論エンジン Phillip

(∃e1,e2,x1,x2,y1,y2) John(x1) ∧ go(e1, x1, x2) ∧ bank(x2) ∧ he(y1) ∧ get(e2, y1, y2) ∧ loan(y2)

loan(x3)

Interpretation as Abduction

issue(e2, y3, y2, y1)financial_inst(x2)

issue(e1, x2, x3, x1)

John went to the bank. He got a loan.

観測

入力

[Hobbs+, ‘93]

仮説(説明)

e1=e2, x2=y3,x3=y2, x1=y1

x3=y2

Page 7: 言語処理のための仮説推論エンジン Phillip

(∃e1,e2,x1,x2,y1,y2) John(x1) ∧ go(e1, x1, x2) ∧ bank(x2) ∧ he(y1) ∧ get(e2, y1, y2) ∧ loan(y2)

loan(x3)

Interpretation as Abduction

issue(e2, y3, y2, y1)financial_inst(x2)

issue(e1, x2, x3, x1)

John went to the bank. He got a loan.

観測

入力

[Hobbs+, ‘93]

仮説(説明)

e1=e2, x2=y3,x3=y2, x1=y1

x3=y2

bank = 銀行

he = JohnJohn が

bank へ行ったのはloan を得るため

Page 8: 言語処理のための仮説推論エンジン Phillip

☺ 我々が期待する仮説推論の有用性– 人間が解釈可能な説明を生成する– 世界知識を利用するための統一的な方法を提供する– NLP の様々なサブタスクを一つのモデルに集約できる

機械学習と組み合わせたい– 論理推論の強みと統計的学習の強みを自然な形で融合

仮説推論のタスク適用に関する過去の取り組み– 意図推定 [Ng+, ’92] ,含意関係認識 [Ovchinnikova+, ’11] ,

談話関係認識 [Sugiura+, ’12] ,共参照解析 [Inoue+, ‘12]

8

仮説推論( Abduction )

Page 9: 言語処理のための仮説推論エンジン Phillip

☺ 我々が期待する仮説推論の有用性– 人間が解釈可能な説明を生成する– 世界知識を利用するための統一的な方法を提供する– NLP の様々なサブタスクを一つのモデルに集約できる

機械学習と組み合わせたい– 論理推論の強みと統計的学習の強みを自然な形で融合

仮説推論のタスク適用に関する過去の取り組み– 意図推定 [Ng+, ’92] ,含意関係認識 [Ovchinnikova+, ’11] ,

談話関係認識 [Sugiura+, ’12] ,共参照解析 [Inoue+, ‘12]

9

仮説推論( Abduction )

☹ 実問題上での解析精度において,我々の期待を裏付けるような結果は未だ得られていないのが現状

Page 10: 言語処理のための仮説推論エンジン Phillip

仮説推論を取り巻く問題

10

Search

Learning

Knowledge

仮説の候補をどう探索するか

背景知識をどう獲得するか

評価関数のモデルパラメータを

どう調整 / 学習するか

Page 11: 言語処理のための仮説推論エンジン Phillip

仮説推論を取り巻く問題

11

Search

Learning

Knowledge

仮説の候補をどう探索するか

背景知識をどう獲得するか

評価関数のモデルパラメータを

どう調整 / 学習するか

それなりの時間で解が導けないと学習どころの話じゃない

仮説推論の計算量は知識の規模に強く依存する

学習するためにはまず正解を導くのに十分な量の知識が

既にあることが前提になる

最も重要!

Page 12: 言語処理のための仮説推論エンジン Phillip

実タスクにおける速度問題

12

B: 300,000+ axiomsO: 20 literals≧ 30 min.

7 min.

0.4 sec.

Mini-TACITUS[Mulkar-Mehta+, ‘07]

MLNs-based[Blythe+, ‘11]

ILP-based & CPI[Inoue+, ‘12]

state-of-the-art

B: 1,000,000+ axiomsO: 30 literals

何も起こらない 全部タイムアウト

Page 13: 言語処理のための仮説推論エンジン Phillip

Who’s Phillip?

13

Page 14: 言語処理のための仮説推論エンジン Phillip

一階述語論理の仮説推論エンジンです

14

scientist(A) chimp(B) banana(C) give(E1)

hungry(E2)

nsubj(E1,A) dobj(E1,C) iobj(E1,B)

nsubj(E2,x)he(x)

A scientist gave a chimp a banana.

Because he was hungry.

eat(u1) nsubj(u1,x)

^

^

give(u2) dobj(u2,u3) iobj(u2,x)food(u3)banana(u3)

C=u3E1=u2

E1=u2

C=u3

E1=u2

B=x

Page 15: 言語処理のための仮説推論エンジン Phillip

世界で一番速いです

15

B: 300,000+ axiomsO: 20 literals≧ 30 min.

7 min.

0.4 sec.

Mini-TACITUS[Mulkar-Mehta+, ‘07]

MLNs-based[Blythe+, ‘11]

ILP-based & CPI[Inoue+, ‘12]

Page 16: 言語処理のための仮説推論エンジン Phillip

世界で一番速いです

16

B: 1,000,000+ axiomsO: 30 literals≧ 30 min.

0.7 sec.

Phillip[Yamamoto+, ‘14]

ILP-based & CPI[Inoue+, ‘12]

Page 17: 言語処理のための仮説推論エンジン Phillip

柔軟にカスタマイズできます

17

観測背景知識解仮説

入力

潜在仮説集合 ILP 問題

Generator Solver

Converter

Page 18: 言語処理のための仮説推論エンジン Phillip

誰でも GitHub から利用可能です

18

github.com/kazeto/phillip

Page 19: 言語処理のための仮説推論エンジン Phillip

実問題にも適用し始めてます

19

Page 20: 言語処理のための仮説推論エンジン Phillip

高速な推論を実現するために

20

Page 21: 言語処理のための仮説推論エンジン Phillip

ILP based Abduction[Inoue+, ‘11]

観測 背景知識

整数線形計画問題

ILP ソルバー

解仮説

21潜在仮説集合(= 仮説候補に含まれうるリテラルの集合 )

ILP-based abduction

john(x) ^go(e) ^nsubj(e,x)...

go(e) => buy(...buy(e) => sell(......

max. ax1 + bx2 + ...s.t. x1 + x2 >= 3 ...

Page 22: 言語処理のための仮説推論エンジン Phillip

基本的なアイデア 解仮説に含まれる可能性の低い推論を

潜在仮説集合を生成する段階で除外する 解の候補の数が減ることによって

推論全体の計算量が軽減される

22

観測

背景知識

解仮説ILP ソルバー

潜在仮説集合

入力

削る削る

Page 23: 言語処理のための仮説推論エンジン Phillip

基本的なアイデア 解仮説に含まれる可能性の低い推論を

潜在仮説集合を生成する段階で除外する 解の候補の数が減ることによって

推論全体の計算量が軽減される

23

観測

背景知識

解仮説ILP ソルバー

潜在仮説集合

入力

削る削る

Page 24: 言語処理のための仮説推論エンジン Phillip

A* 探索に基づく潜在仮説集合生成[Yamamoto+, 14]

24

john(j) go_to(e1,j,s) store(s) buy(e2,j,b) book(b)

buy(e4,j,u1) book(u1) buy(e5,j,u2) food(u2) wood(b)paper(b)

wood(u1)paper(u1) apple(u2)

orange(u2)

banana(u2)

tomato(u2)

potato(u2)

carrot(u2)

peach(u2)

dictionary(u1)

comic(u1)burnable(u1) fruit(u2) vegetable(u2)

cedar(u1)

hinoki(u1)

cedar(u1)

hinoki(u1)rabbit(u3) eat(e6,u3,u2)

pine(u1)

it_company(u2)

...

book_store(s) sell(e3,u1,b)

dictionary(b)

comic(b)

burnable(b)

grocery(s)president(j)

musician(j)

man(j)

John went to the store and bought a book.観測

...

......

Page 25: 言語処理のための仮説推論エンジン Phillip

25

john(j) go_to(e1,j,s) store(s) buy(e2,j,b) book(b)

buy(e4,j,u1) book(u1) buy(e5,j,u2) food(u2) wood(b)paper(b)

wood(u1)paper(u1) apple(u2)

orange(u2)

banana(u2)

tomato(u2)

potato(u2)

carrot(u2)

peach(u2)

dictionary(u1)

comic(u1)burnable(u1) fruit(u2) vegetable(u2)

cedar(u1)

hinoki(u1)

cedar(u1)

hinoki(u1)rabbit(u3) eat(e6,u3,u2)

pine(u1)

it_company(u2)

...

book_store(s) sell(e3,u1,b)

dictionary(b)

comic(b)

burnable(b)

grocery(s)president(j)

musician(j)

man(j)

John went to the store and bought a book.

A* 探索に基づく潜在仮説集合生成[Yamamoto+, 14]

観測

解仮説に含まれる可能性がある推論だけを効率的に探索

Page 26: 言語処理のための仮説推論エンジン Phillip

無矛盾性のチェック

相互排他

26

shoot(e)^nsubj(e,x)^dobj(e,y)=> criminal(x)

shoot(e1) nsubj(e1,Tom) dobj(e1,u1)

have(e2) gun(u2) nsubj(e2,Tom) dobj(u2)

police(Tom)

criminal(Tom)

have(e1)^gun(y)^nsubj(e1,x)^dobj(e1,y)=> shoot(e2)^nsubj(e2,x)^dobj(e2,z)

police(x) =>have(e1)^gun(y)^nsubj(e1,x)^dobj(e1,y)

police(x) ⊥ criminal(x)

背景知識

Page 27: 言語処理のための仮説推論エンジン Phillip

イベントやオブジェクトを変数で表す イベントやオブジェクト間の関係はそれぞれ

一つのリテラルで表現される

☺可変個の依存関係を記述できる

Neo-Davidsonian

27

“John loves Mary.”

john(x1)mary(x2)love(e)

nsubj(e, x1)dobj(e, x2)

Page 28: 言語処理のための仮説推論エンジン Phillip

探索空間の爆発

28

die(e1) nsubj(e1,x) ... nsubj(e2,y) ... nsubj(e3,z) ...

kill(e1) ^ nsubj(e1,x) ^ dobj(e1,y)

=> die(e2) ^ nsubj(e2,y)

背景知識

kill(u1)nsubj(u1,u2)dobj(u1,x)

kill(u3)nsubj(u3,u4

)dobj(u3,x)

e1=e2

kill(u5)nsubj(u5,u6

)dobj(u5,x)

e1=e3

...

^ ^ ^

e1=e2x=y

e2=e3y=z

Page 29: 言語処理のための仮説推論エンジン Phillip

探索空間の爆発

29

die(e1) nsubj(e1,x) ... nsubj(e2,y) ... nsubj(e3,z) ...

kill(e1) ^ nsubj(e1,x) ^ dobj(e1,y)

=> die(e2) ^ nsubj(e2,y)

背景知識

kill(u1)nsubj(u1,u2)dobj(u1,x)

kill(u3)nsubj(u3,u4

)dobj(u3,x)

e1=e2

kill(u5)nsubj(u5,u6

)dobj(u5,x)

e1=e3

...

^ ^ ^

e1=e2x=y

e2=e3y=z

変数が一致することを公理適用の条件として課す

変数が表すイベントが互いに単一化可能でない場合は

それらの依存関係同士も単一化しない

Page 30: 言語処理のための仮説推論エンジン Phillip

実験

観測 背景知識

推論エンジン

1,111,790 個の公理Resource:

WordNetClueWeb12 から抽出した共参照事例

観測 25 問Winograd Schema Challenge に含まれるテキストから生成

比較対象 :1. ILP+CPI [Inoue&Inui, '12]

2. Phillip

求解時間を比較

タイムアウト :1800 sec.

30

Page 31: 言語処理のための仮説推論エンジン Phillip

結果

31

25 問全てでタイムアウト 11 問がタイムアウト

25 問全てにおいて60 秒以内に推論終了

Page 32: 言語処理のための仮説推論エンジン Phillip

柔軟なカスタマイズ

32

Page 33: 言語処理のための仮説推論エンジン Phillip

従来システムの問題点☹単一の評価関数のみを想定– ユーザが評価関数を定義することが不可能– ソースコードそのものを編集するしか無い

☹システム単体での利用のみを想定– 他プログラムへの組み込みを考慮していない

☹推論の内部処理を扱える人が限られる☹コミュニティが閉鎖的に

33

Page 34: 言語処理のための仮説推論エンジン Phillip

コンポーネント化された処理フロー

34

観測背景知識解仮説

入力

潜在仮説集合 ILP 問題

Generator Solver

Converter

潜在仮説集合を観測から生成

ILP 問題の最適解を導出

潜在仮説集合をILP 問題へ変換

Page 35: 言語処理のための仮説推論エンジン Phillip

他プログラムへの組み込み

35

#include <phillip.h>#include <binary.h>

class my_ilp_converter : public phil::ilp_converter_t{ 略 };

class my_ilp_converter_generator : public phil::bin::component_generator_t<phil::ilp_converter_t>{ 略 }

int main(){ using namespace phil; bin::ilp_converter_library_t::instance()->add( "mine", new my_ilp_converter_generator_t()); phillip_main_t phillip; bin::execution_configure_t config; bin::inputs_t inputs; bin::prepare(argc, argv, &phillip, &config, &inputs); bin::execute(&phillip, config, inputs);}

Phillip(lib/libphil.a)

組み込み先

Page 36: 言語処理のための仮説推論エンジン Phillip

他プログラムへの組み込み

36

#include <phillip.h>#include <binary.h>

class my_ilp_converter : public phil::ilp_converter_t{ 略 };

class my_ilp_converter_generator : public phil::bin::component_generator_t<phil::ilp_converter_t>{ 略 }

int main(){ using namespace phil; bin::ilp_converter_library_t::instance()->add( "mine", new my_ilp_converter_generator_t()); phillip_main_t phillip; bin::execution_configure_t config; bin::inputs_t inputs; bin::prepare(argc, argv, &phillip, &config, &inputs); bin::execute(&phillip, config, inputs);}

Phillip(lib/libphil.a)

組み込み先

Page 37: 言語処理のための仮説推論エンジン Phillip

今後の展望

37

Page 38: 言語処理のための仮説推論エンジン Phillip

公理の ”柔らかな” 適用述語が一致していないと公理を適用できない

☺探索空間が爆発しないで済む☹知識が足りなかったらその時点で終了

study(e1) ∧ nsubj(e1 x) ⇒ clever(e2) ∧ nsubj(e2 x)

clever(E1) nsubj(E1 X1) smart(E2) nsubj(E2 X2)

適用できる 適用できない

38

Page 39: 言語処理のための仮説推論エンジン Phillip

“ ソフトな” 仮説推論study(e1) ∧ nsubj(e1 x) ⇒ clever(e2) ∧ nsubj(e2 x)

smart(E) nsubj(E,X)

study(u1) ∧ nsubj(u1,X)背景知識

単語間の類似度

smart ≒ clever

39

Page 40: 言語処理のための仮説推論エンジン Phillip

Winograd Schema Challenge[Levesque+, '11]

共参照解析の難しい問題を集めたデータセット

人間なら簡単に読解できるが,伝統的な NLP 技術(選択選好・文脈類似度)では殆ど解くことが出来ない

Competition at AAAI-16 Symposia (prize: $25,000!)

☺推論システムのベンチマークとして有用

Ed shouted at Tim because he crashed the car.

Ed shouted at Tim because he was angry.

Page 41: 言語処理のための仮説推論エンジン Phillip

WSC への適用

観測 背景知識

Phillip

2,300,000 個の公理Resource:

WordNetClueWeb12 から獲得した共参照事例

観測 560 問Winograd Schema Challenge のテストデータから生成

解析精度を調査

41

Page 42: 言語処理のための仮説推論エンジン Phillip

結果

問題数 560

正解 227

不正解 190

解無し 143

適合率 54.4 %

再現率 40.5 %

推論時間 31 min.

42

Page 43: 言語処理のための仮説推論エンジン Phillip

やりたい事は沢山 パラメータの機械学習

– 学習アルゴリズムは既に提案されている[Inoue+, ‘12] [Yamamoto, ‘13]

– 近く Phillip 上で実装, WSC で実験– 外部ユーザ向けの機械学習用のパッケージも公開予定

談話を論理でどう表現するか– 否定,逆接,モダリティ,事実性, etc...

知識の拡充,高精度化– テリックや語の定義など

更なる高速化– より高度なグラフ探索手法の導入

43

Page 44: 言語処理のための仮説推論エンジン Phillip

まとめ従来システムより遥かに高速な推論エンジン

– ILP-based Abduction に基づいた実装– 解候補を生成する段階で候補を出来る限り枝刈り– 数百万規模の背景知識でも問題なく推論可能

他プログラムへの組み込みやユーザによるカスタマイズを考慮した実装– より多くの人が参入しやすい環境に

実タスクへの適用を開始しつつある– 種々の問題を実タスク上で検証できる段階に来た

推論エンジンは GitHub からパブリックに利用可能

44

Page 45: 言語処理のための仮説推論エンジン Phillip

おもしろいよ,仮説推論

45

github.com/kazeto/phillip

Page 46: 言語処理のための仮説推論エンジン Phillip

Backup!!

46

Page 47: 言語処理のための仮説推論エンジン Phillip

Look up Axioms

Axiom database

eat(e)

Look up axioms which include “eat” in the

consequence

chimp(x) banana(y) nsubj(e,x) dobj(e,y)

... ⇒ eat(e)

... ⇒ eat(e)

... ⇒ eat(e) ^ nsubj(e,x)

... ⇒ eat(e) ^ nsubj(e,x)

... ⇒ eat(e) ^ nsubj(e,x) ^ dog(x)

... ⇒ eat(e) ^ dobj(e,x)

... ⇒ eat(e) ^ dobj(e,x)

... ⇒ eat(e) ^ dobj(e,x) ^ meat(x)

... ⇒ eat(e) ^ with(e,x)

... ⇒ eat(e) ^ with(e,x)

... ⇒ eat(e) ^ with(e,x)

... ⇒ eat(e) ^ with(e,x) ^ fork(x)

... ⇒ eat(e) ^ for(e,x)

Pivot47

... ⇒ eat(e)

... ⇒ eat(e)

... ⇒ eat(e) ^ nsubj(e,x)

... ⇒ eat(e) ^ nsubj(e,x)

... ⇒ eat(e) ^ nsubj(e,x) ^ dog(x)

... ⇒ eat(e) ^ dobj(e,x)

... ⇒ eat(e) ^ dobj(e,x)

... ⇒ eat(e) ^ dobj(e,x) ^ meat(x)

... ⇒ eat(e) ^ with(e,x)

... ⇒ eat(e) ^ with(e,x)

... ⇒ eat(e) ^ with(e,x)

... ⇒ eat(e) ^ with(e,x) ^ fork(x)

... ⇒ eat(e) ^ for(e,x)

Page 48: 言語処理のための仮説推論エンジン Phillip

Look up Axioms

Pattern database

eat(e)

Look up consequence patterns which include “eat”

chimp(x) banana(y) nsubj(e,x) dobj(e,y)

{ eat }{ eat, nsubj }{ eat, nsubj, dog }{ eat, dobj }{ eat, dobj, meat }{ eat, with }{ eat, with, fork }{ eat, for }

Pivot

{ eat }{ eat, nsubj }{ eat, nsubj, dog }{ eat, dobj }{ eat, dobj, meat }{ eat, with }{ eat, with, fork }{ eat, for }

Axiom database

... ⇒ eat(e)

... ⇒ eat(e)

... ⇒ eat(e) ^ nsubj(e,x)

... ⇒ eat(e) ^ nsubj(e,x)

... ⇒ eat(e) ^ dobj(e,x)

... ⇒ eat(e) ^ dobj(e,x)

Look up axioms which correspond with the

patterns

48

Page 49: 言語処理のための仮説推論エンジン Phillip

Category Table 述語 p1, p2 について,リテラル (p1 x) からリテラル (p2 x) を仮説する難しさを表現した行列 仮説不可の場合は nil を返す

実装的には,述語 p1, p2 を引数として, (p1 x) から (p2 x) を仮説するためのコストを返すような仮想関数 評価関数ごとにそれぞれ適した実装を選択できる

49

smart clever wise fool

smart 0

clever 0

wise 0

fool 0

Page 50: 言語処理のための仮説推論エンジン Phillip

Category Table 述語 p1, p2 について,リテラル (p1 x) からリテラル (p2 x) を仮説する難しさを表現した行列 仮説不可の場合は nil を返す

実装的には,述語 p1, p2 を引数として, (p1 x) から (p2 x) を仮説するためのコストを返すような仮想関数 評価関数ごとにそれぞれ適した実装を選択できる

50

smart clever wise fool

smart 0 0.1

clever 0

wise 0.1 0

fool 0Knowledge Base

wise(e) ⇔ smart(e)

Page 51: 言語処理のための仮説推論エンジン Phillip

Category Table 述語 p1, p2 について,リテラル (p1 x) からリテラル (p2 x) を仮説する難しさを表現した行列 仮説不可の場合は nil を返す

実装的には,述語 p1, p2 を引数として, (p1 x) から (p2 x) を仮説するためのコストを返すような仮想関数 評価関数ごとにそれぞれ適した実装を選択できる

51

smart clever wise fool

smart 0 0.1

clever 0 nil

wise 0.1 0

fool nil 0Knowledge Base

fool(e) ⊥ clever(e)

Page 52: 言語処理のための仮説推論エンジン Phillip

Category Table 述語 p1, p2 について,リテラル (p1 x) からリテラル (p2 x) を仮説する難しさを表現した行列 仮説不可の場合は nil を返す

実装的には,述語 p1, p2 を引数として, (p1 x) から (p2 x) を仮説するためのコストを返すような仮想関数 評価関数ごとにそれぞれ適した実装を選択できる

52

smart clever wise fool

smart 0 0.2 0.1 3.7

clever 0.2 0 0.15 nil

wise 0.1 0.15 0 4.2

fool 3.7 nil 4.2 0Word Embeddings

Page 53: 言語処理のための仮説推論エンジン Phillip

演繹推論と仮説推論

演繹推論 仮説推論 仮説推論(現状)

公理を順方向に適用 ○ ○

公理を逆向きに適用 ○ ○

何も無いところから仮説 ○

53