SlideShare a Scribd company logo
SPoC: Search-based
Pseudocode to Code
• Sumith Kulal
• Panupong Pasupat
• Kartik Chandra
• Mina Lee
• Oded Padon
• Alex Aiken
• Percy Liang
Presented By
Minhazul Arefin
Abstract
 mapping pseudocode to long programs that are functionally correct
 treat the translation of each pseudocode line as a discrete portion of
the program
 If program fails to compile, an error localization method tries to
identify the portion of the program responsible for the failure
3
Introduction
 map natural language descriptions
 Perform non-trivial computations
 input-output pairs usually give little information about the
intermediate states of the program
4
Data collection
 Programs and test cases: NAPS dataset
 Decomposition: decompose each program into code lines
 Pseudocode: recruited 59 workers on Amazon Mechanical Turk to
write pseudocode
 Statistics: dataset contains 18,356 programs
 Training and test sets: they created two test sets
5
Problem Statement
• The system is given (a) a sequence x of L pseudocode lines 𝑥1; 𝑥2; : : : ; 𝑥𝐿, where
 𝑥𝑖 is a string with indentation level `I
 K public test cases in the form of
input-output string pairs (𝑇𝑖𝑛1 ; 𝑇𝑜𝑢𝑡1);
: : : ; (𝑇𝑖𝑛𝑘 ; 𝑇𝑜𝑢𝑡𝑘).
▸ The task is to synthesize a program y consisting of L code lines 𝑦1; 𝑦1; : : : ; 𝑦𝐿
▸ The program is accepted if it successfully compiles and passes all public test cases
6
Base approach (Translation)
• They used a standard seq2seq translation model with an LSTM
encoder and decoder
• An attention-based copying mechanism
• A coverage vector
7
Base approach (Best-first search)
1. Create a priority Queue pqueue.
2. insert ‘start’ in pqueue : pqueue.insert(start)
3. delete all elements of pqueue one by one.
1) if, the element is goal . Exit.
2) else, traverse neighbor’s and mark the node examined.
4. End.
8
Base approach (Best-first search)
Advantages:
▸ Best first search can switch between BFS and DFS by gaining the
advantages of both the algorithms.
▸ This algorithm is more efficient than BFS and DFS algorithms.
Disadvantages:
▸ It can behave as an unguided depth-first search in the worst case
scenario.
▸ It can get stuck in a loop as DFS.
▸ This algorithm is not optimal.
9
Experiments (Translation accuracy)
 Used BELU score in best first search
 only 18.2% of programs in TESTP and 32.0% of programs in TESTW is
correct in every line.
 the top candidate of each line have an even lower success rates of
17.8% on TESTP and 30.7% on TESTW
10
Experiments (Translation accuracy)
11
Figure: (a) While the translation accuracy is high at the line level, we need to consider the
result at the program level. For each program, we count the number of lines i where
(b) the top candidate ci1 is incorrect
(c) none of the candidates 𝑐𝑖𝑗 ꞓ 𝑐𝑖 is correct.
Experiments (Oracle success rate)
▸ count the number of lines i where the candidate list 𝑐𝑖 does not have
any correct candidate
▸ 44.8% of programs in TESTP and 28.6% of programs in TESTW have
least one difficult line where the translation model does not produce
a correct prediction
▸ It achieve a maximum success rate of 55.2% on TESTP and 71.4% on
TESTW
12
Experiments (Synthesis results)
 Error line, 𝑖∗ = 𝑖𝑒𝑟𝑟 - ∆i
 Where,
 𝑖∗
= predicted line
 𝑖𝑒𝑟𝑟 = error in line
 ∆i = corresponding line
13
Experiments (Synthesis results)
14
Figure: Success rates at budgets B of best-first search with different error localization methods
Experiments (Synthesis results)
15
Table: Effects of using error localization methods on all test examples
Experiments (Error analysis)
▸ s is half = “s == "half“
▸ interpreted as “s / 2 == 0”
or “s % 2 == 0”
▸ This causes the search to ultimately fail whereas best-first search finds a
correct program in 80 search iterations
16
Related work (Program synthesis)
▸ formulate synthesis as a constraint satisfaction problem
▸ requires that the synthesis problem can be translated to a theory
with effective constraint solvers
▸ brute force enumeration of programs works surprisingly well
▸ when the search space is too large for enumeration, randomized
search guided by a cost function can be effective
17
Related work (Semantic parsing)
 It is a task of converting a NLP text into a logical form (a machine-
understandable format)
 One of its traditional tasks is to parse a given into an executable
database query
 Instead of a single query, some work aims to parse a sequence of
queries that can be sequentially executed (max 5 sentences)
18
Related work (Error localization)
 uses neural models to localize errors focused on localizing and
correcting syntax errors
 semantic errors such as variable misuse and variable replace
 Their work identifies error locations by interpreting compiler error
messages
19

More Related Content

PPTX
Topic 1.4: Randomized Algorithms
PPTX
Lecture 6-cs648 Randomized Algorithms
PPT
Randomized Algorithms
PDF
Algorithm basics
PPTX
Algorithm Design & Implementation
PPTX
Lecture 1-cs648
PPTX
PPTX
Equivalence partinioning and boundary value analysis
Topic 1.4: Randomized Algorithms
Lecture 6-cs648 Randomized Algorithms
Randomized Algorithms
Algorithm basics
Algorithm Design & Implementation
Lecture 1-cs648
Equivalence partinioning and boundary value analysis

What's hot (20)

PPTX
Path testing
PDF
Compiler Construction for DLX Processor
PPSX
Problem solving and design
PPTX
FIT-Unit3 chapter 1 -computer program
PPT
Csphtp1 04
PPTX
Parallel processing -open mp
PPTX
Sta unit 4(abimanyu)
PPTX
Pseudocode-Flowchart
PPS
Boundary and equivalnce systematic test design
PDF
The Road Not Taken: Estimating Path Execution Frequency Statically
PPTX
Introduction to flowchart
PPTX
Model Checking in Formal Methods
PPTX
Boundary value analysis and equivalence partitioning
PDF
Algorithm and c language
PPSX
White Box testing by Pankaj Thakur, NITTTR Chandigarh
PPTX
EquivalencePartition
PDF
Test design techniques
PDF
Ge6161 lab manual
PPT
Software Testing Techniques
PPTX
Calculation of Cyclomatic complexity
Path testing
Compiler Construction for DLX Processor
Problem solving and design
FIT-Unit3 chapter 1 -computer program
Csphtp1 04
Parallel processing -open mp
Sta unit 4(abimanyu)
Pseudocode-Flowchart
Boundary and equivalnce systematic test design
The Road Not Taken: Estimating Path Execution Frequency Statically
Introduction to flowchart
Model Checking in Formal Methods
Boundary value analysis and equivalence partitioning
Algorithm and c language
White Box testing by Pankaj Thakur, NITTTR Chandigarh
EquivalencePartition
Test design techniques
Ge6161 lab manual
Software Testing Techniques
Calculation of Cyclomatic complexity
Ad

Similar to SPoC: search-based pseudocode to code (20)

PPTX
Semantic scaffolds for pseudocode to-code generation (2020)
PPTX
Semantic-Aware Code Model: Elevating the Future of Software Development
PDF
Program Synthesis, DreamCoder, and ARC
PPTX
Keynote at IWLS 2017
PPTX
고급컴파일러구성론_개레_230303.pptx
PDF
7. Trevor Cohn (usfd) Statistical Machine Translation
PDF
Python Lecture slides topic Algorithm design
PDF
Triantafyllia Voulibasi
PDF
Fixing the program my computer learned: End-user debugging of machine-learned...
PDF
Machine Learning on Code - SF meetup
PDF
PDF
NSC #2 - D2 06 - Richard Johnson - SAGEly Advice
PDF
IRJET - Pseudocode to Python Translation using Machine Learning
PDF
CommitBERT.pdf
PPT
Learning for semantic parsing using statistical syntactic parsing techniques
PDF
Natural Language Generation in the Wild
PPTX
AI_03_Solving Problems by Searching.pptx
PDF
clegoues-pwlconf-sept16-asPDF.pdf
DOCX
Adsa u2 ver 1.0.
PPT
01-intro.ppt 8085 microprocessors PPT presentation
Semantic scaffolds for pseudocode to-code generation (2020)
Semantic-Aware Code Model: Elevating the Future of Software Development
Program Synthesis, DreamCoder, and ARC
Keynote at IWLS 2017
고급컴파일러구성론_개레_230303.pptx
7. Trevor Cohn (usfd) Statistical Machine Translation
Python Lecture slides topic Algorithm design
Triantafyllia Voulibasi
Fixing the program my computer learned: End-user debugging of machine-learned...
Machine Learning on Code - SF meetup
NSC #2 - D2 06 - Richard Johnson - SAGEly Advice
IRJET - Pseudocode to Python Translation using Machine Learning
CommitBERT.pdf
Learning for semantic parsing using statistical syntactic parsing techniques
Natural Language Generation in the Wild
AI_03_Solving Problems by Searching.pptx
clegoues-pwlconf-sept16-asPDF.pdf
Adsa u2 ver 1.0.
01-intro.ppt 8085 microprocessors PPT presentation
Ad

More from Minhazul Arefin (8)

PPTX
LaMMA-P: Generalizable Multi-Agent Long-Horizon Task Allocation and Planning ...
PPTX
pic2code: Generating HTML Code from Handwritten Picture.pptx
PPTX
Controlling Home Appliances adopting Chatbot using Machine Learning Approach
PPTX
Object Detection on Dental X-ray Images using R-CNN
PPTX
Natural Language Query to SQL conversion using Machine Learning Approach
PPTX
Efficient estimation of word representations in vector space (2013)
PPTX
Recurrent neural networks (rnn) and long short term memory networks (lstm)
PPTX
The rise of “Big Data” on cloud computing
LaMMA-P: Generalizable Multi-Agent Long-Horizon Task Allocation and Planning ...
pic2code: Generating HTML Code from Handwritten Picture.pptx
Controlling Home Appliances adopting Chatbot using Machine Learning Approach
Object Detection on Dental X-ray Images using R-CNN
Natural Language Query to SQL conversion using Machine Learning Approach
Efficient estimation of word representations in vector space (2013)
Recurrent neural networks (rnn) and long short term memory networks (lstm)
The rise of “Big Data” on cloud computing

Recently uploaded (20)

PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Geodesy 1.pptx...............................................
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
PPT on Performance Review to get promotions
PPTX
Sustainable Sites - Green Building Construction
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Digital Logic Computer Design lecture notes
PPTX
web development for engineering and engineering
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Well-logging-methods_new................
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Geodesy 1.pptx...............................................
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPT on Performance Review to get promotions
Sustainable Sites - Green Building Construction
CYBER-CRIMES AND SECURITY A guide to understanding
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Operating System & Kernel Study Guide-1 - converted.pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Digital Logic Computer Design lecture notes
web development for engineering and engineering
bas. eng. economics group 4 presentation 1.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Embodied AI: Ushering in the Next Era of Intelligent Systems
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Well-logging-methods_new................

SPoC: search-based pseudocode to code

  • 1. SPoC: Search-based Pseudocode to Code • Sumith Kulal • Panupong Pasupat • Kartik Chandra • Mina Lee • Oded Padon • Alex Aiken • Percy Liang
  • 3. Abstract  mapping pseudocode to long programs that are functionally correct  treat the translation of each pseudocode line as a discrete portion of the program  If program fails to compile, an error localization method tries to identify the portion of the program responsible for the failure 3
  • 4. Introduction  map natural language descriptions  Perform non-trivial computations  input-output pairs usually give little information about the intermediate states of the program 4
  • 5. Data collection  Programs and test cases: NAPS dataset  Decomposition: decompose each program into code lines  Pseudocode: recruited 59 workers on Amazon Mechanical Turk to write pseudocode  Statistics: dataset contains 18,356 programs  Training and test sets: they created two test sets 5
  • 6. Problem Statement • The system is given (a) a sequence x of L pseudocode lines 𝑥1; 𝑥2; : : : ; 𝑥𝐿, where  𝑥𝑖 is a string with indentation level `I  K public test cases in the form of input-output string pairs (𝑇𝑖𝑛1 ; 𝑇𝑜𝑢𝑡1); : : : ; (𝑇𝑖𝑛𝑘 ; 𝑇𝑜𝑢𝑡𝑘). ▸ The task is to synthesize a program y consisting of L code lines 𝑦1; 𝑦1; : : : ; 𝑦𝐿 ▸ The program is accepted if it successfully compiles and passes all public test cases 6
  • 7. Base approach (Translation) • They used a standard seq2seq translation model with an LSTM encoder and decoder • An attention-based copying mechanism • A coverage vector 7
  • 8. Base approach (Best-first search) 1. Create a priority Queue pqueue. 2. insert ‘start’ in pqueue : pqueue.insert(start) 3. delete all elements of pqueue one by one. 1) if, the element is goal . Exit. 2) else, traverse neighbor’s and mark the node examined. 4. End. 8
  • 9. Base approach (Best-first search) Advantages: ▸ Best first search can switch between BFS and DFS by gaining the advantages of both the algorithms. ▸ This algorithm is more efficient than BFS and DFS algorithms. Disadvantages: ▸ It can behave as an unguided depth-first search in the worst case scenario. ▸ It can get stuck in a loop as DFS. ▸ This algorithm is not optimal. 9
  • 10. Experiments (Translation accuracy)  Used BELU score in best first search  only 18.2% of programs in TESTP and 32.0% of programs in TESTW is correct in every line.  the top candidate of each line have an even lower success rates of 17.8% on TESTP and 30.7% on TESTW 10
  • 11. Experiments (Translation accuracy) 11 Figure: (a) While the translation accuracy is high at the line level, we need to consider the result at the program level. For each program, we count the number of lines i where (b) the top candidate ci1 is incorrect (c) none of the candidates 𝑐𝑖𝑗 ꞓ 𝑐𝑖 is correct.
  • 12. Experiments (Oracle success rate) ▸ count the number of lines i where the candidate list 𝑐𝑖 does not have any correct candidate ▸ 44.8% of programs in TESTP and 28.6% of programs in TESTW have least one difficult line where the translation model does not produce a correct prediction ▸ It achieve a maximum success rate of 55.2% on TESTP and 71.4% on TESTW 12
  • 13. Experiments (Synthesis results)  Error line, 𝑖∗ = 𝑖𝑒𝑟𝑟 - ∆i  Where,  𝑖∗ = predicted line  𝑖𝑒𝑟𝑟 = error in line  ∆i = corresponding line 13
  • 14. Experiments (Synthesis results) 14 Figure: Success rates at budgets B of best-first search with different error localization methods
  • 15. Experiments (Synthesis results) 15 Table: Effects of using error localization methods on all test examples
  • 16. Experiments (Error analysis) ▸ s is half = “s == "half“ ▸ interpreted as “s / 2 == 0” or “s % 2 == 0” ▸ This causes the search to ultimately fail whereas best-first search finds a correct program in 80 search iterations 16
  • 17. Related work (Program synthesis) ▸ formulate synthesis as a constraint satisfaction problem ▸ requires that the synthesis problem can be translated to a theory with effective constraint solvers ▸ brute force enumeration of programs works surprisingly well ▸ when the search space is too large for enumeration, randomized search guided by a cost function can be effective 17
  • 18. Related work (Semantic parsing)  It is a task of converting a NLP text into a logical form (a machine- understandable format)  One of its traditional tasks is to parse a given into an executable database query  Instead of a single query, some work aims to parse a sequence of queries that can be sequentially executed (max 5 sentences) 18
  • 19. Related work (Error localization)  uses neural models to localize errors focused on localizing and correcting syntax errors  semantic errors such as variable misuse and variable replace  Their work identifies error locations by interpreting compiler error messages 19