Chain-of-Thought in Neural Code Generation: From and for Lightweight Language Models

Large Language Models (LLMs) have demonstrated remarkable potential in code generation. The integration of Chain of Thought (CoT) reasoning can further boost their performance. However, current CoT methods often require manual writing or LLMs with over 100 billion parameters to generate, impeding their applicability in resource-constrained scenarios. In this study, we investigate lightweight Language Models (<inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs), which are defined to have fewer than 10 billion parameters. Empirically, we find that most <inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs cannot generate high-quality CoTs when prompted by the few-shot method, but can take advantage of high-quality CoTs generated elsewhere to improve their performance in code generation. Based on these findings, we design a novel approach <monospace>COTTON</monospace> which can leverage <inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs to automatically generate CoTs for code generation. We synthesize new datasets and conduct extensive experiments on various benchmarks. The results show that the CoTs generated by <monospace>COTTON</monospace> outperform the baselines in terms of automated and human evaluation metrics. In particular, the CoTs generated by <monospace>COTTON</monospace> boost various <inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs to achieve higher performance gains than those generated by LLMs such as ChatGLM (130B), and are competitive with those generated by Gemini and gpt-3.5-turbo. The results also reveal that <monospace>COTTON</monospace> not only improves the performance of <inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs, but also enhances the performance of LLMs. Our study showcases the potential of <inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs in software engineering applications.

Authors

Institutions

Publication Details

Journal
IEEE Transactions on Software Engineering
Published
2024-08-12
DOI
https://doi.org/10.1109/tse.2024.3440503
Citations
37
Primary Topic
Topic Modeling
Type
article
Field-Weighted Citation Impact
12.85

Funders

Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Chain-of-Thought in Neural Code Generation: From and for Lightweight Language Models

Guang Yang, Taolue Chen, Yu Zhou, Terry Yue Zhuo et al.
37 citations
IEEE Transactions on Software Engineering
Topic Modeling
12.85
article

Chain-of-Thought in Neural Code Generation: From and for Lightweight Language Models

Guang Yang, Taolue Chen, Yu Zhou, Terry Yue Zhuo, Xiang Chen, Xiangyu Zhang
article en
37 citations

Abstract

Large Language Models (LLMs) have demonstrated remarkable potential in code generation. The integration of Chain of Thought (CoT) reasoning can further boost their performance. However, current CoT methods often require manual writing or LLMs with over 100 billion parameters to generate, impeding their applicability in resource-constrained scenarios. In this study, we investigate lightweight Language Models (<inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs), which are defined to have fewer than 10 billion parameters. Empirically, we find that most <inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs cannot generate high-quality CoTs when prompted by the few-shot method, but can take advantage of high-quality CoTs generated elsewhere to improve their performance in code generation. Based on these findings, we design a novel approach <monospace>COTTON</monospace> which can leverage <inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs to automatically generate CoTs for code generation. We synthesize new datasets and conduct extensive experiments on various benchmarks. The results show that the CoTs generated by <monospace>COTTON</monospace> outperform the baselines in terms of automated and human evaluation metrics. In particular, the CoTs generated by <monospace>COTTON</monospace> boost various <inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs to achieve higher performance gains than those generated by LLMs such as ChatGLM (130B), and are competitive with those generated by Gemini and gpt-3.5-turbo. The results also reveal that <monospace>COTTON</monospace> not only improves the performance of <inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs, but also enhances the performance of LLMs. Our study showcases the potential of <inline-formula><tex-math notation="LaTeX">$\ell$</tex-math></inline-formula>LMs in software engineering applications.

IEEE Transactions on Software EngineeringVol. 50(9)
Nantong University (CN), Monash University (AU), Birkbeck, University of London (GB), Nanjing University of Aeronautics and Astronautics (CN)
National Natural Science Foundation of China, Fundamental Research Funds for the Central Universities
Quality Education
Openalex Percentile: Top 1%
Topic Modeling
12.85
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.