TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generation
Henrijs Princis, Arindam Sharma, Cristina David
摘要
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.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 1 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Grammar-Constrained Decoding for Structured NLP Tasks without Finetuning 引用了 Synchromesh: Reliable Code Generation from Pre-trained Language Models
- Grammar-Aligned Decoding 引用了 Grammar-Constrained Decoding for Structured NLP Tasks without Finetuning
- Grammar-Aligned Decoding 引用了 Synchromesh: Reliable Code Generation from Pre-trained Language Models
引用它的顶会 Paper1
它引用的 Paper13
- Synchromesh: Reliable Code Generation from Pre-trained Language ModelsGabriel Poesia, Alex Polozov, Vu Le, Ashish Tiwari 等ICLR 2022 · 200 次引用
- Grammar-Aligned DecodingKanghee Park, Jiayu Wang, Taylor Berg-Kirkpatrick, Nadia Polikarpova 等NeurIPS 2024 · 73 次引用
- Hot or Cold? Adaptive Temperature Sampling for Code Generation with Large Language ModelsYuqi Zhu, Jia Li, Ge Li, Yunfei Zhao 等AAAI 2024 · 68 次引用
- Grammar-Constrained Decoding for Structured NLP Tasks without FinetuningSaibo Geng, Martin Josifoski, Maxime Peyrard, Robert WestEMNLP 2023 · 33 次引用
- If beam search is the answer, what was the question?Clara Meister, Ryan Cotterell, Tim VieiraEMNLP 2020 · 26 次引用
相关 Paper
- CoSec: On-the-Fly Security Hardening of Code LLMs via Supervised Co-decodingDong Li, Meng Yan, Yaosheng Zhang, Zhongxin Liu 等ISSTA 2024 · 10 次引用
- Dynamic Scoring Code Token Tree: A Novel Decoding Strategy for Generating High-Performance CodeMuzi Qu, Jie Liu, Liangyi Kang, Shuai Wang 等ASE 2024 · 2 次引用
- CertiCoder: Towards MISRA-Compliant C Code Generation with LLMsMin Gou, Zhiyu Yao, Hualong Ma, Ende Zhang 等FSE 2026
- ROCODE: Integrating Backtracking Mechanism and Program Analysis in Large Language Models for Code GenerationXue Jiang, Yihong Dong, Yongding Tao, Huanyu Liu 等ICSE 2025 · 6 次引用
- Chiseling Out Efficiency: Structured Skeleton Supervision for Efficient Code GenerationYu Yu, Zhihong Sun, Jia Li, Yao Wan 等FSE 2026
