[Paper Review] Few-shot training LLMs for project-specific code-summarization
This paper proposes few-shot fine-tuning of the Codex language model using just 10 project-specific code-comment pairs to significantly improve code summarization performance. By leveraging few-shot prompting with project-local examples, the method achieves statistically significant gains over both zero-shot, one-shot, and traditional fine-tuned models, outperforming models trained on thousands of samples with minimal data.
Very large language models (LLMs), such as GPT-3 and Codex have achieved state-of-the-art performance on several natural-language tasks, and show great promise also for code. A particularly exciting aspect of LLMs is their knack for few-shot and zero-shot learning: they can learn to perform a task with very few examples. Few-shotting has particular synergies in software engineering, where there are a lot of phenomena (identifier names, APIs, terminology, coding patterns) that are known to be highly project-specific. However, project-specific data can be quite limited, especially early in the history of a project; thus the few-shot learning capacity of LLMs might be very relevant. In this paper, we investigate the use few-shot training with the very large GPT (Generative Pre-trained Transformer) Codex model, and find evidence suggesting that one can significantly surpass state-of-the-art models for code-summarization, leveraging project-specific training.
Motivation & Objective
- To investigate whether few-shot prompting with project-specific examples can improve code summarization beyond zero-shot or one-shot settings.
- To evaluate if few-shot training with just 10 examples can surpass traditional fine-tuning methods that require thousands of project-specific samples.
- To compare same-project few-shot training against cross-project few-shot prompting in terms of performance and generalization.
- To assess the feasibility and effectiveness of using minimal developer-annotated code-comment pairs for high-accuracy code summarization in real-world software engineering contexts.
Proposed method
- The study uses the Codex language model (a fine-tuned version of GPT-3) for code summarization, leveraging its few-shot in-context learning capability.
- Few-shot prompts are constructed by including 10 project-specific code-comment pairs as demonstrations before the input code to be summarized.
- The model generates docstrings by autoregressively predicting tokens conditioned on the prompt, without any parameter updates.
- Performance is evaluated using BLEU-4 and ROUGE-L metrics on a project-specific dataset of 8 open-source projects across 6 programming languages.
- Comparative experiments are conducted between zero-shot, one-shot, cross-project few-shot, and same-project few-shot settings to isolate the impact of project-specific data.
- Statistical significance of performance improvements is assessed using paired t-tests across multiple projects and languages.
Experimental results
Research questions
- RQ1Can few-shot prompting with just 10 project-specific examples significantly improve code summarization performance compared to zero-shot or one-shot settings?
- RQ2Does same-project few-shot training outperform cross-project few-shot training in code summarization tasks?
- RQ3Can a few-shot approach using minimal data (10 examples) surpass traditional fine-tuning methods that require thousands of labeled examples?
- RQ4Is the performance improvement from few-shot prompting statistically significant across diverse programming languages and projects?
Key findings
- Same-project few-shot training with 10 examples achieved a 2% to 46% improvement in code summarization performance over cross-project few-shot training across all 8 evaluated projects.
- The same-project few-shot approach showed statistically significant improvements in 2 out of 8 projects, with overall performance gains being statistically significant across all projects.
- Cross-project few-shot training improved performance by 1% to 15% across all 6 programming languages, with statistically significant gains in 4 languages.
- Zero-shot and one-shot prompting with Codex achieved only 2.96 and 6.22 BLEU-4 on average, respectively, indicating poor performance and confirming that few-shot is essential for code summarization.
- The model’s performance improved smoothly with increasing numbers of few-shot examples, suggesting generalization rather than memorization of test data.
- The study demonstrates that minimal project-specific data (10 examples) can yield superior results compared to models fine-tuned on thousands of samples, highlighting the sample efficiency of few-shot prompting.
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.