RAG 評估
如何藉助 Potato,通過人工標註評估檢索增強生成(RAG),包括檢索相關性、答案的 faithfulness 與引用跨度。
檢索增強生成(retrieval-augmented generation,RAG)先檢索文件,再據此生成答案。評估 RAG 意味著分別判斷兩件事:它是否檢索到了正確的文件,以及答案是否真正被這些文件所支撐。 把兩者混為一談,會掩蓋系統究竟在哪裡出錯。
背景知識參見檢索增強生成。
需要標註的三件事
- 檢索相關性:對每一份檢索到的文件,它是否與查詢相關?
- 答案 faithfulness:生成的答案是否紮根於檢索到的文件,沒有缺乏依據的論斷?
- 引用準確性:答案中的論斷是否真能追溯到所引用的來源?
在 Potato 中進行設定
把三個 scheme 組合在同一屏上:對每份文件評分、為 faithfulness 評分,並在答案中標出有問題的跨度:
yaml
annotation_schemes:
- annotation_type: multirate
name: retrieval_relevance
description: "Rate the relevance of each retrieved document to the query."
labels: ["Irrelevant", "Somewhat", "Relevant", "Highly relevant"]
- annotation_type: likert
name: faithfulness
description: "Is the answer faithful to the retrieved documents?"
size: 5
min_label: "Many unsupported claims"
max_label: "Fully grounded"
- annotation_type: span
name: problems
description: "Highlight any unsupported or incorrect claim in the answer."
labels: [unsupported_claim, contradicted, hallucination]multirate 在同一量表上一次性為多份文件評分;span scheme 則精確標出答案在何處偏離了它的來源。參見檢測幻覺。
為什麼要把檢索與生成分開
RAG 系統可能以兩種方式失敗:檢索到了糟糕的上下文(檢索問題),或忽視了良好的上下文(生成問題)。分別打分能告訴你該修哪一半。單憑一個 faithfulness 分數做不到這一點。
品質方面的考量
- 把查詢、文件和答案一併呈現給標註者,因為離開來源就無法判斷 faithfulness。
- "相關"需要一個定義:是與查詢相關,還是確實被答案所採用?請提前確定。
- 跟蹤 faithfulness 上的一致性;它是三者中最主觀的一項。