Skip to content

Enhancing the Non-Functional Quality Compliance of LLM-Generated Code through Quality-Aware Preference Learning

Mar 2025 · 2 citations · 57 references
Computer Science

TL;DR

This work proposes a framework for quality-aware preference learning that guides LLMs toward generating criteria-compliant code and introduces a hybrid optimization objective that combines ranking loss with language modeling loss and KL divergence to enable effective comparative optimization.

Abstract

Large Language Models (LLMs) have been widely adopted in commercial code completion engines, significantly enhancing coding efficiency and productivity. However, even functionally correct LLM-generated code may exhibit non-functional quality issues that violate coding standards and best practices, such as poor style and limited maintainability. To address this, we propose a framework for quality-aware preference learning that guides LLMs toward generating criteria-compliant code. Our approach consists of three phases. First, we construct a dataset of paired criteria-violating and criteria-compliant samples, where each pair contains code exhibiting a specific non-functional quality issue and its repaired version that resolves the issue. Second, we design an adaptive token weighting mechanism to emphasize quality-sensitive code regions. Third, we introduce a hybrid optimization objective that combines ranking loss with language modeling loss and KL divergence to enable effective comparative optimization. Extensive experiments on DeepSeek-Coder and Qwen2.5-Coder show that our method substantially improves compliance with the targeted non-functional quality criteria while maintaining functional correctness, achieving a 75.7% relative increase in Quality Reciprocal Score (QRS) on MBPP-sanitized for Qwen2.5-Coder. Fine-tuning a 7B model requires less than three hours, indicating strong practical viability. Ablation studies and a user study further support the effectiveness of the proposed framework.

View source

Similar papers

Review Oct 2026

PreMaQ: Predicting Maintainability-Related Quality of LLM-Generated Code Before Generation

As large language models (LLMs) become increasingly capable of code generation, adopting generated code in software development requires assessing not only its functional correctness but also its maintainability-related quality. If such quality could be estimated before generation, developers could avoid the cost of ge...

Taiki Wakamatsu, Yuta Ishimoto, Masanari Kondo et al. · 0 citations
Open access Sep 2026

Quality over Quantity: Diversity-Aware Data Selection for Efficient Verilog Code Generation

VeriSelector is proposed, the first data selection framework for Verilog code generation that jointly optimizes quality and diversity, and outperforms full-dataset training and state-of-the-art baselines.

Yi-Heng Shen, Wei Zheng, Xiao Wei et al. · 0 citations
Preprint Nov 2026

Phase-wise MLLM Tuning for Multi-framework WebUI Code Generation

Multimodal large language models (MLLMs) achieve strong performance in translating WebUI screenshots into HTML/CSS. However, when they faced multiple frameworks (React/Vue/Angular), they often suffer from negative transfer that leads to compilation failures. These failures commonly stem from mixing framework specific s...

Hao-Ran Ma, Lin-Xiao Li, Chen-Yue Wang et al. · 0 citations
Preprint Oct 2026

Beyond Functional Correctness: Static Code Quality Profiling of LLM-Generated Code

Large language models (LLMs) are increasingly used for code generation, yet most evaluations still focus on whether generated code passes benchmark test suites. Functional correctness alone, however, provides only a limited view of quality: benchmark tests are often incomplete, and passing them does not guarantee that...

Jue-Zhe Huang, Tarek Mahmud, Mei-Ru Che et al. · 0 citations

Exploring Data-Efficient Adaptation of Large Language Models for Code Generation

A novel adaptation approach named DEED, which stands for D ata-E fficient adaptation with E rror-D riven learning for code generation, leverages the errors made by LLMs as learning opportunities, using error revision to overcome their own shortcomings, thus achieving efficient learning.

Xue Jiang, Zhiyuan Fan Zhi Jin YIHONG DONG, Wen-Pin Jiao et al. · 1 citation
#artificial intelligence Review Sep 2026

Complexity-Aware Evaluation of LLM Comprehension

A complexity-aware framework for evaluating LLM code comprehension using cyclomatic complexity, nesting depth, branching factor, and Halstead volume demonstrates that complexity-aware evaluation provides a more diagnostic assessment of LLM code-comprehension reliability than aggregate accuracy alone.

Ali Mohammadi Esfahani, Nafiseh Kahani, S. Ajila · 0 citations

Related blog posts

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.