CODEP: Grammatical Seq2Seq Model for General-Purpose Code Generation
摘要
General-purpose code generation aims to automatically convert the natural language description to code snippets in a general-purpose programming language (GPL) such as Python. In the process of code generation, it is essential to guarantee the generated code satisfies grammar constraints of GPL. However, existing sequence-to-sequence (Seq2Seq) approaches neglect grammar rules when generating GPL code. In this paper, we devise a pushdown automaton (PDA)-based methodology to make the first attempt to consider grammatical Seq2Seq models for general-purpose code generation, exploiting the principle that PL is a subset of PDA recognizable language and code accepted by PDA is grammatical. Specifically, we construct a PDA module and design an algorithm to constrain the generation of Seq2Seq models to ensure grammatical correctness. Guided by this methodology, we further propose CODEP, a code generation framework equipped with a PDA module, to integrate the deduction of PDA into deep learning. This framework leverages the state of PDA deduction (including state representation, state prediction task, and joint prediction with state) to assist models in learning PDA deduction. To comprehensively evaluate CODEP, we construct a PDA for Python and conduct extensive experiments on four public benchmark datasets. CODEP can employ existing sequence-based models as base models, and we show that it achieves 100% grammatical correctness percentage on these benchmark datasets. Consequently, CODEP relatively improves 17% CodeBLEU on CONALA, 8% EM on DJANGO, and 15% CodeBLEU on JUICE-10K compared to base models. Moreover, PDA module also achieves significant improvements on the pre-trained models.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 7 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation 引用了 BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension
- ROCODE: Integrating Backtracking Mechanism and Program Analysis in Large Language Models for Code Generation 引用了 InCoder: A Generative Model for Code Infilling and Synthesis
- Contextualized Data-Wrangling Code Generation in Computational Notebooks 引用了 BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension
- Contextualized Data-Wrangling Code Generation in Computational Notebooks 引用了 CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
- Unseen Horizons: Unveiling the Real Capability of LLM Code Generation Beyond the Familiar 引用了 InCoder: A Generative Model for Code Infilling and Synthesis
引用它的顶会 Paper7
- ZC3: Zero-Shot Cross-Language Code Clone DetectionJia Li, Chongyang Tao, Zhi Jin, Fang Liu 等ASE 2023 · 7 次引用
- ROCODE: Integrating Backtracking Mechanism and Program Analysis in Large Language Models for Code GenerationXue Jiang, Yihong Dong, Yongding Tao, Huanyu Liu 等ICSE 2025 · 6 次引用
- Contextualized Data-Wrangling Code Generation in Computational NotebooksJunjie Huang, Daya Guo, Chenglong Wang, Jiazhen Gu 等ASE 2024 · 5 次引用
- Unseen Horizons: Unveiling the Real Capability of LLM Code Generation Beyond the FamiliarYuanliang Zhang, Yifan Xie, Shanshan Li, Ke Liu 等ICSE 2025 · 2 次引用
- NERFIFY: A Multi-Agent Framework for Turning NeRF Papers into CodeSeemandhar Jain, Keshav Gupta, Kunal Gupta, Manmohan ChandrakerCVPR 2026 · 1 次引用
它引用的 Paper9
- BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and ComprehensionMike Lewis, Yinhan Liu, Naman Goyal, Marjan Ghazvininejad 等ACL 2020 · 1,224 次引用
- CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and GenerationYue Wang, Weishi Wang, Shafiq R. Joty, Steven C. H. HoiEMNLP 2021 · 1,224 次引用
- Synchromesh: Reliable Code Generation from Pre-trained Language ModelsGabriel Poesia, Alex Polozov, Vu Le, Ashish Tiwari 等ICLR 2022 · 200 次引用
- TreeGen: A Tree-Based Transformer Architecture for Code GenerationZeyu Sun, Qihao Zhu, Yingfei Xiong, Yican Sun 等AAAI 2020 · 196 次引用
- InCoder: A Generative Model for Code Infilling and SynthesisDaniel Fried, Armen Aghajanyan, Jessy Lin, Sida Wang 等ICLR 2023 · 140 次引用
相关 Paper
- Compilable Neural Code Generation with Compiler FeedbackXin Wang, Yasheng Wang, Yao Wan, Fei Mi 等ACL Findings 2022 · 46 次引用
- Analysis of Tree-Structured Architectures for Code GenerationSamip Dahal, Adyasha Maharana, Mohit BansalACL Findings 2021 · 9 次引用
- Improving Tree-Structured Decoder Training for Code Generation via Mutual LearningBinbin Xie, Jinsong Su, Yubin Ge, Xiang Li 等AAAI 2021 · 30 次引用
- GrammarT5: Grammar-Integrated Pretrained Encoder-Decoder Neural Model for CodeQihao Zhu, Qingyuan Liang, Zeyu Sun, Yingfei Xiong 等ICSE 2024 · 10 次引用
- Dependency Parsing via Sequence GenerationBoda Lin, Zijun Yao, Jiaxin Shi, Shulin Cao 等EMNLP Findings 2022 · 4 次引用
