RAG 评测常用断言。
所有函数都支持两类输入:
%CMDCEval.Context{}: Runnerassert/3传入的真实运行上下文。- map fixture: 离线测试可直接传
%{expected_chunk_ids: ..., results: ...}。
Summary
Functions
断言输出至少包含指定数量的 citation。
断言 correctness 指标达到阈值。
断言 faithfulness 指标达到阈值。
断言回答有 grounding。
断言 citation / source 没有越权。
断言 top-k 检索召回率达到阈值。
Functions
@spec contains_citation(CMDCEval.Context.t() | map(), non_neg_integer()) :: boolean()
断言输出至少包含指定数量的 citation。
@spec correctness_min(CMDCEval.Context.t() | map(), float()) :: boolean()
断言 correctness 指标达到阈值。
@spec faithfulness_min(CMDCEval.Context.t() | map(), float()) :: boolean()
断言 faithfulness 指标达到阈值。
@spec grounded_answer(CMDCEval.Context.t() | map(), float()) :: boolean()
断言回答有 grounding。
若上下文含 grounding_score / grounding.score / faithfulness 等指标,按阈值比较;
否则退化为 citation 存在性检查。
@spec no_unauthorized_source(CMDCEval.Context.t() | map(), map() | [String.t()] | nil) :: boolean()
断言 citation / source 没有越权。
allowed 可传:
%{collections: [...], source_uris: [...], document_ids: [...]}- 字符串列表,等同 allowed collections。
nil,此时会从 context metadata 的allowed_collections读取。
@spec recall_at_k(CMDCEval.Context.t() | map(), pos_integer(), float()) :: boolean()
断言 top-k 检索召回率达到阈值。