qiguanjie / ICD

Code & Data for our Paper "Alleviating Hallucinations of Large Language Models through Induced Hallucinations"

Home Page:https://arxiv.org/abs/2312.15710

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alleviating Hallucinations of Large Language Models through Induced Hallucinations

1Soochow University, Suzhou, China
2Tencent AI Lab

Version Stars Issues

image

Introduction

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.

image

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},
}

How to Install

You can use the following commands to install the environment for ICD:

conda create -n icd python==3.8
conda activate icd
pip install -r requirements.txt
cd ./transformers
pip install --editable ./

Run

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.

Contact

If you have any questions, please feel free to email me or drop me an issue.

About

Code & Data for our Paper "Alleviating Hallucinations of Large Language Models through Induced Hallucinations"

https://arxiv.org/abs/2312.15710

License:MIT License


Languages

Language:Python 98.9%Language:Jupyter Notebook 0.4%Language:Cuda 0.4%Language:Shell 0.1%Language:Dockerfile 0.0%Language:C++ 0.0%Language:C 0.0%Language:Makefile 0.0%Language:Cython 0.0%Language:Jsonnet 0.0%