计算机科学 ›› 2024, Vol. 51 ›› Issue (6): 61-67.doi: 10.11896/jsjkx.230400137
徐一然1, 周宇1,2
XU Yiran1, ZHOU Yu1,2
摘要: 代码自动生成是提高软件开发效率的有效途径之一,已有的研究一般将代码生成作为一项序列到序列的任务,并且大规模预训练语言模型的微调过程往往伴随着高昂的算力开销。文中提出了一种基于提示学习的轻量化代码生成方法(Prompt Learning based Parameter-Efficient Code Generation,PPECG),该方法通过查询代码语料库中与当前需求最相似的结果作为提示,指导预训练语言模型进行代码生成,并且在该过程中固定模型的绝大多数参数以实现减少算力开销的目的。为了验证PPECG的有效性,文中选取了两个代码生成数据集,分别是CONCODE和Solidity4CG,通过计算生成结果的BLEU,CodeBLEU以及Exact Match值来验证PPECG的有效性,实验结果表明,PPECG有效地减少了微调时的显存开销,且在上述指标上基本接近甚至优于目前的SOTA方法,能够较好地完成代码生成的任务。
中图分类号:
[1]ZHANG F Y,PENG X,CHEN C,et al.Research on Code Ana-lysis Based on Deep Learning[J].Computer Applications and Software,2018,35(6):9. [2]YANG Z Z,CHEN S R,GAO C Y,et al.Deep Learning Based Code Generation Methods:A Literature Review[J].Journal of Software,2024,35(2):604-628. [3]YIN P,NEUBIG G.TRANX:a Transition-based Neural Abs-tract Syntax Parser for Semantic Parsing and Code Generation[C]//Proceedings of the Conference on Empirical Methods in Natural Language Processing.2018:7-12. [4]BEAU N,CRABBÉ B.The Impact of Lexical and Grammatical Processing on Generating Code from Natural Language[C]//Findings of the Association for Computational Linguistics.ACL,2022:2204-2214. [5]WEI B,LI G,XIA X,et al.Code Generation as a Dual Task of Code Summarization[C]//Proceedings of the International Conference on Neural Information Processing Systems.NIPS,2019:6563-6573. [6]SUN Z,ZHU Q,MOU L,et al.A grammar-based structural cnn decoder for code generation[C]//Proceedings of the AAAI Conference on Artificial Intelligence.2019:7055-7062. [7]SUN Z,ZHU Q,XIONG Y,et al.Treegen:A tree-based transformer architecture for code generation[C]//Proceedings of the AAAI Conference on Artificial Intelligence.2020:8984-8991. [8]HASHIMOTO T B,GUU K,OREN Y,et al.A retrieve-and-edit framework for predicting structured outputs[C]//Procee-dings of the 32nd International Conference on Neural Information Processing Systems.2018:10073-10083. [9]FRIED D,AGHAJANYAN A,LIN J,et al.Incoder:A generative model for code infilling and synthesis[J].arXiv:2204.05999,2022. [10]CHEN B,ZHANG F,NGUYEN A,et al.Codet:Code generation with generated tests[J].arXiv:2207.10397,2022. [11]WANG Y,WANG W,JOTY S,et al.CodeT5:Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation[C]//Proceedings of the Conference on Empirical Methods in Natural Language Processing.2021:8696-8708. [12]AHMAD W U,CHAKRABORTY S,RAY B,et al.Unified pre-training for program understanding and generation[J].arXiv:2103.06333,2021. [13]LU S,GUO D,REN S,et al.Codexglue:A machine learning benchmark dataset for code understanding and generation[J].arXiv:2102.04664,2021. [14]CHEN M,TWOREK J,JUN H,et al.Evaluating large language models trained on code[J].arXiv:2107.03374,2021. [15]LI Y,CHOI D,CHUNG J,et al.Competition-level code generation with alphacode[J].arXiv:2203.07814,2022. [16]CHRISTOPOULOU F,LAMPOURAS G,GRITTA M,et al.PanGu-Coder:Program Synthesis with Function-Level Language Modeling[J].arXiv:2207.11280,2022. [17]PARVEZ M R,AHMAD W U,CHAKRABORTY S,et al.Retrieval augmented code generation and summarization[J].arXiv:2108.11601,2021. [18]WEI B,LI Y,LI G,et al.Retrieve and refine:exemplar-basedneural comment generation[C]//Proceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering.2020:349-360. [19]YANG G,LIU K,CHEN X,et al.CCGIR:Information retrieval-based code comment generation method for smart contracts[J].Knowledge-Based Systems,2022,237:107858. [20]SU J,CAO J,LIU W,et al.Whitening sentence representations for better semantics and faster retrieval[J].arXiv:2103.15316,2021. [21]CHEN X,YU C,YANG G,et al.Bash Code Comment Generation Method Based on Dual Information Retrieval[J].Journal of Software,2023,34(3):1310-1329. [22]LIU P,YUAN W,FU J,et al.Pre-train,prompt,and predict:A systematic survey of prompting methods in natural language processing[J].arXiv:2107.13586,2021. [23]IYER S,KONSTAS I,CHEUNG A,et al.Mapping language to code in programmatic context[J].arXiv:1808.09588,2018. [24]SHAZEER N,STERN M.Adafactor:Adaptive learning rateswith sublinear memory cost[C]//International Conference on Machine Learning.PMLR,2018:4596-4604. [25]REN S,GUO D,LU S,et al.Codebleu:a method for automatic evaluation of code synthesis[J].arXiv:2009.10297,2020. [26]YANG G,ZHOU Y,CHEN X,et al.ExploitGen:Template-augmented exploit code generation based on CodeBERT[J].Journal of Systems and Software,2023,197:111577. [27]APINENI K,ROUKOS S,WARD T,et al.Bleu:a method for automatic evaluation of machine translation[C]//Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics.2002:311-318. |
|