00:00:00

Share Your Feedback 🏝️

Contextual Hallucinations

Contextual Hallucinations

MinWoo(Daniel) Park | Tech Blog

Read more
Previous: Rank RAG Next: vLMs are blind

Contextual Hallucinations

  • Related Project: Private
  • Category: Paper Review
  • Date: 2024-07-09

Lookback Lens: Detecting and Mitigating Contextual Hallucinations in Large Language Models Using Only Attention Maps

  • url: https://arxiv.org/abs/2407.07071
  • pdf: https://arxiv.org/pdf/2407.07071
  • html: https://arxiv.org/html/2407.07071v1
  • abstract: When asked to summarize articles or answer questions given a passage, large language models (LLMs) can hallucinate details and respond with unsubstantiated answers that are inaccurate with respect to the input context. This paper describes a simple approach for detecting such contextual hallucinations. We hypothesize that contextual hallucinations are related to the extent to which an LLM attends to information in the provided context versus its own generations. Based on this intuition, we propose a simple hallucination detection model whose input features are given by the ratio of attention weights on the context versus newly generated tokens (for each attention head). We find that a linear classifier based on these lookback ratio features is as effective as a richer detector that utilizes the entire hidden states of an LLM or a text-based entailment model. The lookback ratio-based detector – Lookback Lens – is found to transfer across tasks and even models, allowing a detector that is trained on a 7B model to be applied (without retraining) to a larger 13B model. We further apply this detector to mitigate contextual hallucinations, and find that a simple classifier-guided decoding approach is able to reduce the amount of hallucination, for example by 9.6% in the XSum summarization task.

  1. (Contextual Hallucinations 감지 및 완화) 주목 비율을 이용해 Contextual Hallucinations을 감지하고 완화하는 Lookback Lens 기법 소개
  2. (다양한 데이터셋과 벤치마크 활용) CNN/DM과 Natural Questions 데이터셋 사용하여 실험적 검증
  3. (모델 간 전이 가능성 탐구) 다양한 모델 간에 Lookback Lens 적용하여 효과성과 일반화 가능성 평가

1. 서론

언어 모델의 유용성에도 불구하고, 사실과 다르거나 맥락과 무관한 내용을 생성하는 경향은 큰 도전이 됩니다. 특히, 입력된 문맥이 정확함에도 불구하고 모델이 정확한 출력을 생성하지 못하는 ‘Contextual Hallucinations’ 현상을 집중적으로 다룹니다. 이런 문제를 해결하기 위해 어텐션 맵에서 신호를 활용하는 새로운 방법을 제안합니다. Lookback Lens라는 단순한 선형 분류기를 통해 Contextual Hallucinations을 감지하고 완화할 수 있는 방법을 소개하며, 이는 다른 복잡한 특징 기반 감지기와 비교하여 우수한 성능을 보입니다.


2. Contextual Hallucinations 감지

2.1 Lookback Lens

트랜스포머 모델의 주의 분포를 기반으로 Lookback Ratio(LR)를 계산하여 Contextual Hallucinations을 감지합니다. 주어진 문맥 토큰 \(X = \{x_1, x_2, \ldots, x_N\}\) 과 새로 생성된 토큰 \(Y = \{y_1, y_2, \ldots, y_{t-1}\}\)에 대해 각 시간 단계 \(t\)에서 각 헤드 \(h\)에 대한 attention weights 비율을 계산합니다.

\[LR_{t, l, h} = \frac{A_{t, l, h}(\text{context})}{A_{t, l, h}(\text{context}) + A_{t, l, h}(\text{new})}\]

\(A_{t, l, h}(\text{context})\)와 \(A_{t, l, h}(\text{new})\)는 각각 문맥 토큰 \(X\)와 새 토큰 \(Y\)에 할당된 소프트맥스 된 attention weights

이 비율을 이용해 로지스틱 회귀 분류기 \(\mathcal{F}\)를 훈련하여 문장이 사실인지 환각인지를 예측합니다.

Classifier 모델로 Hallucination 여부 예측

2.2 실험 설정

LLaMA-2-7B-Chat 모델을 사용하여 CNN/DM 및 Natural Questions 데이터셋에서 1,000개와 2,655개의 요약 및 질문응답 예제를 생성하여 훈련 데이터를 준비합니다. 이 데이터를 사용하여 Lookback Lens를 훈련하고, 생성된 요약에서 약 49.6%, 질문응답에서 67.8%가 정확함을 확인합니다.


3. Contextual Hallucinations 완화

Lookback Lens Guided Decoding 방법을 도입하여 생성 과정에서 문맥에 더 정확한 출력을 유도합니다. 이 방법은 문맥과 부분적으로 생성된 텍스트를 기반으로 후보 청크들을 평가하고, 가장 적합한 청크를 선택하는 방식으로 진행됩니다. 이 접근 방식은 XSum 요약 작업에서 환각을 9.6% 감소시키는 효과를 보였으며, 다른 벤치마크와의 교차 작업 전이에서도 일관된 성능을 보여줍니다.


4. 모델 간 전이

Lookback Lens를 LLaMA-2-7B-Chat 모델에서 훈련시킨 후 LLaMA-2-13B-Chat 모델로 전이하는 실험을 수행합니다. 이는 주의 패턴의 유사성을 기반으로 하며, 모델 간, 작업 간 전이 가능성을 탐구합니다. 전이 학습 결과는 여전히 높은 AUROC 점수를 유지하며, 특히 같은 작업 내에서의 전이 성능이 뛰어납니다.

이 연구는 Contextual Hallucinations 감지와 완화에 대한 새로운 접근 방식을 제안하고, 다양한 데이터셋과 벤치마크를 통해 그 효과성을 입증하며, 다른 모델로의 일반화 가능성을 탐구합니다.

Previous: Rank RAG Next: vLMs are blind

post contain ""

    No matching posts found containing ""