paperbot · PL 论文追踪

全部论文 待读 收藏

P2 CODEP: Grammatical Seq2Seq Model for General-Purpose Code Generation

CODEP:面向通用代码生成的语法化 Seq2Seq 模型
ISSTA Proceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis2023匹配度 3/10 · 该论文属于 PL 与 ML 交叉的语法约束代码生成(用下推自动机保证生成语法正确),与用户关注的静态分析×ML/Agent、浮点程序分析、贝叶斯程序分析等具体方向均无直接关联,且为 Seq2Seq 时代工作,非建立在当前强 LLM 之上。引用 39 inbox
Yihong Dong, Ge Li, Zhi Jin
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出基于下推自动机的语法约束 Seq2Seq 代码生成框架 CODEP,保证生成代码语法正确并提升多项基准指标。

通用代码生成需将自然语言描述转为 Python 等通用语言代码,但现有 Seq2Seq 模型忽略语法规则。本文首次提出面向通用代码生成的语法化 Seq2Seq 方法:基于 PL 是 PDA 可识别语言子集、PDA 接受代码即合语法的原理,构建 PDA 模块并设计约束生成算法;进一步提出 CODEP,将 PDA 推导状态(状态表示、状态预测与联合预测)融入深度学习。作者为 Python 构建 PDA,在四个公开基准上实验,CODEP 达到 100% 语法正确率;相比基模型,CONALA 的 CodeBLEU 相对提升 17%,DJANGO 的 EM 提升 8%,JUICE-10K 的 CodeBLEU 提升 15%,对预训练模型亦有显著提升。

问题
现有通用代码生成的 Seq2Seq 模型在生成 Python 等语言代码时忽略语法规则,难以保证生成代码符合 GPL 语法约束。
方法
构建 PDA 模块与约束生成算法,并提出 CODEP 框架,将 PDA 推导状态表示、状态预测和联合预测融入 Seq2Seq 学习,使生成过程受语法约束。
评估
为 Python 构建 PDA,在四个公开基准数据集上实验;CODEP 取得 100% 语法正确率,并在 CONALA、DJANGO、JUICE-10K 上相对基模型提升 CodeBLEU/EM,预训练模型上也有效。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 · DBLP

BibTeX
@inproceedings{abs-2211-00818,
  title = {CODEP: Grammatical Seq2Seq Model for General-Purpose Code Generation},
  author = {Yihong Dong and Ge Li and Zhi Jin},
  booktitle = {ISSTA},
  year = {2023},
  doi = {10.1145/3597926.3598048}
}