定性的エラー分類学: ハルシネーション・形式違反・過剰拒絶
Agent支援エンジニアリングチェック
前提条件
第71日定量的評価指標およびエラー分析の基礎。
学習目標
LLMの失敗事例を4系統のエラー分類学(内部/外部ハルシネーション、スキーマ形式違反、過剰拒絶、推論破綻)に分類し、根本原因を特定する。
手順
1. Jiら(2023)NLGハルシネーション分類の学習: プロンプト内の前提・文脈に矛盾する「内部ハルシネーション(Intrinsic)」と、入力に存在しない事実無根の情報を捏造する「外部ハルシネーション(Extrinsic)」を明確に区別する。
2. スキーマおよび形式違反の体系化: JSON構文エラー、必須キーの欠落、Markdownコードブロック(```json)の漏洩、トークン上限による途中切断。
3. 安全性の過剰拒絶(Röttger et al. 2023 XSTest)の分析: 機微な単語を含む無害な要求(例: 「Linuxプロセスの強制終了方法」)に対して安全フィルターが誤検知して回答を拒絶する現象。
4. 推論連鎖の破綻: 算術計算ミス、前提の誤解、循環論法。
5. 要因帰属フローの構築: 事前学習データの不足、指示チューニングの混乱、またはサンプリング温度の揺らぎのいずれに起因するかを切り分ける。
演習と予測記録
モデルの出力レコードを入力とし、エラーを適切な分類学バケットに仕分け、対応するエンジニアリング是正策を提示するPython関数 categorize_failure を作成してください。
拒絶定型文の有無、JSONデコード検証、文脈との矛盾フラグを順次判定します。
import json
def categorize_failure(record):
text = record['generation'].lower()
refusal_cues = ['cannot fulfill', 'as an ai', 'i am unable to', 'against my safety policies']
if any(cue in text for cue in refusal_cues):
return {'category': 'safety_over_refusal', 'intervention': 'Curate benign negative contrast pairs in SFT / relax safety trigger threshold'}
if record.get('expected_schema'):
try:
parsed = json.loads(record['generation'].strip())
for req_key in record['expected_schema'].get('required', []):
if req_key not in parsed:
return {'category': 'formatting_violation', 'intervention': 'Add schema grammar constraints or JSON-mode logit masking'}
except json.JSONDecodeError:
return {'category': 'formatting_violation', 'intervention': 'Enforce strict JSON grammar during decoding / add raw JSON demonstrations'}
context = record.get('context', '').lower()
if context and record.get('conflict_flag'):
return {'category': 'intrinsic_hallucination', 'intervention': 'Ground prompt with strict source citation constraint / adjust attention mask'}
elif record.get('unverifiable_flag'):
return {'category': 'extrinsic_hallucination', 'intervention': 'Integrate retrieval-augmented generation (RAG) or calibration refusal'}
return {'category': 'reasoning_breakdown', 'intervention': 'Incorporate Chain-of-Thought demonstrations / self-consistency decoding'}
任意のモデル出力エラーを4大分類に的確に分類し、具体的なエンジニアリング改善策を導出できること。
公式ソースリソースと権利証跡
Survey of Hallucination in Natural Language Generation
該当セクション・タイムスタンプ: Section 2.1 Categorization (intrinsic and extrinsic hallucination)
検証バージョンと日付: ACM Computing Surveys 2023 / arXiv:2202.03629v4 (Verified: 2026-10-30)
Primary taxonomy of hallucinations in NLG, formalizing the critical distinction between intrinsic hallucinations (contradicting source input context) and extrinsic hallucinations (asserting unverifiable external facts).
Natural language generation, factuality evaluation, intrinsic vs extrinsic hallucination.
The intrinsic/extrinsic taxonomy, fact-verification prompt protocols, and error attribution workflows are completely developed in lesson modules.
比較対象候補リソースと選定評価 (2)
Focuses on abstractive summarization faithfulness; Ji et al. provides the overarching taxonomy across dialogue, QA, and generation.
Follow-up survey on LLMs; Ji et al. sets out the taxonomy distinctions utilized across evaluation literature.
XSTest: A Test Suite for Identifying Exaggerated Safety Behaviors in Large Language Models
該当セクション・タイムスタンプ: Section 4.4 Results on Unsafe Prompts and Appendix D Details on Automated Evaluation
検証バージョンと日付: NAACL 2024 / arXiv:2308.01263v2 (Verified: 2026-10-30)
Groundbreaking benchmark identifying exaggerated safety behaviors and false-positive refusals, formalizing test suites that contrast real unsafe prompts against benign prompts with sensitive lexical overlap.
Safety alignment, refusal classifiers, false-positive safety evaluation.
The 10 refusal prompt categories, refusal detection regex/heuristics, and over-refusal error quantification are implemented in lesson exercises.
比較対象候補リソースと選定評価 (2)
Shows that zero-shot chain-of-thought increases biased and toxic outputs on harmful prompts; XSTest provides an explicit, quantitative evaluation dataset for measuring unnecessary refusal rates.
Safety fine-tuning methodology; XSTest isolates the diagnostic metric for detecting exaggerated refusal side effects.