一句话:提出任务增强方法与 Subtoken-TranX 模型,在前端 JavaScript 领域数据稀缺下显著提升代码生成准确率。
自然语言到代码的生成通常依赖大规模「描述—代码」配对语料,但在前端 JavaScript 等特定领域,此类数据难以直接获取,人工撰写代码描述成本极高。数据受限会导致模型训练不充分、易过拟合,难以满足实际应用需求。为此,本文提出一种任务增强方法,通过引入辅助任务把领域知识注入代码生成模型;同时将原 TranX 模型扩展为支持 subtoken 级生成的 Subtoken-TranX,以缓解标识符切分带来的问题。作者收集了真实世界的前端代码生成数据集并开展实验,结果表明 Subtoken-TranX 优于原 TranX 与 Transformer,且借助任务增强,其精确匹配准确率提升 12.75%,在若干代码类别上已达到工业系统可用水平。该方法已被阿里巴巴 BizCook 平台采用,据作者所知是首个在工业开发环境中落地的领域代码生成系统。
Code generation aims to generate a code snippet automatically from natural language descriptions. Generally, the mainstream code generation methods rely on a large amount of paired training data, including both the natural language description and the code. However, in some domain-specific scenarios, building such a large paired corpus for code generation is difficult because there is no directly available pairing data, and a lot of effort is required to manually write the code descriptions to construct a high-quality training dataset. Due to the limited training data, the generation model cannot be well trained and is likely to be overfitting, making the model's performance unsatisfactory for real-world use. To this end, in this paper, we propose a task augmentation method that incorporates domain knowledge into code generation models through auxiliary tasks and a Subtoken-TranX model by extending the original TranX model to support subtoken-level code generation. To verify our proposed approach, we collect a real-world code generation dataset and conduct experiments on it. Our experimental results demonstrate that the subtoken-level TranX model outperforms the original TranX model and the Transformer model on our dataset, and the exact match accuracy of Subtoken-TranX improves significantly by 12.75% with the help of our task augmentation method. The model performance on several code categories has satisfied the requirements for application in industrial systems. Our proposed approach has been adopted by Alibaba's BizCook platform. To the best of our knowledge, this is the first domain code generation system adopted in industrial development environments.
DOI 原文 ·
@inproceedings{paperbot7013,
title = {Incorporating domain knowledge through task augmentation for front-end JavaScript code generation},
author = {Sijie Shen and Xiang Zhu and Yihong Dong and Qizhi Guo and Yankun Zhen and Ge Li},
booktitle = {FSE},
year = {2022},
doi = {10.1145/3540250.3558965}
}