Aligning with Human Coding Preferences for Improving Code Generation
Open Access
- 30 June 2026
- journal article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Software Engineering
- Vol. 3 (FSE) , 2373-2395
Abstract
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 types. 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 types with objectively verifiable optimal solutions, while applying SFT followed by DPO (S&D) enables models to explore superior solutions in types without objectively verifiable optimal solutions. Based on the analysis and experimental evidence, we propose A daptive P reference O ptimization (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 types.Keywords
This publication has 12 references indexed in Scilit:
- An Empirical Study of Issues in Large Language Model Training Systems2025
- What You See is What You Get: Attention-Based Self-Guided Automatic Unit Test Generation2025
- ThinkRepair: Self-Directed Automated Program Repair2024
- Understanding Code Understandability Improvements in Code ReviewsIEEE Transactions on Software Engineering, 2024
- Lost in Translation: A Study of Bugs Introduced by Large Language Models while Translating Code2024
- Evaluating Large Language Models in Class-Level Code Generation2024
- APIRO: A Framework for Automated Security Tools API RecommendationACM Transactions on Software Engineering and Methodology, 2023
- Self-Instruct: Aligning Language Models with Self-Generated Instructions2023
- An Empirical Study of Code Smells in Transformer-based Code Generation Techniques2022
- Machine/Deep Learning for Software Engineering: A Systematic Literature ReviewIEEE Transactions on Software Engineering, 2022