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

TreeCoder: 对LLM代码生成解码与约束的系统探索与优化

TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generation

University of Bristol(布里斯托大学)

Henrijs Princis, Arindam Sharma, Cristina David

AI总结:

TreeCoder通过系统探索和优化解码策略与约束,提升LLM代码生成的准确性和结构,实验表明其在多个开源模型上显著优于无约束基线。

摘要:

大型语言模型(LLMs)在生成代码方面表现出色,但仅通过自然语言提示引导时,其输出常违反语法或语义约束。我们引入TreeCoder,这是目前最通用且灵活的框架,用于探索LLM中的解码策略、约束和超参数。TreeCoder将解码表示为候选程序的树搜索,其中解码策略和约束函数(如风格、语法、执行)作为一等可优化组件。此设计使系统化探索和自动调优解码配置成为可能。在MBPP(Python)和SQL-Spider基准测试中,TreeCoder在开源模型如CodeLlama、Mistral和DeepSeek上一致提升了准确性,通常以显著优势超越无约束基线。

英文摘要:

Large language models (LLMs) have shown remarkable ability to generate code, yet their outputs often violate syntactic or semantic constraints when guided only through natural language prompts. We introduce TreeCoder, the most general and flexible framework to date for exploring decoding strategies, constraints, and hyperparameters in LLMs, and use it in code generation to enforce correctness and structure during decoding rather than relying on prompt engineering. TreeCoder represents decoding as a tree search over candidate programs, where both decoding strategies and constraint functions - such as style, syntax, execution - are treated as first-class, optimisable components. This design enables systematic exploration and automatic tuning of decoding configurations using standard optimisation techniques. Experiments on the MBPP (Python) and SQL-Spider benchmarks show that TreeCoder consistently improves accuracy across open-source models such as CodeLlama, Mistral and DeepSeek, often outperforming their unconstrained baselines by considerable margins.

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

↑