mlsanityData to 7 Oct 2026

On Mitigating Code LLM Hallucinations with API Documentation

arXiv 2407.09726 ↗First posted 13 Jul 2024cs.CL cs.AI cs.LGcited by 21

Not on the map. Why?

Abstract (arXiv)

In this study, we address the issue of API hallucinations in various software engineering contexts. We introduce CloudAPIBench, a new benchmark designed to measure API hallucination occurrences. CloudAPIBench also provides annotations for frequencies of API occurrences in the public domain, allowing us to study API hallucinations at various frequency levels. Our findings reveal that Code LLMs struggle with low frequency APIs: for e.g., GPT-4o achieves only 38.58% valid low frequency API invocations. We demonstrate that Documentation Augmented Generation (DAG) significantly improves performance for low frequency APIs (increase to 47.94% with DAG) but negatively impacts high frequency APIs when using sub-optimal retrievers (a 39.02% absolute drop). To mitigate this, we propose to intelligently trigger DAG where we check against an API index or leverage Code LLMs' confidence scores to retrieve only when needed. We demonstrate that our proposed methods enhance the balance between low and high frequency API performance, resulting in more reliable API invocations (8.20% absolute improvement on CloudAPIBench for GPT-4o).

Key facts. Cited by 21 papers in the map (data through 7 Oct 2026). Builds on 41 of its 58 references that are in the map. First posted on arXiv 13 Jul 2024.

Builds on

41 of 58 references.

References · 41

  1. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  2. 2020Scaling Laws for Neural Language Modelscited by 6,411
  3. 2021Program Synthesis with Large Language Modelscited by 3,509
  4. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  5. 2023ToolLLM: Facilitating Large Language Models to Master 16000+ Real-world APIscited by 1,880
  6. 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,800
  7. 2022Language Models (Mostly) Know What They Knowcited by 1,783
  8. 2023Gorilla: Large Language Model Connected with Massive APIscited by 1,302
  9. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
  10. 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memoriescited by 1,103
  11. 2023Large Language Models Can Be Easily Distracted by Irrelevant Contextcited by 820
  12. 2023REPLUG: Retrieval-Augmented Black-Box Language Modelscited by 786
29 more
  1. 2023Active Retrieval Augmented Generationcited by 506
  2. 2024StarCoder 2 and The Stack v2: The Next Generationcited by 484
  3. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
  4. 2023Making Retrieval-Augmented Language Models Robust to Irrelevant Contextcited by 364
  5. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
  6. 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 346
  7. 2023How Language Model Hallucinations Can Snowballcited by 310
  8. 2023The Impact of AI on Developer Productivity: Evidence from GitHub Copilotcited by 264
  9. 2022Prompting GPT-3 To Be Reliablecited by 258
  10. 2022Grounded Copilot: How Programmers Interact with Code-Generating Modelscited by 216
  11. 2023A Stitch in Time Saves Nine: Detecting and Mitigating Hallucinations of LLMs by Validating Low-Confidence Generationcited by 202
  12. 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 181
  13. 2022DocPrompting: Generating Code by Retrieving the Docscited by 151
  14. 2022GitHub Copilot AI pair programmer: Asset or Liability?cited by 150
  15. 2024Fine-grained Hallucination Detection and Editing for Language Modelscited by 146
  16. 2024CodeGemma: Open Code Models Based on Gemmacited by 145
  17. 2022Impact of Pretraining Term Frequencies on Few-Shot Reasoningcited by 142
  18. 2024To Believe or Not to Believe Your LLMcited by 120
  19. 2024Granite Code Models: A Family of Open Foundation Models for Code Intelligencecited by 116
  20. 2024Beyond Functional Correctness: Exploring Hallucinations in LLM-Generated Codecited by 106
  21. 2023Lift Yourself Up: Retrieval-augmented Text Generation with Self Memorycited by 103
  22. 2023Self-Knowledge Guided Retrieval Augmentation for Large Language Modelscited by 69
  23. 2023Shall We Pretrain Autoregressive Language Models with Retrieval? A Comprehensive Studycited by 63
  24. 2024API-BLEND: A Comprehensive Corpora for Training and Benchmarking API LLMscited by 39
  25. 2023Ever: Mitigating Hallucination in Large Language Models through Real-Time Verification and Rectificationcited by 38
  26. 2023A Static Evaluation of Code Completion by Large Language Modelscited by 14
  27. 2023How Well Do Large Language Models Truly Ground?cited by 14
  28. 2023Private-Library-Oriented Code Generation with Large Language Modelscited by 10
  29. 2023StubCoder: Automated Generation and Repair of Stub Code for Mock Objectscited by 1

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 5; 2025: 11; 2026: 5.

21 papers.

Sort:

By area:

  1. 2024Agents in Software Engineering: Survey, Landscape, and Visioncited by 60
  2. 2024Reducing Tool Hallucination via Reliability Alignmentcited by 37
  3. 2024An LLM Agent for Automatic Geospatial Data Analysiscited by 21
  4. 2025When LLMs Meet API Documentation: Can Retrieval Augmentation Aid Code Generation Just as It Helps Developers?cited by 12
  5. 2025Hallucination by Code Generation LLMs: Taxonomy, Benchmarks, Mitigation, and Challengescited by 9
  6. 2024Retrieval-Augmented Test Generation: How Far Are We?cited by 7
  7. 2024A Methodology for Evaluating RAG Systems: A Case Study On Configuration Dependency Validationcited by 6
  8. 2025Towards Mitigating API Hallucination in Code Generated by LLMs with Hierarchical Dependency Awarecited by 6
  9. 2025Agent WARPP: Workflow Adherence via Runtime Parallel Personalizationcited by 3
  10. 2025Isolating Language-Coding from Problem-Solving: Benchmarking LLMs with PseudoEvalcited by 2
  11. 2025CCCI: Code Completion with Contextual Information for Complex Data Transfer Tasks Using Large Language Modelscited by 2
  12. 2025FalseCrashReducer: Mitigating False Positive Crashes in OSS-Fuzz-Gen Using Agentic AIcited by 2
9 more
  1. 2025Library Hallucinations in LLM-Generated Code: A Risk Analysis Grounded in Developer Queriescited by 1
  2. 2025HFuzzer: Testing Large Language Models for Package Hallucinations via Phrase-based Fuzzingcited by 1
  3. 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Codecited by 1
  4. 2026Correct Code, Vulnerable Dependencies: A Large Scale Measurement Study of LLM-Specified Library Versionscited by 1
  5. 2025Improving Multi-turn Task Completion in Task-Oriented Dialog Systems via Prompt Chaining and Fine-Grained Feedbackcited by 0
  6. 2025Benchmarking Web API Integration Code Generationcited by 0
  7. 2026LibEvoBench: Probing Temporal Knowledge Stratification in Code Generation Modelscited by 0
  8. 2026Skills That Don't Exist: A Large-Scale Study of Hallucinated Skill Recommendation in LLM Agentscited by 0
  9. 2026Can Agents Design Libraries for Agents?cited by 0