Abstract
A recent study by Ahmed and Devanbu reported that using a corpus of code written in multilingual datasets to fine-tune multilingual Pre-trained Language Models (PLMs) achieves higher performance as opposed to using a corpus of code written in just one programming language. However, no analysis was made with respect to fine-tuning monolingual PLMs. Furthermore, some programming languages are inherently different and code written in one language usually cannot be interchanged with the others, i.e., Ruby and Java code possess very different structure. To better understand how monolingual and multilingual PLMs affect different programming languages, we investigate 1) the performance of PLMs on Ruby for two popular Software Engineering tasks: Code Summarization and Code Search, 2) the strategy (to select programming languages) that works well on fine-tuning multilingual PLMs for Ruby, and 3) the performance of the fine-tuned PLMs on Ruby given different code lengths. In this work, we analyze over a hundred of pre-trained and fine-tuned models. Our results show that 1) multilingual PLMs have a lower Performance-to-Time Ratio (the BLEU, METEOR, or MRR scores over the fine-tuning duration) as compared to monolingual PLMs, 2) our proposed strategy to select target programming languages to fine-tune multilingual PLMs is effective: it reduces the time to fine-tune yet achieves higher performance in Code Summarization and Code Search tasks, and 3) our proposed strategy consistently shows good performance on different code lengths.
Introduction
In the field of Natural Language Processing (NLP) for code, "high-resource" languages like Java and Python dominate the datasets. Pre-trained Language Models (PLMs) like CodeBERT are typically trained on a massive, multilingual "kitchen sink" of data. However, many developers work in "low-resource" languages—those with far less available training data, such as Ruby, Kotlin, or Scala. This paper challenges the "bigger is always better" mantra by evaluating over 100 models to determine if monolingual models or strategically curated multilingual models offer better performance and efficiency for these low-resource scenarios.
Datasets and Task Setup
The study primarily utilizes the CodeSearchNet dataset, which includes six programming languages: Go, Java, JavaScript, PHP, Python, and Ruby. Ruby is treated as the primary "low-resource" subject due to its smaller footprint in the dataset compared to giants like PHP or Java.
The researchers evaluated models across two primary tasks:
- Code Summarization: Generating a natural language description of a code snippet.
- Code Search: Finding relevant code snippets using natural language queries.
Methodology
The authors conducted an extensive empirical study using RoBERTa as their base architecture. They introduced two key novelties to evaluate model effectiveness:
- Performance-to-Time Ratio (PTR): A metric that scales a model's accuracy (BLEU, METEOR, or MRR scores) against the time required for fine-tuning. This addresses the computational expense of training large models.
- Language Selection Strategy: Instead of fine-tuning on every available language, the authors proposed a formula to select the most "compatible" helper languages for a target low-resource language. This formula combines Semantic Similarity (using paragraph embeddings) and Textual Similarity (using token-based clone detection).
Key Results and Insights
The Efficiency Paradox
While multilingual models are often touted as the gold standard, the authors found they have a lower PTR. In many cases, a monolingual model is significantly faster to train while achieving comparable or even superior results. For the Code Search task, monolingual PLMs outperformed state-of-the-art multilingual models like CodeBERT by 5% to 35.1% in Mean Reciprocal Rank (MRR).
Strategic Selection vs. Brute Force
For Code Summarization, fine-tuning on a curated subset of similar languages (like Python, PHP, and Go for a Ruby target) outperformed fine-tuning on the entire multilingual dataset. This strategy saw improvements in BLEU scores ranging from 0.6% to 41.7% compared to standard multilingual fine-tuning. Additionally, in zero-shot scenarios, models fine-tuned on Python consistently performed best when tested on Ruby, suggesting Python provides a strong transfer learning foundation.
Human Validation
Qualitative analysis via Amazon Mechanical Turk showed that humans rated the summaries from monolingual models as highly informative and fluent, often indistinguishable from or better than those produced by multilingual giants.
Conclusion
This research demonstrates that for low-resource programming languages, bigger is not always better. Monolingual models often provide a superior performance-to-training-time ratio, and strategic selection of "helper" languages for fine-tuning yields better results than generic multilingual approaches. Future work will aim to expand these strategies to more diverse languages and a wider array of Software Engineering tasks.
Summary updated