paperbot · PL 论文追踪

全部论文 待读 收藏

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

TreeCoder:面向 LLM 代码生成的解码与约束的系统化探索与优化
PLDI 10(PLDI)2026匹配度 3/10 · 论文聚焦于通过树搜索和约束优化 LLM 代码生成的解码策略,属于程序合成与 LLM 生成方向,而非用户核心关注的静态分析、形式化验证、浮点程序分析或贝叶斯程序分析;其研究目标本质是改进 LLM 代码生成,与用户'用 LLM/Agent 改进静态分析'的 AI→PL 方向不匹配。引用 6 inbox
Henrijs Princis, Arindam Sharma, Cristina David
crossref: 2026-09-10

AI 速览

一句话:提出 TreeCoder,把解码策略与约束函数作为可优化组件,通过树搜索系统性探索并自动调优 LLM 代码生成。

大语言模型虽能生成代码,但仅靠自然语言提示引导时,输出常违反语法或语义约束。本文提出 TreeCoder,一个用于探索 LLM 解码策略、约束与超参数的最通用、最灵活的框架,并将其用于代码生成,以便在解码阶段而非提示工程阶段保证正确性与结构。TreeCoder 把解码建模为在候选程序上的树搜索,将解码策略与约束函数(如风格、语法、执行约束)视为一等且可优化的组件,从而可用标准优化技术系统性地探索并自动调节解码配置。在 Python、SQL 与 Rust 上的实验表明,TreeCoder 在 CodeLlama、Mistral、DeepSeek、Qwen 等开源模型上一致提升准确率,且往往显著优于无约束基线。

问题
LLM 生成代码时若仅依赖自然语言提示,输出容易违反语法或语义约束;如何系统化探索并优化解码策略与约束以在解码期保证正确性与结构,是本文关注的问题。
方法
TreeCoder 将解码表示为候选程序上的树搜索,把解码策略与约束函数(风格、语法、执行等)抽象为一等可优化组件,并用标准优化技术自动调优解码配置。
评估
在 Python、SQL 与 Rust 三种语言上,对 CodeLlama、Mistral、DeepSeek、Qwen 等开源模型进行实验,比较 TreeCoder 与无约束基线的准确率。
原文摘要(Abstract)

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 Python, SQL and Rust show that TreeCoder consistently improves accuracy across open-source models such as CodeLlama, Mistral, DeepSeek and Qwen, often significantly outperforming their unconstrained baselines.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@article{abs-2511-22277,
  title = {TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generation},
  author = {Henrijs Princis and Arindam Sharma and Cristina David},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {PLDI},
  year = {2026},
  doi = {10.1145/3808347}
}