Pith. sign in

REVIEW 15 cited by

Not yet reviewed by Pith; the record is open.

This paper has not been read by Pith yet. Machine review is queued; the pith claim, tier, and objections will appear here once it completes.

SPECIMEN: schema-true, not a live event

T0 review · schema-true

One-sentence machine reading of the paper's core claim.

pith:XXXXXXXX · record.json · timestamp

arxiv 2401.01701 v3 pith:FO622MPU submitted 2024-01-03 cs.SE

De-Hallucinator: Mitigating LLM Hallucinations in Code Generation Tasks via Iterative Grounding

classification cs.SE
keywords codeapproachde-hallucinatorgenerationllmsreferencesapisexisting
verification ladder T0 review T1 audit T2 compute T3 formal T4 reserved
0 comments
read the original abstract

Large language models (LLMs) trained on datasets of publicly available source code have established a new state of the art in code generation tasks. However, these models are mostly unaware of the code that exists within a specific project, preventing the models from making good use of existing APIs. Instead, LLMs often invent, or "hallucinate", non-existent APIs or produce variants of already existing code. This paper presents De-Hallucinator, a technique that grounds the predictions of an LLM through a novel combination of retrieving suitable API references and iteratively querying the model with increasingly suitable context information in the prompt. The approach exploits the observation that predictions by LLMs often resemble the desired code, but they fail to correctly refer to already existing APIs. De-Hallucinator automatically identifies project-specific API references related to the model's initial predictions and adds these references into the prompt. Unlike retrieval-augmented generation (RAG), our approach uses the initial prediction(s) by the model to iteratively retrieve increasingly suitable API references. Our evaluation applies the approach to two tasks: predicting API usages in Python and generating tests in JavaScript. We show that De-Hallucinator consistently improves the generated code across five LLMs. In particular, the approach improves the edit distance by 23.3-50.6% and the recall of correctly predicted API usages by 23.9-61.0% for code completion, and improves the number of fixed tests that initially failed because of hallucinations by 63.2%, resulting in a 15.5% increase in statement coverage for test generation.

discussion (0)

Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.

Forward citations

Cited by 15 Pith papers

Reviewed papers in the Pith corpus that reference this work. Sorted by Pith novelty score.

  1. RepairAgent: An Autonomous, LLM-Based Agent for Program Repair

    cs.SE 2024-03 conditional novelty 8.0

    RepairAgent autonomously repairs 164 bugs on Defects4J including 39 not fixed by prior techniques by treating an LLM as an agent that invokes tools via a finite state machine and dynamic prompts.

  2. On the Road to Personalized Code Intelligence: Portraiting and Assisting Developers Based on Their In-IDE Behaviors

    cs.SE 2026-05 unverdicted novelty 7.0

    VirtualME is a new infrastructure that continuously extracts and interprets in-IDE developer behaviors to build personalized personas, delivering 33.8% better performance on repository-level knowledge Q&A than generic...

  3. MR-Coupler: Automated Metamorphic Test Generation via Functional Coupling Analysis

    cs.SE 2026-04 conditional novelty 7.0

    MR-Coupler leverages functional coupling analysis and LLMs to generate valid metamorphic test cases for over 90% of tasks while detecting 44% of real bugs, outperforming baselines by 64.90% in validity and 36.56% in f...

  4. Story Point Estimation Using Large Language Models

    cs.SE 2026-03 unverdicted novelty 7.0

    LLMs predict story points better in zero-shot prompting than supervised deep learning models trained on 80% of project data, with few-shot examples and comparative judgments further improving performance.

  5. Library Hallucinations in LLM-Generated Code: A Risk Analysis Grounded in Developer Queries

    cs.SE 2025-09 unverdicted novelty 7.0

    A study of seven LLMs finds that realistic prompt variations such as one-character misspellings trigger library hallucinations in up to 26% of cases, fabricated names in up to 99%, and time-based prompts in up to 85%,...

  6. Mitigating Errors in LLM-Generated Web API Invocations via Retrieval-Augmented Generation and Constrained Decoding

    cs.SE 2026-07 conditional novelty 6.0

    Constrained decoding derived from OpenAPI specifications eliminates hallucinated web API calls in LLM-generated code and substantially improves correctness across 24 models, while retrieval-augmented generation yields...

  7. SCOPE: Leveraging Subgoal Critiques for Code Generation

    cs.SE 2026-07 conditional novelty 6.0

    A Lean-oriented prover model, fine-tuned with dense and sparse RL rewards, generates structured semantic critiques that improve LLM code generation accuracy over Reflexion and Self-Refine on LiveCodeBench V6 and BigCodeBench.

  8. FASE: Fast Adaptive Semantic Entropy for Code Quality

    cs.SE 2026-06 unverdicted novelty 6.0

    FASE approximates functional correctness via MST on structural and semantic dissimilarity graphs, reporting 25% better Spearman correlation and 19% better ROCAUC than LLM-based semantic entropy at 0.3% runtime cost on...

  9. TICoder: A Repository-Level Code Generation Framework with Test-Driven Planning and Implementation-Aware Reuse

    cs.SE 2026-06 unverdicted novelty 6.0

    TICoder improves repository-level code generation by 11.52% over prior methods through test-driven planning and implementation-aware code reuse on standard benchmarks.

  10. Task Abstention for Large Language Models in Code Generation

    cs.SE 2026-05 unverdicted novelty 6.0

    A distribution-free abstention rule grounded in multiple hypothesis testing uses execution consistency to let code LLMs avoid hallucination-prone tasks with theoretical guarantees.

  11. uGen: An Agentic Framework for Generating Microarchitectural Attack PoCs

    cs.CR 2026-05 unverdicted novelty 6.0

    uGen is the first retrieval-augmented multi-agent LLM framework for generating functionally correct microarchitectural attack PoCs, reporting up to 100% success on Spectre-v1 and 80% on Prime+Probe at low cost.

  12. What Makes Software Bugs Escape Testing? Evidence from a Large-Scale Empirical Study

    cs.SE 2026-04 unverdicted novelty 6.0

    Post-release defects concentrate in older, frequently modified high-churn components and require longer and more complex fixes than pre-release defects.

  13. MojoFrame: Dataframe Library in Mojo Language

    cs.DB 2025-05 unverdicted novelty 6.0

    MojoFrame is the first dataframe library in Mojo, using tensors for numeric columns and cardinality-aware methods for others, with up to 4.6x speedup on TPC-H queries versus other libraries.

  14. MR-Adopt: Automatic Deduction of Input Transformation Function for Metamorphic Testing

    cs.SE 2024-08 unverdicted novelty 6.0

    MR-Adopt deduces input transformations from hard-coded MR test cases using LLMs, data-flow refinement, and output-relation selection to enable reuse with new source inputs.

  15. Retrieval-Augmented Generation for AI-Generated Content: A Survey

    cs.CV 2024-02 accept novelty 5.0

    A survey classifying RAG foundations for AIGC, summarizing enhancements, cross-modal applications, benchmarks, limitations, and future directions.