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

Jaeseok Yoo, Hojae Han, Youngwon Lee, Jaejin Kim, Seung-won Hwang


Abstract
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.
Anthology ID:
2025.coling-main.534
Volume:
Proceedings of the 31st International Conference on Computational Linguistics
Month:
January
Year:
2025
Address:
Abu Dhabi, UAE
Editors:
Owen Rambow, Leo Wanner, Marianna Apidianaki, Hend Al-Khalifa, Barbara Di Eugenio, Steven Schockaert
Venue:
COLING
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
7982–7997
Language:
URL:
https://aclanthology.org/2025.coling-main.534/
DOI:
Bibkey:
Cite (ACL):
Jaeseok Yoo, Hojae Han, Youngwon Lee, Jaejin Kim, and Seung-won Hwang. 2025. PERC: Plan-As-Query Example Retrieval for Underrepresented Code Generation. In Proceedings of the 31st International Conference on Computational Linguistics, pages 7982–7997, Abu Dhabi, UAE. Association for Computational Linguistics.
Cite (Informal):
PERC: Plan-As-Query Example Retrieval for Underrepresented Code Generation (Yoo et al., COLING 2025)
Copy Citation:
PDF:
https://aclanthology.org/2025.coling-main.534.pdf