This repository contains code for the implementation of our NeurIPS 2024 paper LLM-Check: Investigating Detection of Hallucinations in Large Language Models.
Recording for the NeurIPS Virtual Conference: [video]
In-person Presentation media: [poster]
In this work, we propose to directly analyze the variations in model characteristics between truthful and hallucinated examples by examining the rich semantic representations present in internal LLM representations, since we observe that the LLM can often generate the truthful version, albeit with potentially lower frequency. For instance, we observe that the kernel similarity map of self-attention across different tokens can be sensitive to Truthful or Hallucinated tokens!
We propose LLM-Check - a suite of simple, effective detection techniques over current LLMs. We propose two distinct lines of analysis, which we collectively term as LLM-Check:
We utilize these diversified scoring methods from different model components to potentially maximize the capture of hallucinations amongst its various forms without incurring computational overheads at training or inference time.
We present qualitative comparisons of the proposed method with the most pertinent baselines in the table below. We present various trade-offs and advantages in the table such as to whether the method requires fine-tuning of an LLM, if it inherently requires multiple model responses to detect hallucinations, if the method is computationally efficient, if it performs detection on per-sample basis or at a population level, and whether the method is inherently dependent on retrieval during inference time.
We compare the overall runtime cost of the proposed detection scores with other baselines using a Llama-2-7b Chat model on the FAVA-Annotation dataset on a single Nvidia A5000 GPU. For the Eigen Analysis based methods, we report the total time needed for all 32 Layers for Attention and Hidden Scores. We observe that the Logit and Attention scores are indeed very efficient, while the Hidden Score is slightly slower since it uses SVD explicitly. We also observe that LLM-Check is considerably faster than most baselines with speedups of up to 45x and 450x, since it only uses model representations with teacher forcing, without additional inference time overheads.
environment.yml file with Python 3.10.12run_detection_combined.py script is used to detect hallucinations using different scores. This can be executed using the run.sh file, where different configurations can be specified./data folder.The dataset specific utils such as utils_selfcheck.py are used to load the dataset loading function and the dataset-specific iterators which will internally call the score computations.
The final scores are saved in the /data folder, and can be analyzed using the check_scores_XYZ.ipynb file to analyze the scores, plots etc. This can be done without a GPU as the scores are already computed and saved.
@inproceedings{
sriramanan2024llmcheck,
title={{LLM}-Check: Investigating Detection of Hallucinations in Large Language Models},
author={Gaurang Sriramanan and Siddhant Bharti and Vinu Sankar Sadasivan and Shoumik Saha and Priyatham Kattakinda and Soheil Feizi},
booktitle={The Thirty-eighth Annual Conference on Neural Information Processing Systems},
year={2024},
url={https://openreview.net/forum?id=LYx4w3CAgy}
}
4 commits
1 commits
Jupyter Notebook
66.7%
Python
32.6%
This repository contains code for the implementation of our NeurIPS 2024 paper LLM-Check: Investigating Detection of Hallucinations in Large Language Models.
Recording for the NeurIPS Virtual Conference: [video]
In-person Presentation media: [poster]
In this work, we propose to directly analyze the variations in model characteristics between truthful and hallucinated examples by examining the rich semantic representations present in internal LLM representations, since we observe that the LLM can often generate the truthful version, albeit with potentially lower frequency. For instance, we observe that the kernel similarity map of self-attention across different tokens can be sensitive to Truthful or Hallucinated tokens!
We propose LLM-Check - a suite of simple, effective detection techniques over current LLMs. We propose two distinct lines of analysis, which we collectively term as LLM-Check:
We utilize these diversified scoring methods from different model components to potentially maximize the capture of hallucinations amongst its various forms without incurring computational overheads at training or inference time.
We present qualitative comparisons of the proposed method with the most pertinent baselines in the table below. We present various trade-offs and advantages in the table such as to whether the method requires fine-tuning of an LLM, if it inherently requires multiple model responses to detect hallucinations, if the method is computationally efficient, if it performs detection on per-sample basis or at a population level, and whether the method is inherently dependent on retrieval during inference time.
We compare the overall runtime cost of the proposed detection scores with other baselines using a Llama-2-7b Chat model on the FAVA-Annotation dataset on a single Nvidia A5000 GPU. For the Eigen Analysis based methods, we report the total time needed for all 32 Layers for Attention and Hidden Scores. We observe that the Logit and Attention scores are indeed very efficient, while the Hidden Score is slightly slower since it uses SVD explicitly. We also observe that LLM-Check is considerably faster than most baselines with speedups of up to 45x and 450x, since it only uses model representations with teacher forcing, without additional inference time overheads.
environment.yml file with Python 3.10.12run_detection_combined.py script is used to detect hallucinations using different scores. This can be executed using the run.sh file, where different configurations can be specified./data folder.The dataset specific utils such as utils_selfcheck.py are used to load the dataset loading function and the dataset-specific iterators which will internally call the score computations.
The final scores are saved in the /data folder, and can be analyzed using the check_scores_XYZ.ipynb file to analyze the scores, plots etc. This can be done without a GPU as the scores are already computed and saved.
@inproceedings{
sriramanan2024llmcheck,
title={{LLM}-Check: Investigating Detection of Hallucinations in Large Language Models},
author={Gaurang Sriramanan and Siddhant Bharti and Vinu Sankar Sadasivan and Shoumik Saha and Priyatham Kattakinda and Soheil Feizi},
booktitle={The Thirty-eighth Annual Conference on Neural Information Processing Systems},
year={2024},
url={https://openreview.net/forum?id=LYx4w3CAgy}
}
4 commits
1 commits
Jupyter Notebook
66.7%
Python
32.6%