Exploring Dynamic Selection of Branch Expansion Orders for Code Generation
Hui Jiang, Chulun Zhou, Fandong Meng, Biao Zhang, Jie Zhou, Degen Huang, Qingqiang Wu, Jinsong Su
Abstract
Due to the great potential in facilitating software development, code generation has attracted increasing attention recently. Generally, dominant models are Seq2Tree models, which convert the input natural language description into a sequence of tree-construction actions corresponding to the pre-order traversal of an Abstract Syntax Tree (AST). However, such a traversal order may not be suitable for handling all multi-branch nodes. In this paper, we propose to equip the Seq2Tree model with a context-based Branch Selector, which is able to dynamically determine optimal expansion orders of branches for multi-branch nodes. Particularly, since the selection of expansion orders is a non-differentiable multi-step operation, we optimize the selector through reinforcement learning, and formulate the reward function as the difference of model losses obtained through different expansion orders. Experimental results and in-depth analysis on several commonly-used datasets demonstrate the effectiveness and generality of our approach. We have released our code at https: //github.com/DeepLearnXMU/CG-RL.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers4
- CODEP: Grammatical Seq2Seq Model for General-Purpose Code GenerationYihong Dong, Ge Li, Zhi JinISSTA 2023 · 18 citations
- When to Stop? Towards Efficient Code Generation in LLMs with Excess Token PreventionLianghong Guo, Yanlin Wang, Ensheng Shi, Wanjun Zhong et al.ISSTA 2024 · 16 citations
- Beyond Functional Correctness: Investigating Coding Style Inconsistencies in Large Language ModelsYanlin Wang, Tianyue Jiang, Mingwei Liu, Jiachi Chen et al.FSE 2025 · 6 citations
- Bridging Subword Gaps in Pretrain-Finetune Paradigm for Natural Language GenerationXin Liu, Baosong Yang, Dayiheng Liu, Haibo Zhang et al.ACL 2021
Builds on3
- TreeGen: A Tree-Based Transformer Architecture for Code GenerationZeyu Sun, Qihao Zhu, Yingfei Xiong, Yican Sun et al.AAAI 2020 · 196 citations
- Dynamic Context Selection for Document-level Neural Machine Translation via Reinforcement LearningXiaomian Kang, Yang Zhao, Jiajun Zhang, Chengqing ZongEMNLP 2020 · 61 citations
- Improving Tree-Structured Decoder Training for Code Generation via Mutual LearningBinbin Xie, Jinsong Su, Yubin Ge, Xiang Li et al.AAAI 2021 · 30 citations
Related papers
- StepCoder: Improving Code Generation with Reinforcement Learning from Compiler FeedbackShihan Dou, Yan Liu, Haoxiang Jia, Enyu Zhou et al.ACL 2024 · 12 citations
- TAG : Type Auxiliary Guiding for Code Comment GenerationRuichu Cai, Zhihao Liang, Boyan Xu, Zijian Li et al.ACL 2020 · 21 citations
- Multi-Agent Reinforcement Learning Meets Leaf Sequencing in RadiotherapyRiqiang Gao, Florin-Cristian Ghesu, Simon Arberet, Shahab Basiri et al.ICML 2024 · 5 citations
- What Makes Good In-Context Demonstrations for Code Intelligence Tasks with LLMs?Shuzheng Gao, Xin-Cheng Wen, Cuiyun Gao, Wenxuan Wang et al.ASE 2023 · 80 citations
- MARS²: Scaling Multi-Agent Tree Search via Reinforcement Learning for Code GenerationPengfei Li, Shijie Wang, Fangyuan Li, Yikun Fu et al.ACL 2026
