arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2507.06138cs.CLcs.AI
收藏

编码三角形:大型语言模型如何理解代码?

Coding Triangle: How Does Large Language Model Understand Code?

Shanghai AI Laboratory(上海人工智能实验室);Tsinghua University(清华大学);Xi’an Jiaotong University(西安交通大学)

Taolin Zhang, Zihan Ma, Maosong Cao, Junnan Liu, Songyang Zhang, Kai Chen

AI总结:

提出编码三角形框架,从编辑分析、代码实现和测试用例生成三个维度系统评估大语言模型的编程能力,发现其解决方案缺乏人类程序的多样性和鲁棒性,并表明整合人类编辑、解决方案和多样化测试用例可显著提升模型性能。

摘要:

大型语言模型(LLMs)在代码生成方面取得了显著进展,但其真正的编程能力仍未得到充分探索。我们引入了编码三角形(Code Triangle)框架,该框架系统地评估LLMs在三个基本维度上的表现:编辑分析、代码实现和测试用例生成。通过在竞争性编程基准上的广泛实验,我们揭示出,尽管LLMs能够在这三个维度上形成一个自洽的系统,但它们的解决方案往往缺乏人类程序员的多样性和鲁棒性。我们识别出模型认知与人类专业知识之间存在显著的分布偏移,模型错误往往因训练数据偏差和有限的推理迁移而聚集。我们的研究表明,整合人类生成的编辑内容、解决方案和多样化测试用例,以及利用模型混合,可以显著提升LLMs的性能和鲁棒性。此外,我们揭示了LLMs认知中的一致性与不一致性,这可能促进自我反思和自我改进,为开发更强大的编码模型提供了潜在方向。

英文摘要:

Large language models (LLMs) have achieved remarkable progress in code generation, yet their true programming competence remains underexplored. We introduce the Code Triangle framework, which systematically evaluates LLMs across three fundamental dimensions: editorial analysis, code implementation, and test case generation. Through extensive experiments on competitive programming benchmarks, we reveal that while LLMs can form a self-consistent system across these dimensions, their solutions often lack the diversity and robustness of human programmers. We identify a significant distribution shift between model cognition and human expertise, with model errors tending to cluster due to training data biases and limited reasoning transfer. Our study demonstrates that incorporating human-generated editorials, solutions, and diverse test cases, as well as leveraging model mixtures, can substantially enhance both the performance and robustness of LLMs. Furthermore, we reveal both the consistency and inconsistency in the cognition of LLMs that may facilitate self-reflection and self-improvement, providing a potential direction for developing more powerful coding models.

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

↑