arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.11466cs.LGcs.CLcs.SE
收藏

GiFT: 面向代码生成的吉布斯微调

GiFT: Gibbs Fine-Tuning for Code Generation

Nanyang Technological University(南洋理工大学)

Haochen Li, Wanjin Feng, Xin Zhou, Zhiqi Shen

AI总结:

针对代码生成中LLM自训练的条件采样偏差问题,提出受吉布斯采样启发的GiFT方法,通过边缘分布采样和困惑度代码选择优化,在多基准上实现更优性能。

摘要:

使用合成数据训练大语言模型(LLM)是代码生成领域的主流做法,其中自训练是一种关键方法:LLM在自生成的正确代码片段上进行迭代训练,这类自生成代码从以特定种子描述为条件的条件分布中采样得到。但种子描述并非与其预期含义匹配的唯一有效表征,所有有效描述和代码共同构成一个联合空间,从条件分布中采样代码会导致对完整描述-代码空间的表征不足。为此,我们提出吉布斯微调(Gibbs Fine-Tuning,GiFT)——一种受吉布斯采样启发的新型自训练方法。GiFT允许从联合空间的边缘分布中采样自生成数据,从而缓解条件采样固有的偏差。我们提供了理论分析,证明使用从边缘分布得到的代码微调LLM的潜在优势。此外,我们提出一种基于困惑度的代码选择方法,以缓解自生成代码的长尾分布不平衡问题。在四个数据集上对两个LLM的实证评估表明,GiFT取得了更优的性能,在更具挑战性的基准上表现尤为突出。源代码可在https://github.com/Alex-HaochenLi/GiFT获取。

英文摘要:

Training Large Language Models (LLMs) with synthetic data is a prevalent practice in code generation. A key approach is self-training, where LLMs are iteratively trained on self-generated correct code snippets. In this case, the self-generated codes are drawn from a conditional distribution, conditioned on a specific seed description. However, the seed description is not the only valid representation that aligns with its intended meaning. With all valid descriptions and codes forming a joint space, codes drawn from the conditional distribution would lead to an underrepresentation of the full description-code space. As such, we propose Gibbs Fine-Tuning (GiFT), a novel self-training method inspired by Gibbs sampling. GiFT allows self-generated data to be drawn from the marginal distribution of the joint space, thereby mitigating the biases inherent in conditional sampling. We provide a theoretical analysis demonstrating the potential benefits of fine-tuning LLMs with code derived from the marginal distribution. Furthermore, we propose a perplexity-based code selection method to mitigate the imbalanced long-tail distribution of the self-generated codes. Empirical evaluation of two LLMs across four datasets demonstrates that GiFT achieves superior performance, particularly on more challenging benchmarks. Source code is available at https://github.com/Alex-HaochenLi/GiFT.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