Comments as Natural Logic Pivots: Improve Code Generation via Comment Perspective

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Chen, Yijie, Liu, Yijin, Meng, Fandong, Chen, Yufeng, Xu, Jinan, Zhou, Jie
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866909166678835200
author Chen, Yijie
Liu, Yijin
Meng, Fandong
Chen, Yufeng
Xu, Jinan
Zhou, Jie
author_facet Chen, Yijie
Liu, Yijin
Meng, Fandong
Chen, Yufeng
Xu, Jinan
Zhou, Jie
contents Code generation aims to understand the problem description and generate corresponding code snippets, where existing works generally decompose such complex tasks into intermediate steps by prompting strategies, such as Chain-of-Thought and its variants. While these studies have achieved some success, their effectiveness is highly dependent on the capabilities of advanced Large Language Models (LLMs) such as GPT-4, particularly in terms of API calls, which significantly limits their practical applicability. Consequently, how to enhance the code generation capabilities of small and medium-scale code LLMs without significantly increasing training costs is an appealing challenge. In this paper, we suggest that code comments are the natural logic pivot between natural language and code language and propose using comments to boost the code generation ability of code LLMs. Concretely, we propose MANGO (comMents As Natural loGic pivOts), including a comment contrastive training strategy and a corresponding logical comment decoding strategy. Experiments are performed on HumanEval and MBPP, utilizing StarCoder and WizardCoder as backbone models, and encompassing model parameter sizes between 3B and 7B. The results indicate that MANGO significantly improves the code pass rate based on the strong baselines. Meanwhile, the robustness of the logical comment decoding strategy is notably higher than the Chain-of-thoughts prompting. The code is publicly available at \url{https://github.com/pppa2019/Mango}.
format Preprint
id arxiv_https___arxiv_org_abs_2404_07549
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Comments as Natural Logic Pivots: Improve Code Generation via Comment Perspective
Chen, Yijie
Liu, Yijin
Meng, Fandong
Chen, Yufeng
Xu, Jinan
Zhou, Jie
Computation and Language
Code generation aims to understand the problem description and generate corresponding code snippets, where existing works generally decompose such complex tasks into intermediate steps by prompting strategies, such as Chain-of-Thought and its variants. While these studies have achieved some success, their effectiveness is highly dependent on the capabilities of advanced Large Language Models (LLMs) such as GPT-4, particularly in terms of API calls, which significantly limits their practical applicability. Consequently, how to enhance the code generation capabilities of small and medium-scale code LLMs without significantly increasing training costs is an appealing challenge. In this paper, we suggest that code comments are the natural logic pivot between natural language and code language and propose using comments to boost the code generation ability of code LLMs. Concretely, we propose MANGO (comMents As Natural loGic pivOts), including a comment contrastive training strategy and a corresponding logical comment decoding strategy. Experiments are performed on HumanEval and MBPP, utilizing StarCoder and WizardCoder as backbone models, and encompassing model parameter sizes between 3B and 7B. The results indicate that MANGO significantly improves the code pass rate based on the strong baselines. Meanwhile, the robustness of the logical comment decoding strategy is notably higher than the Chain-of-thoughts prompting. The code is publicly available at \url{https://github.com/pppa2019/Mango}.
title Comments as Natural Logic Pivots: Improve Code Generation via Comment Perspective
topic Computation and Language
url https://arxiv.org/abs/2404.07549