paper-with-me

Papers

LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and Mitigation

2024-09-30 · Ziyao Zhang, Yanlin Wang, Chong Wang, Jiachi Chen, Zibin Zheng

Code generation aims to automatically generate code from input requirements, significantly enhancing development efficiency. Recent large language models (LLMs) based approaches have shown promising results and revolutionized code generation task. Despite the promising performance, LLMs often generate contents with hallucinations, especially for the code generation scenario requiring the handling of complex contextual dependencies in practical development process. Although previous study has analyzed hallucinations in LLM-powered code generation, the study is limited to standalone function generation. In this paper, we conduct an empirical study to study the phenomena, mechanism, and mitigation of LLM hallucinations within more practical and complex development contexts in repository-level generation scenario. First, we manually examine the code generation results from six mainstream LLMs to establish a hallucination taxonomy of LLM-generated code. Next, we elaborate on the phenomenon of hallucinations, analyze their distribution across different models. We then analyze causes of hallucinations and identify four potential factors contributing to hallucinations. Finally, we propose an RAG-based mitigation method, which demonstrates consistent effectiveness in all studied LLMs. The replication package including code, data, and experimental results is available at https://github.com/DeepSoftwareAnalytics/LLMCodingHallucination

📄 PDF Abstract BibTeX arXiv:2409.20550

Code (1)

deepsoftwareanalytics/llmcodinghallucination 공식 구현

Tasks

Code GenerationHallucinationRAG

Similar Papers 제목 키워드 기반

SEReDeEP: Hallucination Detection in Retrieval-Augmented Models via Semantic Entropy and Context-Parameter Fusion

2025-05-12 · Lei Wang

Retrieval-Augmented Generation (RAG) models frequently encounter hallucination phenomena when integrating external information with internal parametric knowledge. Empirical studies demonstrate that the disequilibrium bet…

HallucinationRAGRetrieval-augmented Generation

Hallucination in LLM-Based Code Generation: An Automotive Case Study

2025-08-15 · Marc Pavel, Nenad Petrovic, Lukasz Mazur, Vahid Zolfaghari 외 arxiv

Large Language Models (LLMs) have shown significant potential in automating code generation tasks offering new opportunities across software engineering domains. However, their practical application remains limited due t…

Code Generation

HFuzzer: Testing Large Language Models for Package Hallucinations via Phrase-based Fuzzing

2025-09-28 · Yukai Zhao, Menghan Wu, Xing Hu, Xin Xia arxiv

Large Language Models (LLMs) are widely used for code generation, but they face critical security risks when applied to practical production due to package hallucinations, in which LLMs recommend non-existent packages. T…

Code Generation

Information Gravity: A Field-Theoretic Model for Token Selection in Large Language Models

2025-04-29 · Maryna Vyshnyvetska

We propose a theoretical model called "information gravity" to describe the text generation process in large language models (LLMs). The model uses physical apparatus from field theory and spacetime geometry to formalize…

DiversitySensitivityText Generation

A Comprehensive Survey of Hallucination Mitigation Techniques in Large Language Models

2024-01-02 · S. M Towhidul Islam Tonmoy, S M Mehedi Zaman, Vinija Jain, Anku Rani 외

As Large Language Models (LLMs) continue to advance in their ability to write human-like text, a key challenge remains around their tendency to hallucinate generating content that appears factual but is ungrounded. This …

Financial AnalysisHallucinationRetrievalRetrieval-augmented Generation+1