[Paper Review] AceCoder: Utilizing Existing Code to Enhance Code Generation
AceCoder introduces guided code generation and example retrieval to prompts, significantly boosting code generation accuracy across multiple LLMs and languages on MBPP, MBJP, and MBJSP benchmarks.
Large Language Models (LLMs) have shown great success in code generation. LLMs take as the input a prompt and output the code. A key question is how to make prompts (i.e., Prompting Techniques). Existing prompting techniques are designed for natural language generation and have low accuracy in code generation. In this paper, we propose a new prompting technique named AceCoder. Our motivation is that code generation meets two unique challenges (i.e., requirement understanding and code implementation). AceCoder contains two novel mechanisms (i.e., guided code generation and example retrieval) to solve these challenges. (1) Guided code generation asks LLMs first to analyze requirements and output an intermediate preliminary (e.g., test cases). The preliminary is used to clarify requirements and tell LLMs "what to write". (2) Example retrieval selects similar programs as examples in prompts, which provide lots of relevant content (e.g., algorithms, APIs) and teach LLMs "how to write". We apply AceCoder to three LLMs (e.g., Codex) and evaluate it on three public benchmarks using the Pass@k. Results show that AceCoder can significantly improve the performance of LLMs on code generation. (1) In terms of Pass@1, AceCoder outperforms the state-of-the-art baseline by up to 56.4% in MBPP, 70.7% in MBJP, and 88.4% in MBJSP. (2) AceCoder is effective in LLMs with different sizes (i.e., 6B to 13B) and different languages (i.e., Python, Java, and JavaScript). (3) Human evaluation shows human developers prefer programs from AceCoder.
Motivation & Objective
- Motivate the need for specialized prompting in code generation due to two unique challenges: requirement understanding and code implementation.
- Propose AceCoder with two mechanisms—guided code generation and example retrieval—to address these challenges.
- Demonstrate effectiveness across multiple LLMs and programming languages using public benchmarks and human evaluation.
- Provide ablations and design insights to show contributions of each AceCoder module.
Proposed method
- Retrieval of similar <requirement, code> pairs from a corpus using BM25 via Lucene.
- Selector to filter retrieved examples by reducing redundancy through an n-gram overlap and a decay-based scoring loop (Algorithm 1).
- Analyzer to convert retrieved programs into <requirement, preliminary, code> triples by extracting preliminaries (e.g., test cases) from examples.
- Prompt construction that injects triple examples into prompts so LLMs first generate a preliminary (e.g., test cases) and then the final code.
- Three-step code generation where the LLM uses the constructed prompt to output a preliminary followed by the code.
- Evaluation with Pass@k (k=1,3,5) on MBPP (Python), MBJP (Java), MBJSP (JavaScript) across three base LLMs (CodeGeeX-13B, CodeGen-6B, InCoder-6B).
Experimental results
Research questions
- RQ1RQ1: Is AceCoder more accurate than existing prompting techniques for code generation?
- RQ2RQ2: How does AceCoder compare to retrieval-based baselines?
- RQ3RQ3: Do human developers prefer AceCoder-generated code?
- RQ4RQ4: What are the contributions of the three AceCoder modules (Retriever, Selector, Analyzer)?
- RQ5RQ5: Which design choices for the three modules maximize performance?
Key findings
- AceCoder outperforms state-of-the-art baselines on Pass@1 by up to 56.4% (MBPP), 70.7% (MBJP), and 88.4% (MBJSP).
- AceCoder outperforms retrieval-based baselines by up to 13.1% (MBPP), 23.44% (MBJP), and 15.8% (MBJSP) on Pass@1.
- AceCoder yields improvements across LLM sizes from 6B to 13B and across Python, Java, and JavaScript.
- Human evaluation shows developers prefer AceCoder-generated programs for correctness, code smells, and maintainability.
- Ablation shows all three modules (Retriever, Selector, Analyzer) contribute to performance gains; designed variants were compared.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.