$mathbb{USCD}$:通过不确定性感知的选择性对比解码改进 LLM 的代码生成

Shuai Wang, Liang Ding, Li Shen, Yong Luo, Zheng He, Wei Yu, Dacheng Tao
{"title":"$mathbb{USCD}$:通过不确定性感知的选择性对比解码改进 LLM 的代码生成","authors":"Shuai Wang, Liang Ding, Li Shen, Yong Luo, Zheng He, Wei Yu, Dacheng Tao","doi":"arxiv-2409.05923","DOIUrl":null,"url":null,"abstract":"Large language models (LLMs) have shown remarkable capabilities in code\ngeneration. However, the effects of hallucinations (e.g., output noise) make it\nparticularly challenging for LLMs to generate high-quality code in one pass. In\nthis work, we propose a simple and effective \\textbf{u}ncertainty-aware\n\\textbf{s}elective \\textbf{c}ontrastive \\textbf{d}ecoding ($\\mathbb{USCD}$)\nmechanism to improve the quality of one-pass code generation in LLMs and reduce\nthe impact of output noise. To be specific, we first elaborately designed a\nnegative prompt (namely lame prompt) to output noise by removing input-output\nexamples from the standard few-shot prompt. Our preliminary study shows that\nthe Jensen-Shannon divergence (JS divergence) between token distribution\nuncertainty and the output noise is relatively low (approximately $0.25$),\nindicating their high relevance. Then, we selectively eliminate output noise\ninduced by lame prompts based on the uncertainty of the prediction distribution\nfrom the standard prompt. Notably, our proposed plug-and-play mechanism is an\ninference-only method, enjoying appealing flexibility. Extensive experiments on\nwidely used benchmarks, e.g., HumanEval, MBPP, and MultiPL-E, upon several LLMs\n(i.e., Inocder-6b, CodeLlama-7b, WizardCoder-15b, StarCoder, and Llama2-7b),\ndemonstrate that our proposed USCD significantly improves one-pass code\ngeneration, with an average \\textit{pass@$1$} scores increase of 16.59\\%. We\nwill release code and data on GitHub.","PeriodicalId":501278,"journal":{"name":"arXiv - CS - Software Engineering","volume":"9 1","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-09-09","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"$\\\\mathbb{USCD}$: Improving Code Generation of LLMs by Uncertainty-Aware Selective Contrastive Decoding\",\"authors\":\"Shuai Wang, Liang Ding, Li Shen, Yong Luo, Zheng He, Wei Yu, Dacheng Tao\",\"doi\":\"arxiv-2409.05923\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"Large language models (LLMs) have shown remarkable capabilities in code\\ngeneration. However, the effects of hallucinations (e.g., output noise) make it\\nparticularly challenging for LLMs to generate high-quality code in one pass. In\\nthis work, we propose a simple and effective \\\\textbf{u}ncertainty-aware\\n\\\\textbf{s}elective \\\\textbf{c}ontrastive \\\\textbf{d}ecoding ($\\\\mathbb{USCD}$)\\nmechanism to improve the quality of one-pass code generation in LLMs and reduce\\nthe impact of output noise. To be specific, we first elaborately designed a\\nnegative prompt (namely lame prompt) to output noise by removing input-output\\nexamples from the standard few-shot prompt. Our preliminary study shows that\\nthe Jensen-Shannon divergence (JS divergence) between token distribution\\nuncertainty and the output noise is relatively low (approximately $0.25$),\\nindicating their high relevance. Then, we selectively eliminate output noise\\ninduced by lame prompts based on the uncertainty of the prediction distribution\\nfrom the standard prompt. Notably, our proposed plug-and-play mechanism is an\\ninference-only method, enjoying appealing flexibility. Extensive experiments on\\nwidely used benchmarks, e.g., HumanEval, MBPP, and MultiPL-E, upon several LLMs\\n(i.e., Inocder-6b, CodeLlama-7b, WizardCoder-15b, StarCoder, and Llama2-7b),\\ndemonstrate that our proposed USCD significantly improves one-pass code\\ngeneration, with an average \\\\textit{pass@$1$} scores increase of 16.59\\\\%. We\\nwill release code and data on GitHub.\",\"PeriodicalId\":501278,\"journal\":{\"name\":\"arXiv - CS - Software Engineering\",\"volume\":\"9 1\",\"pages\":\"\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2024-09-09\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"arXiv - CS - Software Engineering\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/arxiv-2409.05923\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"arXiv - CS - Software Engineering","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/arxiv-2409.05923","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

摘要

大型语言模型(LLMs)在代码生成方面表现出了非凡的能力。然而,由于幻觉(如输出噪声)的影响,LLMs 要一次性生成高质量的代码尤其具有挑战性。在这项工作中,我们提出了一种简单有效的不确定性感知(textbf{u}ncertainty-aware\textbf{s}elective \textbf{c}ontrastive\textbf{d}ecoding($\mathbb{USCD}$)机制,以提高 LLM 一次生成代码的质量,并降低输出噪声的影响。具体来说,我们首先精心设计了一种消极提示(即跛脚提示),通过从标准的几发提示中移除输入-输出示例来消除输出噪声。初步研究表明,令牌分布不确定性与输出噪声之间的詹森-香农分歧(JS 分歧)相对较低(约为 0.25 美元),这表明它们具有很高的相关性。然后,我们根据标准提示的预测分布的不确定性,有选择地消除跛脚提示引起的输出噪声。值得注意的是,我们提出的即插即用机制是一种纯推理方法,具有极高的灵活性。在广泛使用的基准(如HumanEval、MBPP和MultiPL-E)和多个LLM(即Inocder-6b、CodeLlama-7b、WizardCoder-15b、StarCoder和Llama2-7b)上进行的大量实验表明,我们提出的USCD显著提高了单通代码生成能力,平均textit{pass@$1$}得分提高了16.59%。我们将在 GitHub 上发布代码和数据。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
$\mathbb{USCD}$: Improving Code Generation of LLMs by Uncertainty-Aware Selective Contrastive Decoding
Large language models (LLMs) have shown remarkable capabilities in code generation. However, the effects of hallucinations (e.g., output noise) make it particularly challenging for LLMs to generate high-quality code in one pass. In this work, we propose a simple and effective \textbf{u}ncertainty-aware \textbf{s}elective \textbf{c}ontrastive \textbf{d}ecoding ($\mathbb{USCD}$) mechanism to improve the quality of one-pass code generation in LLMs and reduce the impact of output noise. To be specific, we first elaborately designed a negative prompt (namely lame prompt) to output noise by removing input-output examples from the standard few-shot prompt. Our preliminary study shows that the Jensen-Shannon divergence (JS divergence) between token distribution uncertainty and the output noise is relatively low (approximately $0.25$), indicating their high relevance. Then, we selectively eliminate output noise induced by lame prompts based on the uncertainty of the prediction distribution from the standard prompt. Notably, our proposed plug-and-play mechanism is an inference-only method, enjoying appealing flexibility. Extensive experiments on widely used benchmarks, e.g., HumanEval, MBPP, and MultiPL-E, upon several LLMs (i.e., Inocder-6b, CodeLlama-7b, WizardCoder-15b, StarCoder, and Llama2-7b), demonstrate that our proposed USCD significantly improves one-pass code generation, with an average \textit{pass@$1$} scores increase of 16.59\%. We will release code and data on GitHub.
求助全文
通过发布文献求助,成功后即可免费获取论文全文。 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Promise and Peril of Collaborative Code Generation Models: Balancing Effectiveness and Memorization Shannon Entropy is better Feature than Category and Sentiment in User Feedback Processing Motivations, Challenges, Best Practices, and Benefits for Bots and Conversational Agents in Software Engineering: A Multivocal Literature Review A Taxonomy of Self-Admitted Technical Debt in Deep Learning Systems Investigating team maturity in an agile automotive reorganization
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1