Large Language Model-Aware In-Context Learning for Code Generation

Jia Li, Ge Li, Chongyang Tao, Jia Li, Huangzhao Zhang +2 more
10/15/2023
cs.SEcs.CL

No confident code implementation found for this paper. 5 possible matches can be shown below.

Abstract

Large language models (LLMs) have shown impressive in-context learning (ICL) ability in code generation. LLMs take a prompt consisting of requirement-code examples and a new requirement as input, and output new programs. Existing studies have found that ICL is highly dominated by the examples and thus arises research on example selection. However, existing approaches randomly select examples or only consider the textual similarity of requirements to retrieve, leading to sub-optimal performance. In this paper, we propose a novel learning-based selection approach named LAIL (LLM-Aware In-context Learning) for code generation. Given a candidate example, we exploit LLMs themselves to estimate it by considering the generation probabilities of ground-truth programs given a requirement and the example. We then label candidate examples as positive or negative through the probability feedback. Based on the labeled data, we import a contrastive learning objective to train an effective retriever that acquires the preference of LLMs in code generation. We apply LAIL to three LLMs and evaluate it on three representative datasets (e.g., MBJP, MBPP, and MBCPP). LATA outperforms the state-of-the-art baselines by 11.58%, 6.89%, and 5.07% on CodeGen, and 4.38%, 2.85%, and 2.74% on GPT-3.5 in terms of Pass@1, respectively.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 5 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{li2023large,
  title  = {Large Language Model-Aware In-Context Learning for Code Generation},
  author = {Jia Li and Ge Li and Chongyang Tao and Jia Li and Huangzhao Zhang and Fang Liu and Zhi Jin},
  year   = {2023},
  eprint = {2310.09748},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2310.09748v1}
}

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/2310.09748.svg)](https://codeofpaper.com/paper/2310.09748)

Discussion