TruthX: Alleviating Hallucinations by Editing Large Language Models in Truthful Space

Shaolei Zhang, Tian Yu, Yang Feng
2/27/2024
cs.CLcs.AIcs.LG

No official code found. Best implementation: ictnlp/TruthX (144 stars, GPL-3.0, last commit 2024-03-26).

Abstract

Large Language Models (LLMs) sometimes suffer from producing hallucinations, especially LLMs may generate untruthful responses despite knowing the correct knowledge. Activating the truthfulness within LLM is the key to fully unlocking LLM's knowledge potential. In this paper, we propose TruthX, an inference-time intervention method to activate the truthfulness of LLM by identifying and editing the features within LLM's internal representations that govern the truthfulness. TruthX employs an auto-encoder to map LLM's representations into semantic and truthful latent spaces respectively, and applies contrastive learning to identify a truthful editing direction within the truthful space. During inference, by editing LLM's internal representations in truthful space, TruthX effectively enhances the truthfulness of LLM. Experiments show that TruthX improves the truthfulness of 13 advanced LLMs by an average of 20% on TruthfulQA benchmark. Further analyses suggest that TruthX can control LLM to produce truthful or hallucinatory responses via editing only one vector in LLM's internal representations.

View on arXivView PDF

Code Implementations(1)

ictnlp/TruthXCommunity100%
GPL-3.0

Code for ACL 2024 paper "TruthX: Alleviating Hallucinations by Editing Large Language Models in Truthful Space"

1447C, C++Feb 27, 20242 years agoGPL-3.0
baichuanchatglmchatgptexplainable-aigpt-4+13 more

Similar Papers

Cite this paper

@article{zhang2024truthx,
  title  = {TruthX: Alleviating Hallucinations by Editing Large Language Models in Truthful Space},
  author = {Shaolei Zhang and Tian Yu and Yang Feng},
  year   = {2024},
  eprint = {2402.17811},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2402.17811v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.17811.svg)](https://codeofpaper.com/paper/2402.17811)

Discussion