miltos1 https://miltos.allamanis.com Microsoft Research Cambridge - - PowerPoint PPT Presentation

miltos1 https miltos allamanis com
SMART_READER_LITE
LIVE PREVIEW

miltos1 https://miltos.allamanis.com Microsoft Research Cambridge - - PowerPoint PPT Presentation

miltos1 https://miltos.allamanis.com Microsoft Research Cambridge http://www.eclipse.org/recommenders/ https://visualstudio.microsoft.com/services/intellicode/ Predicting Program Properties from Code Deep Learning Type Inference V. Raychev,


slide-1
SLIDE 1

Microsoft Research Cambridge

miltos1 https://miltos.allamanis.com

slide-2
SLIDE 2
slide-3
SLIDE 3

https://visualstudio.microsoft.com/services/intellicode/ http://www.eclipse.org/recommenders/

slide-4
SLIDE 4

http://jsnice.org/

Deep Learning Type Inference

  • V. Hellendoorn, C. Bird, E.T. Barr, M. Allamanis. 2018

Predicting Program Properties from Code

  • V. Raychev, M. Vechev, A. Krause. 2015
slide-5
SLIDE 5

Defined Types

string string

slide-6
SLIDE 6
slide-7
SLIDE 7

Resea earch h in ML+Cod +Code

slide-8
SLIDE 8
slide-9
SLIDE 9

Target Task

slide-10
SLIDE 10
slide-11
SLIDE 11

int int int int return for (int i =0; < ; ++) if ( [ ]>0) += [ ]; int int int int return for (int i = 0; i < lim; i++) if (arr[i] > 0) sum += arr[i];

Programs as Graphs: Key Idea

slide-12
SLIDE 12

Assert.NotNull(clazz);

Assert . ( NotNull … ExpressionStatement InvocationExpression MemberAccessExpression ArgumentList Next Token AST Child

Programs as Graphs: Syntax

slide-13
SLIDE 13

(x, y) = Foo(); while (x > 0) x = x + y;

Last Write Last Use Computed From

Programs as Graphs: Data Flow

slide-14
SLIDE 14

Programs as Graphs

int int int int return for (int i =0; < ; ++) if ( [ ]>0) += [ ]; ~900 nodes/graph ~8k edges/graph

slide-15
SLIDE 15

Graph Representation for Variable Misuse

B A E G D C F

slide-16
SLIDE 16

Graph Representation for Variable Misuse

B A E G D C F

slide-17
SLIDE 17

Vector Space Representations

slide-18
SLIDE 18

Graph Neural Networks

B A E G D C F

Li et al (2015). Gated Graph Sequence Neural Networks.

B A E G D C F Gilmer et al (2017). Neural Message Passing for Quantum Chemistry.

slide-19
SLIDE 19

Graph Neural Networks: Message Passing

E D F B A E G D C F

slide-20
SLIDE 20

Graph Neural Networks: Message Passing

E D F

Li et al (2015). Gated graph sequence neural networks.

B A E G D C F

slide-21
SLIDE 21

Graph Neural Networks: Unrolling

slide-22
SLIDE 22

Graph Neural Networks: Unrolling

Li et al (2015). Gated graph sequence neural networks.

slide-23
SLIDE 23

Graph Neural Networks: Unrolling

Li et al (2015). Gated Graph Sequence Neural Networks. Gilmer et al (2017). Neural Message Passing for Quantum Chemistry.

  • node selection
  • node classification
  • graph classification

https://github.com/Microsoft/gated-graph-neural-network-samples

slide-24
SLIDE 24

Quantitative Results – Variable Misuse

Seen Projects: 24 F/OSS C# projects (2060 kLOC): Used for train and test 3.8 type-correct alternative variables per slot (median 3, σ= 2.6)

Accuracy (%) BiGRU BiGRU+Dataflow GGNN Seen Projects 50.0 73.7 85.5

slide-25
SLIDE 25

Quantitative Results – Variable Misuse

Accuracy (%) BiGRU BiGRU+Dataflow GGNN Seen Projects 50.0 73.7 85.5 Unseen Projects 28.9 60.2 78.2

Seen Projects: 24 F/OSS C# projects (2060 kLOC): Used for train and test Unseen Projects: 3 F/OSS C# projects (228 kLOC): Used only for test 3.8 type-correct alternative variables per slot (median 3, σ= 2.6)

slide-26
SLIDE 26

bool string string

  • ut string

var while null if return true null return false

What the model sees…

slide-27
SLIDE 27

UI/UX ML Capabilities Metrics Low resources

slide-28
SLIDE 28

Learning Signals

target prediction 𝑔

𝜄(𝑦)

input data 𝑦

model of problem

  • Given dataset

𝑦1, 𝑧0 , … , 𝑦𝑂, 𝑧𝑂

  • Minimize Loss ℒ 𝜄 =

1 𝑂 σ𝑗 𝑀 𝑔 𝜄 𝑦𝑗 , 𝑧𝑗

slide-29
SLIDE 29
slide-30
SLIDE 30