Table of Contents
Fetching ...

Enhancing Code Generation for Low-Resource Languages: No Silver Bullet

Alessandro Giagnorio, Alberto Martin-Lopez, Gabriele Bavota

TL;DR

The paper investigates the performance gap in LLM-based code generation between high-resource and low-resource programming languages. It conducts a comprehensive, cross-model study across six LLMs and six languages, evaluating five boosting techniques (three in-context prompting variants and two fine-tuning strategies) plus a code-translation pre-training objective. Key findings show that fine-tuning boosts small models, while in-context learning yields stronger gains for larger models, with very large models sometimes deteriorating under fine-tuning; translation-based in-context prompts provide robust improvements across models. The work offers practical guidance for practitioners on choosing boosting strategies based on model size and highlights future directions such as retrieval-augmented generation and broader language/model coverage.

Abstract

The advent of Large Language Models (LLMs) has significantly advanced the field of automated code generation. LLMs rely on large and diverse datasets to learn syntax, semantics, and usage patterns of programming languages. For low-resource languages (i.e., niche programming languages characterized by the scarcity of training data), the limited availability of such data hampers the models' ability to generalize effectively, resulting in poorer code generation performance as compared to high-resource languages. For this reason, there is a quest for techniques able to close this performance gap. We present an empirical study investigating the effectiveness of several approaches for boosting LLMs' performance on low-resource languages, namely: (i) a classic fine-tuning, which is however capped in size by the scarcity of training data; (ii) three variants of in-context learning, with prompts crafted to provide the LLM with additional information about the low-resource language (e.g., few-shot examples showcasing features of the targeted language); and (iii) a pre-training objective teaching the model how to translate between high- and low-resource languages. The context of our study are two low-resource languages (R and Racket) and six LLMs having different architectures and sizes. Our findings reveal that a fine-tuning is usually the best choice for smaller LLMs, possibly due to the fact that even a small dataset is sufficient to train their limited number of parameters. With the increase in size of the models, in-context learning becomes more and more effective, representing a safe and cheap bet (i.e., it always helps, but with different magnitudes). Differently, very large LLMs may deteriorate their performance on low-resource languages when fine-tuning is performed, possibly due to the lack of enough data needed to effectively update their weights.

Enhancing Code Generation for Low-Resource Languages: No Silver Bullet

TL;DR

The paper investigates the performance gap in LLM-based code generation between high-resource and low-resource programming languages. It conducts a comprehensive, cross-model study across six LLMs and six languages, evaluating five boosting techniques (three in-context prompting variants and two fine-tuning strategies) plus a code-translation pre-training objective. Key findings show that fine-tuning boosts small models, while in-context learning yields stronger gains for larger models, with very large models sometimes deteriorating under fine-tuning; translation-based in-context prompts provide robust improvements across models. The work offers practical guidance for practitioners on choosing boosting strategies based on model size and highlights future directions such as retrieval-augmented generation and broader language/model coverage.

Abstract

The advent of Large Language Models (LLMs) has significantly advanced the field of automated code generation. LLMs rely on large and diverse datasets to learn syntax, semantics, and usage patterns of programming languages. For low-resource languages (i.e., niche programming languages characterized by the scarcity of training data), the limited availability of such data hampers the models' ability to generalize effectively, resulting in poorer code generation performance as compared to high-resource languages. For this reason, there is a quest for techniques able to close this performance gap. We present an empirical study investigating the effectiveness of several approaches for boosting LLMs' performance on low-resource languages, namely: (i) a classic fine-tuning, which is however capped in size by the scarcity of training data; (ii) three variants of in-context learning, with prompts crafted to provide the LLM with additional information about the low-resource language (e.g., few-shot examples showcasing features of the targeted language); and (iii) a pre-training objective teaching the model how to translate between high- and low-resource languages. The context of our study are two low-resource languages (R and Racket) and six LLMs having different architectures and sizes. Our findings reveal that a fine-tuning is usually the best choice for smaller LLMs, possibly due to the fact that even a small dataset is sufficient to train their limited number of parameters. With the increase in size of the models, in-context learning becomes more and more effective, representing a safe and cheap bet (i.e., it always helps, but with different magnitudes). Differently, very large LLMs may deteriorate their performance on low-resource languages when fine-tuning is performed, possibly due to the lack of enough data needed to effectively update their weights.

Paper Structure

This paper contains 21 sections, 1 figure, 3 tables.

Figures (1)

  • Figure 1: DeepSeek Coder 33B generations on "HumanEval_7_filter_by_substring" problem from the translated HumanEval dataset.