Planning with Large Language Models for Code Generation

03/09/2023
by   Shun Zhang, et al.
0

Existing large language model-based code generation pipelines typically use beam search or sampling algorithms during the decoding process. Although the programs they generate achieve high token-matching-based scores, they often fail to compile or generate incorrect outputs. The main reason is that conventional Transformer decoding algorithms may not be the best choice for code generation. In this work, we propose a novel Transformer decoding algorithm, Planning-Guided Transformer Decoding (PG-TD), that uses a planning algorithm to do lookahead search and guide the Transformer to generate better programs. Specifically, instead of simply optimizing the likelihood of the generated sequences, the Transformer makes use of a planner to generate candidate programs and test them on public test cases. The Transformer can therefore make more informed decisions and generate tokens that will eventually lead to higher-quality programs. We also design a mechanism that shares information between the Transformer and the planner to make our algorithm computationally efficient. We empirically evaluate our framework with several large language models as backbones on public coding challenge benchmarks, showing that 1) it can generate programs that consistently achieve higher performance compared with competing baseline methods; 2) it enables controllable code generation, such as concise codes and highly-commented codes by optimizing modified objective.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
02/02/2023

Accelerating Large Language Model Decoding with Speculative Sampling

We present speculative sampling, an algorithm for accelerating transform...
research
03/31/2023

Towards Enhancing In-Context Learning for Code Generation

In-context learning (ICL) with pre-trained language models (PTLMs) has s...
research
02/15/2023

Learning Performance-Improving Code Edits

The waning of Moore's Law has shifted the focus of the tech industry tow...
research
09/05/2021

SideControl: Controlled Open-domain Dialogue Generation via Additive Side Networks

Transformer-based pre-trained language models boost the performance of o...
research
06/18/2021

Learning to Generate Code Sketches

Traditional generative models are limited to predicting sequences of ter...
research
05/21/2023

SLaDe: A Portable Small Language Model Decompiler for Optimized Assembler

Decompilation is a well-studied area with numerous high-quality tools av...
research
07/05/2021

DeepRapper: Neural Rap Generation with Rhyme and Rhythm Modeling

Rap generation, which aims to produce lyrics and corresponding singing b...

Please sign up or login with your details

Forgot password? Click here to reset