On Mitigating Code LLM Hallucinations with API Documentation

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Jain, Nihal, Kwiatkowski, Robert, Ray, Baishakhi, Ramanathan, Murali Krishna, Kumar, Varun
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866916326527729664
author Jain, Nihal
Kwiatkowski, Robert
Ray, Baishakhi
Ramanathan, Murali Krishna
Kumar, Varun
author_facet Jain, Nihal
Kwiatkowski, Robert
Ray, Baishakhi
Ramanathan, Murali Krishna
Kumar, Varun
contents 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).
format Preprint
id arxiv_https___arxiv_org_abs_2407_09726
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle On Mitigating Code LLM Hallucinations with API Documentation
Jain, Nihal
Kwiatkowski, Robert
Ray, Baishakhi
Ramanathan, Murali Krishna
Kumar, Varun
Computation and Language
Artificial Intelligence
Machine Learning
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).
title On Mitigating Code LLM Hallucinations with API Documentation
topic Computation and Language
Artificial Intelligence
Machine Learning
url https://arxiv.org/abs/2407.09726