Less is More: DocString Compression in Code Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Yang, Guang, Zhou, Yu, Cheng, Wei, Zhang, Xiangyu, Chen, Xiang, Zhuo, Terry Yue, Liu, Ke, Zhou, Xin, Lo, David, Chen, Taolue
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866915335666401280
author Yang, Guang
Zhou, Yu
Cheng, Wei
Zhang, Xiangyu
Chen, Xiang
Zhuo, Terry Yue
Liu, Ke
Zhou, Xin
Lo, David
Chen, Taolue
author_facet Yang, Guang
Zhou, Yu
Cheng, Wei
Zhang, Xiangyu
Chen, Xiang
Zhuo, Terry Yue
Liu, Ke
Zhou, Xin
Lo, David
Chen, Taolue
contents The widespread use of Large Language Models (LLMs) in software engineering has intensified the need for improved model and resource efficiency. In particular, for neural code generation, LLMs are used to translate function/method signature and DocString to executable code. DocStrings which capture user re quirements for the code and used as the prompt for LLMs, often contains redundant information. Recent advancements in prompt compression have shown promising results in Natural Language Processing (NLP), but their applicability to code generation remains uncertain. Our empirical study show that the state-of-the-art prompt compression methods achieve only about 10% reduction, as further reductions would cause significant performance degradation. In our study, we propose a novel compression method, ShortenDoc, dedicated to DocString compression for code generation. Our extensive experiments on six code generation datasets, five open-source LLMs (1B to 10B parameters), and one closed-source LLM GPT-4o confirm that ShortenDoc achieves 25-40% compression while preserving the quality of generated code, outperforming other baseline methods at similar compression levels. The benefit of this research is to improve efficiency and reduce the cost while maintaining the quality of the generated code, especially when calling third-party APIs, and is able to reduce the token processing cost by 25-40%.
format Preprint
id arxiv_https___arxiv_org_abs_2410_22793
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Less is More: DocString Compression in Code Generation
Yang, Guang
Zhou, Yu
Cheng, Wei
Zhang, Xiangyu
Chen, Xiang
Zhuo, Terry Yue
Liu, Ke
Zhou, Xin
Lo, David
Chen, Taolue
Software Engineering
The widespread use of Large Language Models (LLMs) in software engineering has intensified the need for improved model and resource efficiency. In particular, for neural code generation, LLMs are used to translate function/method signature and DocString to executable code. DocStrings which capture user re quirements for the code and used as the prompt for LLMs, often contains redundant information. Recent advancements in prompt compression have shown promising results in Natural Language Processing (NLP), but their applicability to code generation remains uncertain. Our empirical study show that the state-of-the-art prompt compression methods achieve only about 10% reduction, as further reductions would cause significant performance degradation. In our study, we propose a novel compression method, ShortenDoc, dedicated to DocString compression for code generation. Our extensive experiments on six code generation datasets, five open-source LLMs (1B to 10B parameters), and one closed-source LLM GPT-4o confirm that ShortenDoc achieves 25-40% compression while preserving the quality of generated code, outperforming other baseline methods at similar compression levels. The benefit of this research is to improve efficiency and reduce the cost while maintaining the quality of the generated code, especially when calling third-party APIs, and is able to reduce the token processing cost by 25-40%.
title Less is More: DocString Compression in Code Generation
topic Software Engineering
url https://arxiv.org/abs/2410.22793