NLP/📚 paper

논문 리뷰 💬 [Survey of Hallucination in Natural Language Generation]

MINAIR 2024. 8. 7. 15:38

📚 Paper

https://arxiv.org/abs/2311.05232

 

Abstract


본 논문은 NLG에서 발생하는 hallucination 현상에 대한 metrics(평가 지표), mitigation methods, specifics in downstream tasks, future directions 등에 대한 전반적인 조사 내용을 담고 있다. 

 

Introduction


Hallucination이란 NLG 모델이 nonsensical하고 unfaithful한 내용을 generate하는 현상이다. 

 

Definitions


Hallucination은 unreal perception을 real인 것처럼 나타내기 때문에 사용자 입장에서는 hallucinated text를 봤을 때 이를 분간하기 힘들다. 

Categorization

  • Intrinsic Hallucinations: 주어진 source content에 대해 일어나는 hallucination이다. 예를 들어 given source content에서는 '그녀는 1996년생이다'이지만 hallucinated text는 '그녀는 1990년생이다'. 
  • Extrinsic Hallucination: 주어진 source content로부터 검증할 수 없는 hallucination으로, 예를 들어 given source content에서는 없는 정보가 generated text에 있는 것이다. 

Task Comparison

downstream task마다 hallucination에 대한 정의와 대처 방법이 다르다. 주요 차이점은 어떤 source content를 입력으로 받고 또 얼마나 hallucination에 tolerance가 있는지다. 예를 들어, abstractive summarization은 긴 text를 입력으로 받고 dialogue system은 dialogue history나 external knowledge sentences를 입력으로 받는다. 또 abstractive summarization은 주어진 입력에 대해 faithful한 결과를 내놓아야 하기 때문에 hallucination tolerance가 낮지만 dialogue system은 engaging하고 diverse한 결과를 출력해야 하기 때문에 hallucination tolerance가 높다. 

Terminology Clarification

  • Faithfulness: provided source에 대해 얼마나 충실한 지. 즉, world knowledge와 관계 없이 얼마나 주어진 입력을 충실하게 출력에 반영했는지에 대한 정도다. 
  • Factuality: 얼마나 world knowledge를 사실대로 반영하는지에 대한 정도다.

 

Contributors to hallucinated in NLG


Hallucination from Data

  • Heuristic data collection: source에 target reference에 대한 내용이 없을 때. 또한 duplicates가 제대로 filtering되지 않았다면 특정 문장 생성을 반복할 수 있다. 
  • Innate divergence: dialogue system같은 경우는 engaginess와 diversity가 중요하고 이를 충족시킬 수 있는 dataset을 사용하기 때문에 NLG 모델은 innate divergence characteristic을 가질 수 있다.

Hallucination from Training and Inference

  • Imperfect representation learning: encoder의 역할은 input sentence를 meaningful representation으로 만들어서 decoder에게 전달하는 것이다. 만약 encoder가 이 역할을 잘 수행하지 못한다면 hallucination이 발생할 수 있다. (출력이 정답으로부터 diverge한다)
  • Erroneous decoding: decoder가 encoder context에 잘못 attention을 수행했을 때. 또한 top-k sampling과 같이 decoding strategy에  randomness가 포함되면서 hallucination이 발생할 수 있다. 
  • Exposure bias: training 때는 target sequence를 decoder의 입력으로 주는 teacher forcing을 하지만 inference 때는 출력 결과를 target sequence로 사용한다. training과 inference 때의 discrepancy로 인해 hallucination이 발생할 수 있다. 특히 target sequence의 길이가 길어질 때 문제가 악화된다. 
  • Parametric knowledge bias: pre-training된 모델을 사용하면, 지금 주어진 input sequence보다 모델의 parameter를 더 우선시하므로 hallucination이 발생할 수 있다. 이에 대한 연구 분야로, 모델이 자신이 hallucinate되었는지 깨달을 수 있는가? 에 대한 연구가 있다.

 

Metrics Measuring Hallucination(평가 지표)


Statistical Metric

가장 간단한 방법으로 n-gram을 사용해서 information overlap과 contradiction을 계산할 수 있다. BLEU는 n-gram precision으로, 실제 P / P로 예측한 것 = TP / TP + FP이다. ROUGE는 n-gram recall으로, 실제 P로 예측한 것 / 실제 P = TP / TP + FN이다. 

  • PARENT(Precision And Recall of Entailed n-grams from the Table): source와 target을 모두 이용해서 hallucination을 측정하는 지표. generated text를 source table과 target text와 모두 비교한다. (table to text task의 경우)
  • PARENT-T: 하나의 input에 대해 여러 개의 target이 존재할 수 있다. 그러나 모든 경우의 target을 고려하는 것은 무리기 때문에 PARENT-T는 오직 source을 reference로 사용해서 평가한다.
  • BVSS(Bag-of-Vectors Sentence Similarity): target만을 reference로 사용해서 generated text와 target sentence 사이의 정보의 양을 비교한다. 

