mathbbUSCD: Improving Code Generation of LLMs by Uncertainty-Aware Selective Contrastive Decoding
Not on the map. Why?
Abstract (arXiv)
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 uncertainty-aware selective contrastive decoding (mathbbUSCD) 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 textitpass@1 scores increase of 16.59%. We will release code and data on GitHub.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Builds on 32 of its 44 references that are in the map. First posted on arXiv 9 Sep 2024.
Builds on
32 of 44 references.
References · 32
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2020Measuring Massive Multitask Language Understandingcited by 7,768
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2023WizardLM: Empowering large pre-trained language models to follow complex instructionscited by 1,116
- 2021GLM: General Language Model Pretraining with Autoregressive Blank Infillingcited by 1,026
- 2023Large Language Models Cannot Self-Correct Reasoning Yetcited by 965
- 2023Teaching Large Language Models to Self-Debugcited by 963
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2023Mitigating Object Hallucinations in Large Vision-Language Models through Visual Contrastive Decodingcited by 671
- 2022Contrastive Decoding: Open-ended Text Generation as Optimizationcited by 598
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
20 more
- 2023Trusting Your Evidence: Hallucinate Less with Context-aware Decodingcited by 319
- 2024Mitigating Hallucinations in Large Vision-Language Models with Instruction Contrastive Decodingcited by 198
- 2023Is Self-Repair a Silver Bullet for Code Generation?cited by 191
- 2023Can ChatGPT Understand Too? A Comparative Study on ChatGPT and Fine-tuned BERTcited by 155
- 2023Towards Making the Most of ChatGPT for Machine Translationcited by 138
- 2023Structured Chain-of-Thought Prompting for Code Generationcited by 136
- 2023Can Large Language Models Really Improve by Self-critiquing Their Own Plans?cited by 107
- 2021Jigsaw: Large Language Models meet Program Synthesiscited by 103
- 2017Abstract Syntax Networks for Code Generation and Semantic Parsingcited by 92
- 2016Latent Predictor Networks for Code Generationcited by 73
- 2018A Retrieve-and-Edit Framework for Predicting Structured Outputscited by 73
- 2023Automatic Semantic Augmentation of Language Model Prompts (for Code Summarization)cited by 72
- 2021Break-It-Fix-It: Unsupervised Learning for Program Repaircited by 71
- 2022Compilable Neural Code Generation with Compiler Feedbackcited by 46
- 2023Mitigating Hallucinations and Off-target Machine Translation with Source-Contrastive and Language-Contrastive Decodingcited by 42
- 2018Retrieval-Based Neural Code Generationcited by 41
- 2024ROSE Doesn't Do That: Boosting the Safety of Instruction-Tuned Large Language Models with Reverse Prompt Contrastive Decodingcited by 32
- 2024Beyond Code Generation: An Observational Study of ChatGPT Usage in Software Engineering Practicecited by 25
- 2019Coupling Retrieval and Meta-Learning for Context-Dependent Semantic Parsingcited by 18
- 2024Uncertainty Aware Learning for Language Model Alignmentcited by 13
Built on by
Citing papers per year: 2024: 1; 2025: 2; 2026: 3.
6 papers.
- 2024DynamicKV: Task-Aware Adaptive KV Cache Compression for Long Context LLMscited by 42
- 2025Loki's Dance of Illusions: A Comprehensive Survey of Hallucination in Large Language Modelscited by 6
- 2025Enhancing Input-Label Mapping in In-Context Learning with Contrastive Decodingcited by 4
- 2026Temporal Guidance for Large Language Modelscited by 0
- 2026Gradient-Guided Reward Optimization for Inference-time Alignmentcited by 0
- 2026Beyond Tokens: A Survey on Decoding Methods for Large Language and Vision-Language Modelscited by 0
- 2026Beyond Tokens: A Survey on Decoding Methods for Large Language and Vision-Language Models14 Aug 2026
- 2026Gradient-Guided Reward Optimization for Inference-time Alignment8 Jun 2026
- 2026Temporal Guidance for Large Language Models29 Jan 2026
- 2025Loki's Dance of Illusions: A Comprehensive Survey of Hallucination in Large Language Models6 Jun 2025
- 2025Enhancing Input-Label Mapping in In-Context Learning with Contrastive Decoding19 Feb 2025
- 2024DynamicKV: Task-Aware Adaptive KV Cache Compression for Long Context LLMs19 Dec 2024