abstract syntax networks for code generation and …mitchell/files/acl...abstract syntax networks...

Post on 23-May-2020

8 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Abstract Syntax Networks for Code Generation and Semantic Parsing

Maxim Rabinovich*, Mitchell Stern*, Dan Klein

Berkeley

N L P

Code Generation

[Ling et al. 2016]

Code Generation

class DireWolfAlpha(MinionCard):

def __init__(self):

super().__init__(

"Dire Wolf Alpha", 2,

CHARACTER_CLASS.ALL,

CARD_RARITY.COMMON,

minion_type=MINION_TYPE.BEAST)

def create_minion(self, player):

return Minion(2, 2, auras=[

Aura(ChangeAttack(1),

MinionSelector(Adjacent()))

])

Input Output [Ling et al. 2016]

Code Generation

class DireWolfAlpha(MinionCard):

def __init__(self):

super().__init__(

"Dire Wolf Alpha", 2,

CHARACTER_CLASS.ALL,

CARD_RARITY.COMMON,

minion_type=MINION_TYPE.BEAST)

def create_minion(self, player):

return Minion(2, 2, auras=[

Aura(ChangeAttack(1),

MinionSelector(Adjacent()))

])

Input Output [Ling et al. 2016]

Code Generation

class DireWolfAlpha(MinionCard):

def __init__(self):

super().__init__(

"Dire Wolf Alpha", 2,

CHARACTER_CLASS.ALL,

CARD_RARITY.COMMON,

minion_type=MINION_TYPE.BEAST)

def create_minion(self, player):

return Minion(2, 2, auras=[

Aura(ChangeAttack(1),

MinionSelector(Adjacent()))

])

Input Output [Ling et al. 2016]

Code Generation

class DireWolfAlpha(MinionCard):

def __init__(self):

super().__init__(

"Dire Wolf Alpha", 2,

CHARACTER_CLASS.ALL,

CARD_RARITY.COMMON,

minion_type=MINION_TYPE.BEAST)

def create_minion(self, player):

return Minion(2, 2, auras=[

Aura(ChangeAttack(1),

MinionSelector(Adjacent()))

])

Input Output [Ling et al. 2016]

Code Generation

class DireWolfAlpha(MinionCard):

def __init__(self):

super().__init__(

"Dire Wolf Alpha", 2,

CHARACTER_CLASS.ALL,

CARD_RARITY.COMMON,

minion_type=MINION_TYPE.BEAST)

def create_minion(self, player):

return Minion(2, 2, auras=[

Aura(ChangeAttack(1),

MinionSelector(Adjacent()))

])

Input Output [Ling et al. 2016]

The Main Idea

??

??

...

??

...

Card Representation

Dire Wolf Alpha name

cost 2

type Minion

rarity Common

race Beast

class Neutral

description Adjacent minions have

+1 Attack.

health 2

attack 2

class DireWolfAlpha(MinionCard):

def __init__(self):

super().__init__(

"Dire Wolf Alpha", 2,

CHARACTER_CLASS.ALL,

CARD_RARITY.COMMON,

minion_type=MINION_TYPE.BEAST)

def create_minion(self, player):

return Minion(2, 2, auras=[

Aura(ChangeAttack(1),

MinionSelector(Adjacent()))

])

[Ling et al. 2016] Input Output

Code Representations Aura(ChangeAttack(1), MinionSelector(Adjacent()))

[Ling et al. 2016]

Code Representations Aura(ChangeAttack(1), MinionSelector(Adjacent()))

[Ling et al. 2016]

Code Representations Aura(ChangeAttack(1), MinionSelector(Adjacent()))

Model Overview

Input Encoding Output

Encoding

Encoding

Dire Wolf Alpha name

cost 2

type Minion

rarity Common

race Beast

class Neutral

description Adjacent minions have

+1 Attack.

health 2

attack 2

Encoding

Dire Wolf Alpha name

cost 2

type Minion

rarity Common

race Beast

class Neutral

description Adjacent minions have

+1 Attack.

health 2

attack 2

. . .

Encoding

Dire Wolf Alpha name

cost 2

type Minion

rarity Common

race Beast

class Neutral

description Adjacent minions have

+1 Attack.

health 2

attack 2

. . .

Encoding

Dire Wolf Alpha name

cost 2

type Minion