그러나, statistical metric을 사용하면 semantic, syntactic variation을 충분히 고려해서 평가하지 못한다. model-based metric은 더 복잡한 syntactic, semantic variation을 다룰 수 있다. 그러나 model-based metric은 neural model이므로 error propagation에 유의해야 한다. 

Model-based Metric

  • Information Extraction (IE)-based: 이 방식은 source와 generated text 사이의 overlap을 사용한다. generated text에서 검증이 필요한 부분을 결정해야 한다. IE model은 source과 generated text 각각에서 (subject, relation, object)의 튜플 형태로 정보를 추출한다. (information extraction) 이런 식으로 stopwords, conjuctions은 무시하고 verification이 필요한 부분만 source와 generated text에서 각각 뽑아서 비교할 수 있다. 예를 들어 source는 Brad Fitt was born in 1963이고 generated text는 Brad Fitt was born in 1961이라면 각각 튜플이 (Brad Fitt, born-in, 1963), (Brad Fitt, born-in, 1961)로 뽑힐 수 있다. 이를 비교하면 1963 != 1961이므로 hallucination을 detect할 수 있다. 
  • QA-based: 이 방식도 IE-model과 마찬가지로 source와 generated text 사이의 overlap / consistency를 사용한다. 또한 비슷한 답변은 같은 질문으로부터 생성된다는 아이디어에 기반하여 QG(Question Generation) model과 QA(Question Answering) model을 사용한다. content가 있으면 QG model이 여러 개의 (question, answer) 쌍을 만든다. QA model이 generated question에 대한 답을 생성하면 이를 answer과 비교하여 hallucination score를 측정한다. 
  • Natural Language Inference(NLI) Metrics: NLI(Natural Language Inference)는 premise가 있을 때 hypothesis가 참인지, 거짓인지, 중립인지를 판단하는 테스크다. 오직 source knowledge만이 faithful하고 hallucination-free generation하다고 가정한다. premise와 generated text가 entail(참인지), netural to(중립인지), contradict(거짓인지) 판단하고 entailment probability를 계산해 faithfulness / hallucinatory score를 매긴다. 그러나, NLI metrics는 문장 단위로 처리되기 때문에 문장의 어떤 부분이 erroneous한 지 평가하는 데에는 한계가 있다. 
  • faithfulness classification metrics: NLI metrics를 개선시키기 위한 평가 지표다. faithfulness specific dataset은 NLI dataset보다 나을 수 있는데, 그 이유는 NLI dataset의 라벨인 entailment와 neutral은 항상 faithfulness를 의미하지 않기 때문이다. 예를 들어 NLI의 입장에서 Putin is president라는 premise가 있을 때 Putin is U.S president라는 hypothesis는 entailment 또는 neutral이 될 수 있지만, 이는 U.S라는 unsupported information을 담고 있기 때문에 hallucination이라고 볼 수 있다.
  • LM-based metrics: 두 개의 LM을 사용한다. unconditional LM은 오직 target(ground-truth reference)만을 사용해 훈련됐고 conditional LMx는 source와 target data를 모두 이용해서 훈련됐다. 만약 LM의 loss가 LMx보다 더 낮다면 generated token은 hallucinatory라고 판단한다. 전체 token에 대한 hallucinated token의 비율이 hallucination degree를 나타낸다. 

Human Evaluation

  • scoring: generated text에 대해 hallucinated score를 매긴다. 
  • comparing: generated text를 비교한다. 

 

Hallucination Mitigation Methods


Data-Related Methods

  • Building a faithful dataset: noisy dataset이 hallucination을 야기할 수 있으므로 annotator들로 하여금 처음부터 주어진 source에 대해서 clean & faithful target을 만들도록 한다. 또한 target을 깔끔하게 만들도록 revision할 수도 있다.
  • Cleaning data automatically: input에 대해 irrelvant하고 contradictory한 정보를 찾아 없앤다. 위의 metric 중 하나를 이용해 hallucinatory score를 구하고 내림차순으로 순위를 매겨 하위권 generated text를 삭제한다.
  • Information augmentation: 데이터 크기를 크게 하여 모델로 하여금 source에 대한 더 좋은 표현을 배울 수 있도록 한다. retrieved external knowledge 등이 있다. 

