arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.17598cs.AIcs.CLcs.LG
收藏

通过推理蒸馏与结构对齐改进代码生成

Reasoning Distillation and Structural Alignment for Improved Code Generation

Universidade Estadual de Campinas(坎皮纳斯州立大学)

Amir Jalilifard, Anderson de Rezende Rocha, Marcos Medeiros Raimundo

AI总结:

本文提出将 VLLM 的推理能力蒸馏到小模型,并通过结构感知损失对齐问题与代码方案,从而在多个代码生成基准上显著提升 pass@1 等指标。

摘要:

使用语言模型实现有效的代码生成取决于两个关键因素:准确理解提示词的意图,以及生成能够运用算法推理的代码,从而产生正确的解决方案,使其能够通过多样化测试用例,同时遵守目标编程语言的语法。与其他语言任务不同,代码生成需要的不仅仅是准确的 token 预测;它要求理解解决方案层面和结构层面的关系,而不只是生成最可能的 token。超大型语言模型(VLLM)能够针对复杂任务生成通向正确解决方案的详细步骤,而在这些任务中,推理对于解决问题至关重要。较小的语言模型可能缺乏此类推理能力。因此,在本工作中,我们将 VLLM 的推理能力蒸馏到一个更小、更高效的模型中,该模型部署起来更快、成本更低。我们的方法训练模型模仿 VLLM 的推理和问题解决能力,具体方式是学习识别正确的求解路径,并通过一种新颖的结构感知损失优化方法,在问题定义与潜在解决方案之间建立结构对应关系。这使模型能够超越 token 级生成,并深刻把握给定问题解决方案的总体结构。实验结果表明,我们通过低成本且易于实施的流程开发的微调模型,在 MBPP、MBPP Plus 和 HumanEval 基准测试上,于 pass@1、平均数据流和平均语法匹配指标方面均显著优于基线模型。

英文摘要:

Effective code generation with language models hinges on two critical factors: accurately understanding the intent of the prompt and generating code that applies algorithmic reasoning to produce correct solutions capable of passing diverse test cases while adhering to the syntax of the target programming language. Unlike other language tasks, code generation requires more than accurate token prediction; it demands comprehension of solution-level and structural relationships rather than merely generating the most likely tokens. very large language model (VLLM) are capable of generating detailed steps toward the correct solution of complex tasks where reasoning is crucial in solving the problem. Such reasoning capabilities may be absent in smaller language models. Therefore, in this work, we distill the reasoning capabilities of a VLLM into a smaller, more efficient model that is faster and cheaper to deploy. Our approach trains the model to emulate the reasoning and problem-solving abilities of the VLLM by learning to identify correct solution pathways and establishing a structural correspondence between problem definitions and potential solutions through a novel method of structure-aware loss optimization. This enables the model to transcend token-level generation and to deeply grasp the overarching structure of solutions for given problems. Experimental results show that our fine-tuned model, developed through a cheap and simple to implement process, significantly outperforms our baseline model in terms of pass@1, average data flow, and average syntax match metrics across the MBPP, MBPP Plus, and HumanEval benchmarks.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