GAP-Gen: Guided Automatic Python Code Generation

Junchen Zhao, Yurun Song, Junlin Wang, Ian Harris


Abstract
Automatic code generation from natural language descriptions can be highly beneficial during the process of software development. In this work, we propose GAP-Gen, a Guided Automatic Python Code Generation method based on Python syntactic constraints and semantic constraints. We first introduce Python syntactic constraints in the form of Syntax-Flow, which is a simplified version of Abstract Syntax Tree (AST) reducing the size and high complexity of Abstract Syntax Tree but maintaining crucial syntactic information of Python code. In addition to Syntax-Flow, we introduce Variable-Flow which abstracts variable and function names consistently through out the code. In our work, rather than pretraining, we focus on modifying the finetuning process which reduces computational requirements but retains high generation performance on automatic Python code generation task. GAP-Gen fine-tunes the transformer based language models T5 and CodeT5 using the Code-to-Docstring datasets CodeSearchNet, CodeSearchNet AdvTest and Code-Docstring Corpus from EdinburghNLP. Our experiments show that GAP-Gen achieves better results on automatic Python code generation task than previous works
Anthology ID:
2023.eacl-srw.4
Volume:
Proceedings of the 17th Conference of the European Chapter of the Association for Computational Linguistics: Student Research Workshop
Month:
May
Year:
2023
Address:
Dubrovnik, Croatia
Editors:
Elisa Bassignana, Matthias Lindemann, Alban Petit
Venue:
EACL
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
37–51
Language:
URL:
https://aclanthology.org/2023.eacl-srw.4
DOI:
10.18653/v1/2023.eacl-srw.4
Bibkey:
Cite (ACL):
Junchen Zhao, Yurun Song, Junlin Wang, and Ian Harris. 2023. GAP-Gen: Guided Automatic Python Code Generation. In Proceedings of the 17th Conference of the European Chapter of the Association for Computational Linguistics: Student Research Workshop, pages 37–51, Dubrovnik, Croatia. Association for Computational Linguistics.
Cite (Informal):
GAP-Gen: Guided Automatic Python Code Generation (Zhao et al., EACL 2023)
Copy Citation:
PDF:
https://aclanthology.org/2023.eacl-srw.4.pdf
Video:
 https://aclanthology.org/2023.eacl-srw.4.mp4