Modeling and Inference Methods

  • Model Architecture
    • Encoder: encoder에서 잘못된 semantic interpretation을 하면 hallucination이 일어날 수 있으므로 dual encoder처럼 sequential document encoder와 structured graph encoder 두 개로 이루어져 있어 additional knowledge를 학습할 수 있도록 한다. 
    • Attention: sparse attention, inductive attention -> long-term dependency를 개선하고 pre-established structural information을 따르도록 하여 uninformative attention link를 형성하지 않도록 한다. 
    • Decoder: multi-branch decoders, uncertainty-aware decoder, randomness를 줄이는 방법 등이 소개됐다. 그러나 이런 decoder들을 사용하면 hallucinatory를 줄일 수 있지만 fluent하고 diverse text를 생성하는 데 어렵다는 trade-off가 존재한다. 
  • Training
    • Planning/Sketching: 모델에게 content와 그 순서를 알려줌으로써 모델의 생성을 제한하고 조절하는 방법이다. 이 방법을 사용하면 faithfulness는 개선되지만 diversity는 낮아지므로 잘 조절해야 한다. 
    • Reinforcement Learning(RL): teacher forcing을 하거나 data가 제대로 정제되지 않으면 bias가 생길 수 있다. 따라서 reward model을 줆으로써 LM을 optimize할 수 있다는 아이디어를 사용한다. RL의 목적은 에이전트로 하여금 환경으로부터 주어지는 reward를 최대화하는 optimal policy를 찾게 하는 것이다. 좋은 답에는 큰 보상을 주고 나쁜 답에는 낮은 보상을 주는 consistency를 통해 RL을 이용해 hallucination을 완화할 수 있다. 
    • Multi-task Learning: 하나의 모델이 여러 개의 taks를 동시에 수행한다. target task를 수행하는데 적절한 additional task를 추가함으로써 hallucination problem을 완화할 수 있다. 예를 들어 translation task가 target task라고 하면 word alignment task를 추가할 수 있다. 또한 abstractive summarization을 할 때 faithful entailed result를 내도록 entailment task를 추가할 수 있다. multi-task learning은 데이터 효율성, 과적합 방지, 빠른 학습 등 다양한 이점을 가진다. 
    • Controllable Generation: hallucination이 필수불가결하게 유해한 것은 아니고 약간의 benefit을 가져오므로 적당히 조절해 약간의 hallucination이 포함되도록 control generation할 수 있다. 
    • Post-processing: 이미 생성된 output에 대해 적은 양의 training data를 이용해 hallucination을 제거하는 방법.(사후 처리)

 

Future Directions


Future directions in metrics design

  • fine-grained metrics: intrinsic hallucination과 extrinsic hallucination을 분리해서 평가하는 것이 연구자들에게 더 좋은 insight를 줄 수 있다. 즉 hallucination type과 hallucination이 일어난 횟수를 측정한다. 
  • fact-checking: extrinsic hallucintion에 대해 world-knowledge를 이용해 fact-checking한다. 이 방법에서의 이슈는 어디에서 reliable information을 찾아 generated text에 대한 evidence로 사용할 것이냐다. 대부분 Wikipedia의 정보를 이용하지만 그것이 world knowledge의 전부는 당연히 아니니까 말이다. 만약 web에 존재하는 모든 정보를 이끌어 와 evidence로 사용한다고 해도, 과연 그 정보들이 신뢰할 만하냐는 이슈가 또 있다. 이는 중요한 연구 방향이 될 것이다. fact-checking과 같은 verification task는 확실히 correct evidence가 주어지면 성능이 좋아진다. 그러나, verfication model은 적대적 공격, 부정/부인(negatation), numerical, comparative words에는 취약하기 때문에 factuality를 손상시키지 않는 연구도 진행돼야 한다. 
  • Generalization: 비록 형태는 다양하지만 input과 generated text 사이의 일반적인 관계를 찾아 평가 지표를 만든다. 
  • Incorporation of Human Cognitive Perspective: 사람의 평가가 들어간 지표를 구축한다. 