rarity Common

race Beast

class Neutral

description Adjacent minions have

+1 Attack.

health 2

attack 2

. . .

Encoding

Dire Wolf Alpha name

cost 2

type Minion

rarity Common

race Beast

class Neutral

description Adjacent minions have

+1 Attack.

health 2

attack 2

. . .

Encoding

Dire Wolf Alpha name

cost 2

type Minion

rarity Common

race Beast

class Neutral

description Adjacent minions have

+1 Attack.

health 2

attack 2

. . .

Decoder Architecture

Decoder Architecture

Decoder Architecture

expr

BinOp Name Call ...

Decoder Architecture

??

expr

BinOp Name Call ...

Call

Decoder Architecture

??

expr

BinOp Name Call ...

Call

Decoder Architecture

??

Call

func args

expr

BinOp Name Call ...

Call

Decoder Architecture

??

Call

func args

expr expr*

expr

BinOp Name Call ...

Call

identifier

“x” ... “Aura”

Decoder Architecture

??

Call

func args

expr expr*

expr

BinOp Name Call ...

Call

identifier

“x” ...

“Aura”

“Aura”

Decoder Architecture

??

Call

func args

expr expr*

Decoding Process

Decoding Process

Decoding Process

expr

BinOp Name Call ...

??

Decoding Process

expr

BinOp Name Call ...

??

Decoding Process

expr

BinOp Name Call ...

Call

??

Decoding Process

Call

func args

Decoding Process

Call

func args

Decoding Process

Call

func args

expr expr*

Decoding Process

Call

func args

expr expr*

Decoding Process

expr

BinOp Name Call ...

??

Decoding Process

expr

BinOp Name Call ...

??

Decoding Process

expr

BinOp Name Call ...

Name

??

Decoding Process

Decoding Process

Decoding Process

expr*

Next Stop

??

Decoding Process

expr*

Next Stop

??

Decoding Process

expr*

Next Stop

??

Decoding Process

Decoding Process

expr*

Next Stop

??

Decoding Process

expr*

Next Stop

??

Decoding Process

expr*

Next Stop

??

Decoding Process

Decoding Process

expr*

Next Stop

??

Decoding Process

expr*

Next Stop

??

Decoding Process

expr*

Next Stop

??

Stop

Training

Training

??

Training

??

Training

??

??

...

??

...

Training

??

??

...

??

...

Hearthstone Results

0

5

10

15

20

25

Exact Match Accuracy (%)

Hearthstone Results

Nearest Ling et al. (2016)

ASN ASN +SupAtt

3.0

6.1

0

5

10

15

20

25

Exact Match Accuracy (%)

Hearthstone Results

Nearest Ling et al. (2016)

ASN ASN +SupAtt

3.0

6.1

18.2

0

5

10

15

20

25

Exact Match Accuracy (%)

Hearthstone Results

Nearest Ling et al. (2016)

ASN ASN +SupAtt

3.0

6.1

18.2

22.7

0

5

10

15

20

25

Exact Match Accuracy (%)

Hearthstone Results

Nearest Ling et al. (2016)

ASN ASN +SupAtt

Hearthstone Results

65.0 67.1

77.6 79.2

50

55

60

65

70

75

80

85

Token BLEU

Nearest Ling et al. (2016)

ASN ASN +SupAtt

Hearthstone Results

65.7

72.4

75.6

50

55

60

65

70

75

80

Tree F1

Nearest ASN ASN +SupAtt

Semantic Parsing

show me the fare from ci0 to ci1

𝜆𝑥. ∃𝑦.from(𝑦,ci0) ∧ to(𝑦,ci0) ∧ equals fare(𝑦 , 𝑥)

Semantic Parsing Results

87.1

85.7

87.1

90.4 WKZ14

DL16

ASN

ASN+SupAtt

87.1

85.3

84.6

91.3 WKZ14

DL16

ASN

ASN+SupAtt

92.9

91.4

90.0

90.7 LJK13

DL16

ASN

ASN+SupAtt

Geo

ATIS

Jobs

[Wang, Kwiatkowski, Zettlemoyer 2014] [Dong and Lapata 2016] [Liang, Jordan, Klein 2013]

Conclusion

Code generation and similar systems benefit from:

– Representing structure in output space

– Modular network architectures

Thanks!

top related