Evaluating In-Context Learning of Libraries for Code Generation

Arkil Patel, Siva Reddy, Dzmitry Bahdanau, Pradeep Dasigi
11/16/2023
cs.CL

No official code found. Best implementation: McGill-NLP/incontext-code-generation (10 stars, last commit 2024-10-23).

Abstract

Contemporary Large Language Models (LLMs) exhibit a high degree of code generation and comprehension capability. A particularly promising area is their ability to interpret code modules from unfamiliar libraries for solving user-instructed tasks. Recent work has shown that large proprietary LLMs can learn novel library usage in-context from demonstrations. These results raise several open questions: whether demonstrations of library usage is required, whether smaller (and more open) models also possess such capabilities, etc. In this work, we take a broader approach by systematically evaluating a diverse array of LLMs across three scenarios reflecting varying levels of domain specialization to understand their abilities and limitations in generating code based on libraries defined in-context. Our results show that even smaller open-source LLMs like Llama-2 and StarCoder demonstrate an adept understanding of novel code libraries based on specification presented in-context. Our findings further reveal that LLMs exhibit a surprisingly high proficiency in learning novel library modules even when provided with just natural language descriptions or raw code implementations of the functions, which are often cheaper to obtain than demonstrations. Overall, our results pave the way for harnessing LLMs in more adaptable and dynamic coding environments.

View on arXivView PDF

Code Implementations(1)

NAACL 2024: Evaluating In-Context Learning of Libraries for Code Generation

102PythonMar 31, 20241 years ago

Similar Papers

Cite this paper

@article{patel2023evaluating,
  title  = {Evaluating In-Context Learning of Libraries for Code Generation},
  author = {Arkil Patel and Siva Reddy and Dzmitry Bahdanau and Pradeep Dasigi},
  year   = {2023},
  eprint = {2311.09635},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2311.09635v2}
}

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

Discussion