Skip to content

RAG 评估

如何借助 Potato,通过人工标注评估检索增强生成(RAG),包括检索相关性、答案的 faithfulness 与引用跨度。

检索增强生成(retrieval-augmented generation,RAG)先检索文档,再据此生成答案。评估 RAG 意味着分别判断两件事:它是否检索到了正确的文档,以及答案是否真正被这些文档所支撑 把两者混为一谈,会掩盖系统究竟在哪里出错。

背景知识参见检索增强生成

需要标注的三件事

  1. 检索相关性:对每一份检索到的文档,它是否与查询相关?
  2. 答案 faithfulness:生成的答案是否扎根于检索到的文档,没有缺乏依据的论断?
  3. 引用准确性:答案中的论断是否真能追溯到所引用的来源?

在 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 上的一致性;它是三者中最主观的一项。

延伸阅读