Despite their impressive capabilities, large language models (LLMs) have been observed to generate responses that include inaccurate or fabricated information, a phenomenon commonly known as ``hallucination''. In this work, we propose a simple Induce-then-Contrast Decoding (ICD) strategy to mitigate this issue. We first construct a factually weak LLM by inducing hallucinations from the original LLMs. Then, we penalize these induced hallucinations during decoding to enhance the factuality of the generated content. Concretely, we determine the final next-token predictions by amplifying the predictions from the original model and downplaying the induced untruthful predictions via contrastive decoding. Experimental results on both discrimination-based and generation-based hallucination evaluation benchmarks, such as TruthfulQA and FActScore, demonstrate that our proposed ICD methods can effectively enhance the factuality of LLMs across various model sizes and families. For example, when equipped with our approach, Llama2-7B-Chat and Mistral-7B-Instruct now can achieve performance comparable to ChatGPT and GPT4 on TruthfulQA, respectively.
On TruthfulQA, our ICD approach significantly improves the truthfulness of Llama2-7B-Chat (+8 MC1 score) and Mistral-7B-Instruct (+20 MC1 score). With these improvements, the enhanced Llama2-7B-Chat and Mistral-7B-Instruct now match the performance levels of ChatGPT and GPT4, respectively.
If you are interested in our work, please cite:
@article{zhang-etal-2023-ICD,
title = {Alleviating Hallucinations of Large Language Models through Induced Hallucinations},
author = {Zhang, Yue and
Cui, Leyang and
Wei, Bi and
Shuming Shi},
journal = {arXiv preprint arXiv:2312.15710},
}
You can use the following commands to install the environment for ICD:
conda create -n icd python==3.10
conda activate icd
pip install -r requirements.txt
cd ./transformers
pip install --editable ./
Try the following command to test our method on TruthfulQA:
cd ./exp_scripts/benchmark
sh truthfulqa.sh
For experiments on Factscore, please try:
cd ./exp_scripts/benchmark
sh factscore.sh
For evaluation on Factscore, please kindly refer to their repo.
We also provide some hallucinated models on the huggingface model hub for fast trial:
Model | Link |
---|---|
HillZhang/untruthful_llama2_7b | HuggingFace |
HillZhang/untruthful_baichuan2_7b | HuggingFace |
HillZhang/untruthful_mistral_7b | HuggingFace |
HillZhang/untruthful_llama2_7b_bio | HuggingFace |
If you have any questions, please feel free to email me or drop me an issue.