arXiv:2502.11466cs.LGcs.CL2025-02ACL被引 3

用吉布斯采样改进代码生成自训练,减少条件采样偏差。

GiFT: Gibbs Fine-Tuning for Code Generation

  • 基于吉布斯采样从联合分布中采样代码,避免条件依赖偏差。
  • 在四个数据集上优于传统方法,尤其在难题上提升显著。
  • 适合想提升代码生成模型泛化能力的研究者和开发者。

使用合成数据训练大语言模型(LLM)是代码生成中的常见做法。主流方法为自训练:模型迭代地在自生成的正确代码片段上训练,这些代码基于特定的种子描述生成。然而,同一意图可能对应多种有效描述,仅依赖条件分布会导致描述-代码联合空间的覆盖不足。为此,本文提出吉布斯微调(GiFT),受吉布斯采样启发,使自生成数据来自联合空间的边缘分布,缓解条件采样的偏差。我们提供了理论分析,证明边缘分布微调的潜力。此外,提出基于困惑度的代码选择策略,缓解自生成代码的长尾分布不平衡问题。在两个LLM和四个数据集上的实证评估显示,GiFT表现更优,尤其在更具挑战性的基准上。源码见https://github.com/Alex-HaochenLi/GiFT。

原文摘要 · Abstract (English)

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.

代码生成自训练吉布斯采样

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。