Skip to main content
QUICK REVIEW

[Paper Review] Learning code summarization from a small and local dataset

Toufique Ahmed, Prémkumar Dévanbu|arXiv (Cornell University)|Jun 2, 2022
Software Engineering ResearchComputer Science6 citations
TL;DR

This paper proposes same-project fine-tuning of foundation models for code summarization, demonstrating that training and testing on the same project significantly improves performance over cross-project methods. Using a hybrid approach—first pre-training on multilingual data and then fine-tuning on project-specific code—achieves state-of-the-art results with high sample efficiency, especially in low-data settings.

ABSTRACT

Foundation models (e.g., CodeBERT, GraphCodeBERT, CodeT5) work well for many software engineering tasks. These models are pre-trained (using self-supervision) with billions of code tokens, and then fine-tuned with hundreds of thousands of labeled examples, typically drawn from many projects. However, software phenomena can be very project-specific. Vocabulary, and other phenomena vary substantially with each project. Thus, training on project-specific data, and testing on the same project, is a promising idea. This hypothesis has to be evaluated carefully, e.g., in a time-series setting, to prevent training-test leakage. We compare several models and training approaches, including same-project training, cross-project training, training a model especially designed to be sample efficient (and thus prima facie well-suited for learning in a limited-sample same-project setting) and a maximalist hybrid approach, fine-tuning first on many projects in many languages and then training on the same-project. We find that the maximalist hybrid setting provides consistent, substantial gains over the state-of-the-art, on many different projects in both Java and Python.

Motivation & Objective

  • Investigate whether project-specific fine-tuning improves code summarization performance compared to cross-project training.
  • Address the challenge of limited labeled data in software engineering NLP by exploring sample-efficient fine-tuning strategies.
  • Evaluate the effectiveness of same-project training in a realistic time-series setting to prevent data leakage.
  • Develop and test a hybrid model (GCBhybrid) optimized for sample efficiency in project-specific fine-tuning.
  • Assess whether even highly pre-trained models like PolyGlot can be further improved via same-project fine-tuning.

Proposed method

  • Use a time-series evaluation protocol: train only on past code samples from a project and test on future samples to simulate real-world deployment.
  • Apply a two-stage training regime: pre-train foundation models (e.g., GraphCodeBERT, CodeT5) on large-scale, multilingual code data, then fine-tune on project-specific data.
  • Introduce GCBhybrid, a modified GraphCodeBERT model with a specialized decoder to enhance sample efficiency during same-project fine-tuning.
  • Compare multiple training strategies: same-project, cross-project, and hybrid fine-tuning on 18 Java and 16 Python projects.
  • Use BLEU-4 and other standard metrics to evaluate summarization quality, ensuring no data leakage via careful dataset partitioning.
  • Leverage the CodeXGLUE benchmark with de-duplicated, pre-split data to ensure external validity and prevent contamination.

Experimental results

Research questions

  • RQ1Can same-project fine-tuning improve code summarization performance compared to cross-project training?
  • RQ2Does a model fine-tuned on a single project outperform models trained on diverse, multi-project datasets in project-specific settings?
  • RQ3Can a sample-efficient model like GCBhybrid achieve superior performance with limited labeled examples from a single project?
  • RQ4Does further fine-tuning of an already state-of-the-art model (e.g., PolyGlot) on project-specific data yield measurable gains?
  • RQ5What is the computational and data efficiency trade-off of same-project training versus cross-project training?

Key findings

  • The hybrid training approach—pre-training on multilingual data followed by same-project fine-tuning—achieves consistent, substantial gains over state-of-the-art models like CodeT5 across multiple Java and Python projects.
  • Same-project fine-tuning significantly improves performance, even when applied to a highly pre-trained model like PolyGlot, indicating that project-specificity enhances summarization quality.
  • The GCBhybrid model demonstrates high sample efficiency, enabling strong performance with limited training data, making it suitable for low-resource software projects.
  • The best-performing model (PolyGlot with same-project fine-tuning) outperforms CodeT5 with statistical significance, as confirmed by paired non-parametric tests.
  • The average improvement in BLEU-4 score exceeds the 2-point threshold considered meaningful for human detectability, indicating practical significance.
  • Same-project training reduces computational cost and avoids data leakage, offering a more realistic and stable evaluation setting than cross-project benchmarks.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.