smartsynth : synthesizing smartphone automation scripts from natural language

31
SmartSynth: Synthesizing Smartphone Automation Scripts from Natural Language Vu Le (UC Davis) Sumit Gulwani (MSR Redmond) Zhendong Su (UC Davis)

Upload: mikko

Post on 14-Feb-2016

71 views

Category:

Documents


0 download

DESCRIPTION

SmartSynth : Synthesizing Smartphone Automation Scripts from Natural Language. Vu Le (UC Davis) Sumit Gulwani (MSR Redmond) Zhendong Su (UC Davis). motivation. programming. Tasker. App Inventor. natural language. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

SmartSynth: Synthesizing Smartphone Automation

Scripts from Natural Language

Vu Le (UC Davis)Sumit Gulwani (MSR Redmond)

Zhendong Su (UC Davis)

Page 2: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

motivation

Page 4: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

natural languageWhen I receive a new SMS, if the phone is connected to my car’s bluetooth, it reads the message content and replies the sender “I’m driving.”

Page 5: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

scriptwhen (number, content) := MessageReceived()

if (IsConnectedToBTDevice(Car_BT) then

Speak(content);SendMessage(number, "I'm driving");

Page 6: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

SmartScriptScript P ::= I E T C MParameter I ::= input (i1, …, in) | εEvent E ::= (r1, …, rn) := when Event() | εConversions T ::= F1; …; Fn; Condition C ::= if (Π1 ∧ … ∧ Πn) then | εBody M ::= Stmt1; … ; Stmtn;Conversion F ::= x := Convert(a)Predicate Π ::= Predicate (a1, …, an) Statement Stmt ::= S | foreach x in a do S1; … ; Sn; odAtomic Stmt. S ::= A | FAction A ::= (r1, …, rn) := Action (a1, …, an) Argument a ::= x | i | r | l

Page 7: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

approachScript = Components +

Relations

Page 8: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

approachScript = Components +

Relations

Page 9: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

approachScript = Components +

Relations

Page 10: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

approachScript = Components +

Relations

Page 11: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

definitiono Component

• API: MessageReceived• Entity• Literal: “I’m driving”• API return value: MessageReceived.TextO

o Relation = <Entity, API parameter>• E.g., < “I’m driving”, SendMessage.TextI

>

Page 12: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

component discovery

Description ComponentWhen I receive a new SMS

MessageReceived

if the phone is connected to

IsConnectedToBTDevice

my car’s bluetooth Car_BTreads Speakthe message content MessageReceived.TextO

replies SendMessagethe sender MessageReceived.Num

berO

“I’m driving” "I'm driving"

Page 13: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

mapping featureso Regular expressionso Bag of wordso Phrase lengtho Punctuationo Parse tree (Stanford NLP parser)

Page 14: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

relation discoveryo Rule-based relation detection

• Relative locations of APIs and entities

Return Value or Literal API ParameterCar_BT IsConnectedToBTDevice.T

extI

MessageReceived.TextO Speak.TextIMessageReceived.NumberO

SendMessage.NumberI

“I’m driving” SendMessage.TextI

Page 15: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

script generationwhen (number, content) := MessageReceived()

if (IsConnectedToBTDevice(Car_BT) then

Speak(content);

SendMessage(number, "I'm driving");

Page 16: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

ambiguityDescription Possible Component

MappingsWhen I receive a new SMS

MessageReceived

if the phone is connected to

IsConnectedToBTDeviceIsConnectedToWifiNetworkIsConnectedToDataService

my car’s bluetooth Car_BTreads Speakthe message content MessageReceived.TextO

repliesSendMessageSendEmail

“I’m driving” "I'm driving"

Page 17: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

incompletenesswhen (number, content) := MessageReceived()

if (IsConnectedToBTDevice(Car_BT) then

Speak(content);

SendMessage(number, "I'm driving");

Page 18: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

insightNLP + Program

Synthesis

Page 19: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

ambiguity{ MessagedReceived, IsConnectedToBTDevice, Car_BT,

Speak, MessageReceived.TextO, (SendMessage OR SendEmail), "I'm driving“ }

Ranking

Script 1 (SendMessage)

SendMessage

SendEmails

Script 1

Script 2

Synthesizer

Page 20: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

incompletenesso Search for most likely missing

relations

Page 21: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

q & ao Distinguishing multiple choice

questions• Question: API parameter• Answers: Equally-likely related entities

What do you want the phone to speak?A. The received message contentB. “I’m driving”

Page 22: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

architecture

Component Discovery

ScriptDiscovery

Natural LanguageDescription

MappingComponents

IntendedScript

Natural LanguageQ&A (Optional)

1

2

3

5

User

Feedback onDescription (Optional)

6

Feedback onComp. Mapping

4

Page 23: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

evaluationo 50 scripts collected from user forumso User study: give NL descriptions from

scripts• 11 students participated• Each student was given 25 problems• 640 correct descriptions (725 total)

Page 24: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

component mapping

[1] [1] [2] [1] [2] [3] [1][2][3][4] SmartSynth0

10

20

30

40

50

60

70

80

90

100

Series1[1] Regex + Bags-of-Words [2] Phrase length[3] Punctuation [4] Parse tree

Page 25: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

relation detection

1 2 3 4 7 80

1

2

3

4

5

# Relations

# D

etec

ted

Rela

tions

Page 26: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

completing ratio

0 1 2 3 4 7 80

50

100

150

200

250

Detected by NLP Engine Completed by Synthesis Engine

# Relations

# De

scrip

tions

Page 27: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

synthesis time

2 3 4 5 6 7 8 10 11 120

1

2

3

4

5

6

7

Parsing time Total time

# Components

Tim

e (s

)

Page 28: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

related worko General purpose programming using

natural languageo Natural language interfaceso Specification extraction from natural

language

Page 29: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

thank youScript = Components +

Relations

NLP

Program Synthesis

Identify

Detect

Resolve

Complete

Page 30: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

v.s. SiriConversation

Single phone API

Composition of APIs

Siri

SmartSynth

Page 31: SmartSynth :  Synthesizing Smartphone Automation  Scripts from Natural Language

v.s. Tasker

TaskerSmartSynth

Time

Prod

uctiv

ity