arXiv:2507.20109cs.SEcs.AI2025-07被引 3

提出自适应偏好优化方法,提升代码生成模型对人类偏好的对齐效果。

Learning to Align Human Code Preferences

  • 基于SFT与DPO动态组合,自动选择最优训练策略。
  • 在6个代码任务中表现优于传统SFT和S&D方法。
  • 适合需要高精度代码生成的开发者工具场景。

大型语言模型在自动化软件开发任务中展现出巨大潜力。尽管近期研究采用监督微调(SFT)和直接偏好优化(DPO)来对齐模型与人类偏好,但不同代码偏好场景下的最佳训练策略仍不明确。本文系统研究了SFT与DPO在不同代码偏好场景中的作用。理论分析与实验表明:当存在客观最优解时,SFT表现更优;而在无客观最优解的场景中,先SFT后DPO(S&D)可探索更优解。基于此,我们提出自适应偏好优化(APO),通过动态增强偏好响应、抑制非偏好响应并鼓励探索潜在更优解。在六个代表性代码偏好任务上的实验验证了理论假设,结果显示APO始终匹配或超越现有SFT与S&D策略。本工作为不同代码偏好对齐场景提供了理论基础与实践指导。

原文摘要 · Abstract (English)

Large Language Models (LLMs) have demonstrated remarkable potential in automating software development tasks. While recent advances leverage Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO) to align models with human preferences, the optimal training strategy remains unclear across diverse code preference scenarios. This paper systematically investigates the roles of SFT and DPO in aligning LLMs with different code preferences. Through both theoretical analysis and empirical observation, we hypothesize that SFT excels in scenarios with objectively verifiable optimal solutions, while applying SFT followed by DPO (S&D) enables models to explore superior solutions in scenarios without objectively verifiable optimal solutions. Based on the analysis and experimental evidence, we propose Adaptive Preference Optimization (APO), a dynamic integration approach that adaptively amplifies preferred responses, suppresses dispreferred ones, and encourages exploration of potentially superior solutions during training. Extensive experiments across six representative code preference tasks validate our theoretical hypotheses and demonstrate that APO consistently matches or surpasses the performance of existing SFT and S&D strategies. Our work provides both theoretical foundations and practical guidance for selecting appropriate training strategies in different code preference alignment scenarios.

代码生成偏好优化LLM

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