2025-02-07 · 专家 · 计算机视觉 · 机器学习 · 数据科学

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

本文研究了针对低资源语言的代码生成问题,通过实验比较了多种技术,发现上下文学习在提高低资源语言代码生成性能方面是一种安全且有效的方法。

更新于 2025-08-22。作者:Alessandro Giagnorio、Alberto Martin-Lopez、Gabriele Bavota。

中文摘要

大型语言模型(LLMs)的出现显著推进了自动化代码生成的领域。LLMs依靠大量且多样化的数据集来学习编程语言的语法、语义和用法模式。对于低资源语言(即具有训练数据稀缺特性的细分编程语言),这种数据的有限可用性阻碍了模型有效泛化的能力,导致与高资源语言相比,代码生成性能较差。因此,寻找能够缩小这一性能差距的技术成为了一种追求。我们进行了一项实证研究,探讨了提升LLMs在低资源语言上性能的几种方法的有效性,具体包括:(i)经典微调,然而由于训练数据的稀缺性,其规模受到限制;(ii)三种上下文学习变体,其中提示被设计用来向LLM提供关于低资源语言的额外信息(例如,展示目标语言特征的少量示例);以及(iii)一个预训练目标,教会模型如何在高资源语言和低资源语言之间进行翻译。我们的研究背景是两种低资源语言(R和Racket)以及六种具有不同架构和大小的LLMs。我们的发现显示,对于较小的LLMs来说,微调通常是最佳选择,这可能是因为即使是小数据集也足以训练它们有限的参数数量。随着模型规模的增加,上下文学习变得越来越有效,代表了一种安全且经济的选择(即总是有帮助,但效果程度不同)。不同地,当对非常大的LLMs进行微调时,它们在低资源语言上的性能可能会下降,这可能是因为缺乏足够的数据来有效地更新其权重。

英文摘要

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.

解读

一句话总结

本文研究了针对低资源语言的代码生成问题,通过实验比较了多种技术,发现上下文学习在提高低资源语言代码生成性能方面是一种安全且有效的方法。

问题1:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源

机器可读索引:llms.txt