arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2503.14838cs.SE
收藏

像人类开发者一样思考:利用社区知识进行结构化代码推理

Think Like Human Developers: Harnessing Community Knowledge for Structured Code Reasoning

Chengran Yang, Zhensu Sun, Hong Jin Kang, Jieke Shi, David Lo

AI总结:

针对LLM复杂代码推理能力弱、高质量推理数据稀缺的问题,提出SVRC框架从社区讨论中挖掘重构推理链,微调得到的CodeThinker在LiveCodeBench中等难度代码任务上性能显著提升。

摘要:

大语言模型(LLMs)已显著推动了自动化代码生成的发展,但它们在需要多步逻辑推理的复杂编码任务中仍存在困难。高质量推理数据对提升LLMs的推理能力至关重要,但这类数据集仍然稀缺。现有方法要么依赖计算成本高昂的强化学习(RL),要么采用LLMs合成的易错推理链,在可扩展性和准确性方面都存在挑战。\n为应对这一挑战,我们提出SVRC(面向代码生成的结构化且经过验证的推理链),这是一个新型框架,可从软件工程平台上的社区驱动讨论中挖掘、重构并丰富推理链。SVRC通过将编码问题的非结构化、不完整讨论与软件开发生命周期(SDLC)原则对齐来对其进行优化,确保推理链能够捕捉真实世界的问题解决策略并支持迭代优化。\n为评估SVRC的有效性,我们推出了CodeThinker,这是一款基于SVRC生成的12444个推理增强样本进行微调的LLM。在LiveCodeBench上的实验表明,在中等难度代码问题的pass@1指标上,CodeThinker比其基础模型高出42.86%,并且分别优于GPT-4o-mini和GPT-4o达73.14%和115.86%。我们的消融研究进一步表明,SVRC的每个组件都对CodeThinker的推理能力有贡献。

英文摘要:

Large Language Models (LLMs) have significantly advanced automated code generation, yet they struggle with complex coding tasks requiring multi-step logical reasoning. High-quality reasoning data is crucial for improving LLMs' reasoning capabilities, but such datasets remain scarce. Existing approaches either rely on computationally expensive reinforcement learning (RL) or error-prone reasoning chains synthesized by LLMs, posing challenges in scalability and accuracy. To address this challenge, we propose SVRC (Structured and Validated Reasoning Chains for Code Generation), a novel framework that mines, restructures, and enriches reasoning chains from community-driven discussions on software engineering platforms. SVRC refines unstructured and incomplete discussions of coding problems by aligning them with Software Development Life Cycle (SDLC) principles, ensuring that reasoning chains capture real-world problem-solving strategies and support iterative refinement. To evaluate the effectiveness of SVRC, we introduce CodeThinker, an LLM fine-tuned on 12,444 reasoning-augmented samples generated by SVRC. Experiments on LiveCodeBench show that CodeThinker surpasses its base model by 42.86\% on medium-level code problems in terms of pass@1 and outperforms GPT-4o-mini and GPT-4o by 73.14\% and 115.86\%, respectively. Our ablation study further highlights that each component of SVRC contributes to the reasoning capabilities of CodeThinker.

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

↑