FGIT: Fault-Guided Fine-Tuning for Code Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Fan, Lishui, Liu, Zhongxin, Wang, Haoye, Bao, Lingfeng, Xia, Xin, Li, Shanping
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866908760709005312
author Fan, Lishui
Liu, Zhongxin
Wang, Haoye
Bao, Lingfeng
Xia, Xin
Li, Shanping
author_facet Fan, Lishui
Liu, Zhongxin
Wang, Haoye
Bao, Lingfeng
Xia, Xin
Li, Shanping
contents Modern instruction-tuned large language models (LLMs) have made remarkable progress in code generation. However, these LLMs fine-tuned with standard supervised fine-tuning (SFT) sometimes generate plausible-looking but functionally incorrect code variants. This issue likely stems from the limitation of standard SFT, which treats all tokens equally during optimization and fails to emphasize the error-sensitive segments-specific code differences between correct implementations and similar incorrect variants. To address this problem, we propose Fault-Guided Fine-Tuning (FGIT), a novel fine-tuning technique that enhances LLMs' code generation by (1) extracting multi-granularity (line/token-level) differences between correct and incorrect yet similar implementations to identify error-sensitive segments, and (2) dynamically prioritizing those segments during training via dynamic loss weighting. Through extensive experiments on seven LLMs across three widely-used benchmarks, our method achieves an average relative improvement of 6.9% on pass@1 with some enhanced 6.7B LLMs outperforming closed-source models, e.g., GPT-3.5-Turbo. Furthermore, our fine-tuning technique demonstrates strong generalization with performance improvements ranging from 3.8% to 19.1% across diverse instruction-tuned LLMs, and our ablation studies confirm the contributions of different granularities of differences and hyperparameters.
format Preprint
id arxiv_https___arxiv_org_abs_2503_16913
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle FGIT: Fault-Guided Fine-Tuning for Code Generation
Fan, Lishui
Liu, Zhongxin
Wang, Haoye
Bao, Lingfeng
Xia, Xin
Li, Shanping
Software Engineering
Modern instruction-tuned large language models (LLMs) have made remarkable progress in code generation. However, these LLMs fine-tuned with standard supervised fine-tuning (SFT) sometimes generate plausible-looking but functionally incorrect code variants. This issue likely stems from the limitation of standard SFT, which treats all tokens equally during optimization and fails to emphasize the error-sensitive segments-specific code differences between correct implementations and similar incorrect variants. To address this problem, we propose Fault-Guided Fine-Tuning (FGIT), a novel fine-tuning technique that enhances LLMs' code generation by (1) extracting multi-granularity (line/token-level) differences between correct and incorrect yet similar implementations to identify error-sensitive segments, and (2) dynamically prioritizing those segments during training via dynamic loss weighting. Through extensive experiments on seven LLMs across three widely-used benchmarks, our method achieves an average relative improvement of 6.9% on pass@1 with some enhanced 6.7B LLMs outperforming closed-source models, e.g., GPT-3.5-Turbo. Furthermore, our fine-tuning technique demonstrates strong generalization with performance improvements ranging from 3.8% to 19.1% across diverse instruction-tuned LLMs, and our ablation studies confirm the contributions of different granularities of differences and hyperparameters.
title FGIT: Fault-Guided Fine-Tuning for Code Generation
topic Software Engineering
url https://arxiv.org/abs/2503.16913