Future directions in mitigation design

  • General and robust data pre-processing approaches: 데이터 전처리 잘하기. 
  • Hallucinations in numerals: 숫자를 정확히 생성하는 것도 사용자들에게 있어 매우 중요하다. commonsense를 학습 데이터로 학습시키는 것이 숫자를 잘 생성하도록 한다는 연구 결과가 있다. 
  • Extrinsic hallucination mitigation: extrinsic hallucination은 intrinsic hallucination에 비해 완화가 힘들어서 간과되고 있는 경향이 있다. fact-checking과 같은 방법을 사용하는 등 extrinsic hallucination을 줄일 수 있는 방법을 찾는 것은 가치 있는 일이라고 소개한다. 
  • Hallucination in long text: 긴 입력 문장을 잘 encoding하는 방법을 찾기. 또한 output이 길어지면 self-contradiction 문제가 발생할 수 있으므로 이를 해결하는 것도 중요하다. 
  • Reasoning: 모델이 input content를 잘 이해하도록 하려면 적절한 reasoning을 해주는 것이 필요하다. generated text가 input content를 거꾸로 reasoning 시켜보는 것도 좋은 검증 방법이다.

 

Hallucination in LLM


Hallucination Definition in LLMs

기존의 모델들이 input source에 영향을 많이 받았지만, LLM은 이미 방대한 양의 파라미터로 학습됐기 때문에 이 영향을 더 많이 받는다. 따라서 source뿐 아니라 training data로부터도 영향을 받는다. 기존에는 training data가 consistently factual하다는 전제가 있었지만 이 가정이 항상 유효하지는 않다.

Hallucination Metrics for LLMs

대부분의 연구가 extrinsic hallucination을 측정하는 데 집중되어 있다. 만약 hallucination을 확인하는 데 golden reference가 필요하다면 이를 reference-dependent metric이고 그 반대를 reference-free metric이라고 한다. reference-dependent metric은 Wikipedia, news articles 등등을 이용해 LLM을 분석하고 검증한다. reference-free metric은 정답 reference를 이용하지 않으므로 token probability-based uncertainty measures나 self-consistency check를 사용한다.

Hallucination Mitigation in LLMs

  • Data-related methods
    • data for pretraining
    • data for fine-instruction
    • data for reward model training: OpenAI는 extrinsic hallucination에 대해서는 사용자가 사실이 아니라고 한 real-world 데이터와 additional labeled comparison data를 함께 이용해서 reward model을 학습시켰다. intrinsic hallucination에 대해서는 ChatGPT-4가 생성한 synthetic data를 reward model training에 사용했다.
    • Retrieval Augmented Generation(RAG): hallucination 완화 방법으로 인기 있지만, 여러 가지 challenge가 있다. 검색 과정에서 무관하거나 가짜 정보를 구분해야 한다. 또한 충분한 정보가 주어지지 않았을 때는 generation을 거부해야 한다. 
  • Modeling and Inference Methods
    • Safety Fine-Tuning and Reinforcement Learning with Human Feedback(RLHF): fine-tuning에서 RLHF를 사용하자 hallucination rate가 41%에서 21%로 감소한 성과를 보였다. 그러나 이런 alignment(reward model)가 이루어지면 기존에 모델이 습득한 다양한 능력을 잃을 수 있기 때문에(이를 alignment tax 또는 catastrophic forgetting이라고 한다) 두 요소 사이에 균형을 잘 맞추는 것이 필요하다.
    • Model Editing: 모델의 파라미터를 조절한다. 
    • Decoding Methods: 모델의 특정 layer에서 factual knowledge가 처리된다는 점에 기반하여 later layer와 earlier layer를 비교해 factual knowledge probability를 증폭시킬 수 있다. 
    • Chain-of-though and Variants: LLM으로 하여금 final reply를 출력할 때 reasoning을 해보도록 한다. 예를 들어 Chain-of-Verification은 initial response를 생성하고, verfication question을 만들고 이에 답해 최종적으로 verifued response를 출력한다. 
    • Post-processing: generate and refine 전략
    • Ensemble: 여러 개의 모델의 출력을 비교하고 공통된 답을 찾아 factuality를 개선시킬 수 있다.

Future Directions of Hallucination in LLMs

  • Hallucination in Long-tail and Low-resource Domains: dominant하지 않은 low-resource domain에 대해서도 일반화될 수 있는 unified framework가 필요하다. 
  • Estimating the Knowledge Boundary and Expressing the Uncertainty: 비록 LLM이 방대한 양의 데이터로 훈련되지만 모든 걸 아우를 수는 없다. 따라서 모델이 모르는 건 모른다고 하는 것이 중요하고, 이렇게 하기 위해서는 LLM의 knowledge boundary를 정확하게 알고 정의할 수 있어야 한다.
  • Minimizing the Alignment Tax During Hallucination Mitigation: 여러 연구가 ChatGPT와 GPT-4의 성능이 safety fine-tuning을 함에 따라 저하되고 있다고(forgetting) 밝히고, 이 현상을 alignment tax라고 한다. LLM을 훈련하고 개선시키는 과정에서 발생하는 비용을 줄이는 것이 중요하다.