PERC: Plan-As-Query Example Retrieval for Underrepresented Code Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Yoo, Jaeseok, Han, Hojae, Lee, Youngwon, Kim, Jaejin, Hwang, Seung-won
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866909435650113536
author Yoo, Jaeseok
Han, Hojae
Lee, Youngwon
Kim, Jaejin
Hwang, Seung-won
author_facet Yoo, Jaeseok
Han, Hojae
Lee, Youngwon
Kim, Jaejin
Hwang, Seung-won
contents Code generation with large language models has shown significant promise, especially when employing retrieval-augmented generation (RAG) with few-shot examples. However, selecting effective examples that enhance generation quality remains a challenging task, particularly when the target programming language (PL) is underrepresented. In this study, we present two key findings: (1) retrieving examples whose presented algorithmic plans can be referenced for generating the desired behavior significantly improves generation accuracy, and (2) converting code into pseudocode effectively captures such algorithmic plans, enhancing retrieval quality even when the source and the target PLs are different. Based on these findings, we propose Plan-as-query Example Retrieval for few-shot prompting in Code generation (PERC), a novel framework that utilizes algorithmic plans to identify and retrieve effective examples. We validate the effectiveness of PERC through extensive experiments on the CodeContests, HumanEval and MultiPL-E benchmarks: PERC consistently outperforms the state-of-the-art RAG methods in code generation, both when the source and target programming languages match or differ, highlighting its adaptability and robustness in diverse coding environments.
format Preprint
id arxiv_https___arxiv_org_abs_2412_12447
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle PERC: Plan-As-Query Example Retrieval for Underrepresented Code Generation
Yoo, Jaeseok
Han, Hojae
Lee, Youngwon
Kim, Jaejin
Hwang, Seung-won
Software Engineering
Artificial Intelligence
Computation and Language
Code generation with large language models has shown significant promise, especially when employing retrieval-augmented generation (RAG) with few-shot examples. However, selecting effective examples that enhance generation quality remains a challenging task, particularly when the target programming language (PL) is underrepresented. In this study, we present two key findings: (1) retrieving examples whose presented algorithmic plans can be referenced for generating the desired behavior significantly improves generation accuracy, and (2) converting code into pseudocode effectively captures such algorithmic plans, enhancing retrieval quality even when the source and the target PLs are different. Based on these findings, we propose Plan-as-query Example Retrieval for few-shot prompting in Code generation (PERC), a novel framework that utilizes algorithmic plans to identify and retrieve effective examples. We validate the effectiveness of PERC through extensive experiments on the CodeContests, HumanEval and MultiPL-E benchmarks: PERC consistently outperforms the state-of-the-art RAG methods in code generation, both when the source and target programming languages match or differ, highlighting its adaptability and robustness in diverse coding environments.
title PERC: Plan-As-Query Example Retrieval for Underrepresented Code Generation
topic Software Engineering
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2412.12447