Retrieval-Based Neural Code Generation

Shirley Anugrah Hayati, Raphael Olivier, Pravalika Avvaru, Pengcheng Yin, Anthony Tomasic +1 more
8/29/2018
cs.CL

Official code: sweetpeach/ReCode (28 stars, Python, last commit 2022-04-04).

Abstract

In models to generate program source code from natural language, representing this code in a tree structure has been a common approach. However, existing methods often fail to generate complex code correctly due to a lack of ability to memorize large and complex structures.

Show full abstract

We introduce ReCode, a method based on subtree retrieval that makes it possible to explicitly reference existing code examples within a neural code generation model. First, we retrieve sentences that are similar to input sentences using a dynamic-programming-based sentence similarity scoring method. Next, we extract n-grams of action sequences that build the associated abstract syntax tree. Finally, we increase the probability of actions that cause the retrieved n-gram action subtree to be in the predicted code. We show that our approach improves the performance on two code generation tasks by up to +2.6 BLEU.

View on arXivView PDF

Code Implementations(1)

sweetpeach/ReCodeOfficial100%
285Python, ShellAug 28, 20184 years ago

Similar Papers

Cite this paper

@article{hayati2018retrievalbased,
  title  = {Retrieval-Based Neural Code Generation},
  author = {Shirley Anugrah Hayati and Raphael Olivier and Pravalika Avvaru and Pengcheng Yin and Anthony Tomasic and Graham Neubig},
  year   = {2018},
  eprint = {1808.10025},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1808.10025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1808.10025.svg)](https://codeofpaper.com/paper/1808.10025)

Discussion