一句话:提出以行为理解为核心的 LLM 代码生成框架,通过使用模式检索、跨语境实践迁移与语义属性约束提升生成正确性。
大语言模型虽已广泛用于代码生成,但常产出语法正确而行为错误的代码:不遵循仓库约定、跨语境误用实践、违反语义性质。作者指出其根源在于模型只学到语法模式,缺乏对代码在具体上下文中如何执行的行为理解。为此,该工作围绕三个相互关联的挑战展开:(1)不仅检索符号是什么,还要通过使用模式检索其行为方式;(2)将行为意图与实现细节分离,从而把实践迁移到新语境;(3)在生成过程中施加语义性质约束,同时避免过高的运行时开销。初步结果显示显著提升:仓库补全的精确匹配率从 29.05% 提升到 48.2%,跨框架实践迁移的一致率从 0% 提升到 100%。目标是让 LLM 从模式匹配系统转变为理解代码“做什么”而非仅“长什么样”的行为感知生成系统。
Large Language Models (LLMs) have transformed software engineering by automating code generation, yet they frequently produce code that is syntactically correct but behaviorally incorrect—failing to respect repository conventions, misapplying practices across contexts, or violating semantic properties. These failures come from a fundamental limitation: current LLMs learn syntactic patterns but lack behavioral understanding of how code executes in context. This work addresses three interconnected challenges in building behaviorally-grounded code generation: (1) retrieving not just what symbols are, but how they behave through usage patterns; (2) adapting practices across contexts by separating behavioral intent from implementation details; and (3) enforcing semantic properties during generation without prohibitive runtime costs. Preliminary results demonstrate substantial improvements: 48.2% exact match on repository completion (vs. 29.05% baseline) and 100% conformance on cross-framework practice transfer (vs. 0% baseline). This work aims to transform LLMs from pattern-matching systems into behaviorally-aware generation system that understand what code does, not just what it looks like.