conditional program generation for bimodal program
play

Conditional Program Generation for Bimodal Program Synthesis Swarat - PowerPoint PPT Presentation

Conditional Program Generation for Bimodal Program Synthesis Swarat Chaudhuri Rice University www.cs.rice.edu/~swarat (Joint work with Chris Jermaine, Vijay Murali, and Letao Qi) Program synthesis [Simon 1963, Summers 1977, Manna-Waldinger


  1. Conditional Program Generation for Bimodal Program Synthesis Swarat Chaudhuri Rice University www.cs.rice.edu/~swarat (Joint work with Chris Jermaine, Vijay Murali, and Letao Qi)

  2. Program synthesis [Simon 1963, Summers 1977, Manna-Waldinger 1977, Pnueli-Rosner 1989] Specification Specification: Logical constraint that must be satisfied exactly Synthesizer Algorithm: Search for a program that satisfies the specification. Program + Correctness Certificate

  3. “Bimodal” program synthesis An Prior distribution idealized program Learned Ambiguous “evidence” + from a real-world Logical requirements code corpus Synthesizer Candidate implementations Posterior distribution over programs Neural Sketch Learning for Conditional Program Generation. Murali, Qi, Chaudhuri, and Jermaine. Arxiv 2017. 3

  4. “Bimodal” program synthesis An idealized Prior distribution program Learned Ambiguous “evidence” + from a real-world Logical requirements code corpus Synthesizer Candidate implementations Posterior distribution over programs • API calls or types that the program uses • “Soft” I/O examples or constraints • Natural language description of what the program does • ... 4

  5. The Bayou synthesizer: A demo http://bit.ly/2zgP5fj 5

  6. Conditional program generation Assume random variables 𝑌 and 𝑄𝑠𝑝𝑕 , over labels and programs respectively, following a joint distribution 𝑅(𝑌, 𝑄𝑠𝑝𝑕) . Offline: 𝑌 * , 𝑄𝑠𝑝𝑕 * of samples from 𝑅(𝑌, 𝑄𝑠𝑝𝑕) . From • You are given a set this, learn a function 𝑕 that maps evidence to programs. • Learning goal: maximize 𝐹 ,,-./0 ∼2 𝐽 , where ⇢ 1 if g ( X ) ≡ Prog I = 0 otherwise. Online: Given 𝑌 , produce 𝑕(𝑌) . 6

  7. � In what we actually do The map g is probabilistic. Learning is maximum conditional likelihood estimation: ∑ log 𝑄 𝑄𝑠𝑝𝑕 * 𝑌 * , 𝜄) • Given {(𝑌 * , 𝑄𝑠𝑝𝑕 * )} , solve arg max . * ; 7

  8. Programs Language capturing the essence of API usage in Java. ::= skip | Prog 1 ; Prog 2 | call Call | Prog let x = Call | if Exp then Prog 1 else Prog 2 | while Exp do Prog 1 | try Prog 1 Catch ::= Sexp | Call | let x = Call : Exp 1 Exp Sexp ::= c | x Call ::= Sexp 0 .a ( Sexp 1 , . . . , Sexp k ) API call Catch ::= catch ( x 1 ) Prog 1 . . . catch ( x k ) Prog k API method name 8

  9. Labels Set of API calls • readline, write,… Set of API datatypes • BufferedReader, FileReader,… Set of keywords that may appear while describing program actions in English • read, file, write,… • Obtained from API calls and datatypes through a camel case split 9

  10. Challenges Directly learning over source code simply doesn’t work • Source code is full of low-level, program-specific names and operations. • Programs need to satisfy structural and semantic constraints such as type safety. Learning to satisfy these constraints is hard. 10

  11. Language abstractions to the rescue! Learn not over programs, but typed, syntactic models of programs. 11

  12. � Sketches The sketch of a program is obtained by applying an abstraction function 𝛽 . From sketch 𝑍 to program 𝑄𝑠𝑝𝑕 : a fixed concretization distribution 𝑄(𝑄𝑠𝑝𝑕 | 𝑍). Learning goal changes to ∑ log 𝑄 𝑍 • Given {(𝑌 * , 𝑍 * )} , solve arg max * 𝑌 * , 𝜄) . * ; 12

  13. Sketches ::= Call | skip | while Cond do Y 1 | Y 1 ; Y 2 | Y try Y 1 Catch | if Cond then Y 1 else Y 2 ::= catch ( τ 1 ) Y 1 . . . catch ( τ k ) Y k Catch ::= { Call 1 , . . . , Call k } Cond ::= a ( τ 1 , . . . , τ k ) Call Abstract API call 13

  14. Program synthesis Learned from 𝒀 𝒋 , 𝒁 𝒋 pairs End-to-end Evidence 𝑌 𝑄 𝑍 𝑌) differentiable neural architecture Logical requirement 𝜒 Sample sketches Type-directed, Combinatorial Implementations compositional “concretization” satisfying 𝜒 synthesizer Sketch → Executable code 14

  15. Program synthesis Learned from 𝒀 𝒋 , 𝒁 𝒋 pairs End-to-end Evidence 𝑌 Not all sketches may 𝑄 𝑍 𝑌) differentiable be realizable as neural executable programs architecture Logical requirement 𝜒 Sample ✘ sketches Type-directed, Combinatorial Implementations compositional “concretization” satisfying 𝜒 synthesizer Sketch → Executable code 15

  16. Learning using a probabilistic 𝑌 : Evidence 𝑍 : Sketches encoder-decoder 𝑎 : Latent “intent” 𝑎 𝑔(𝑌) Decoder Encoder 𝑌 Y f g 𝑎 Representation of hidden intent 𝑌 𝑍 Prior for regularization 16

  17. Learning using a probabilistic 𝑌 : Evidence 𝑍 : Sketches encoder-decoder 𝑎 : Latent “intent” 𝑎 𝑔(𝑌) Decoder Encoder 𝑌 Y g f During learning, use 𝑄 𝑎 = 𝑂𝑝𝑠𝑛𝑏𝑚 0, 𝐽 Jensen’s inequality 𝑄 𝑔(𝑌) 𝑎) = 𝑂𝑝𝑠𝑛𝑏𝑚 𝑎, 𝜏 S 𝐽 to get smooth loss function 17

  18. Learning using a probabilistic 𝑌 : Evidence 𝑍 : Sketches encoder-decoder 𝑎 : Latent “intent” 𝑎 𝑔(𝑌) Decoder Encoder 𝑌 Y g f 𝑄 𝑎 = 𝑂𝑝𝑠𝑛𝑏𝑚 0, 𝐽 During inference, get P(Z | X) using 𝑄 𝑔(𝑌) 𝑎) = 𝑂𝑝𝑠𝑛𝑏𝑚 𝑎, 𝜏 S 𝐽 normal-normal conjugacy 18

  19. Neural decoder Distribution on rules that can be fired at a point, given history so far. History encoded as a real vector. … 0.7 0.3 19

  20. Concretization … Ruled out by type system ✗ 20

  21. Results • Trained method on 100 million lines of Java/Android code. ~2500 API methods, ~1500 types. • Synthesis of method bodies from scratch, given 2-3 API calls and types. • Sketch learning critical to accuracy. • Good performance compared to GSNNs (state of the art conditional generative model). • Good results on label-sketch pairs not encountered in training set. 21

  22. Thank you! Questions? swarat@rice.edu http://www.cs.rice.edu/~swarat (Research funded by the DARPA MUSE award #FA8750-14-2-0270) 22

Recommend


More recommend