EMNLP 2022finding8 citations

CodeExp: Explanatory Code Document Generation

Haotian Cui, Chenglong Wang, Junjie Huang, Jeevana Priya Inala, Todd Mytkowicz, Bo Wang, Jianfeng Gao, Nan Duan

Abstract

Developing models that can automatically generate detailed code explanation can greatly benefit software maintenance and programming education. However, existing code-to-text generation models often produce only high-level summaries of code that do not capture implementation-level choices essential for these scenarios. To fill in this gap, we propose the code explanation generation task. We first conducted a human study to identify the criteria for high-quality explanatory docstring for code. Based on that, we collected and refined a large-scale code docstring corpus and formulated automatic evaluation metrics that best match human assessments. Finally, we present a multi-stage fine-tuning strategy and baseline models for the task. Our experiments show that (1) our refined training dataset lets models achieve better performance in the explanation generation tasks compared to larger-scale unrefined data (15x larger), and (2) fine-tuned models can generate well-structured long docstrings comparable to human-written ones. We envision our training dataset, human-evaluation protocol, recommended metrics, and fine-tuning strategy can boost future code explanation research. The code and annotated data are available at https://github.com/subercui/CodeExp.

BibTeX
@inproceedings{cui-etal-2022-codeexp,
    title = "{C}ode{E}xp: Explanatory Code Document Generation",
    author = "Cui, Haotian  and
      Wang, Chenglong  and
      Huang, Junjie  and
      Inala, Jeevana Priya  and
      Mytkowicz, Todd  and
      Wang, Bo  and
      Gao, Jianfeng  and
      Duan, Nan",
    editor = "Goldberg, Yoav  and
      Kozareva, Zornitsa  and
      Zhang, Yue",
    booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2022",
    month = dec,
    year = "2022",
    address = "Abu Dhabi, United Arab Emirates",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2022.findings-emnlp.174/",
    doi = "10.18653/v1/2022.findings-emnlp.174",
    pages = "2342--2354"
}
CodeExp: Explanatory Code Document Generation · EMNLP 2022