class RetrievalPrecision(k=1, distance_metric_name: ~quaterion.distances.Distance = Distance.COSINE, reduce_func: ~typing.Callable | None = <built-in method mean of type object>)[source]¶
-
基类:
PairMetric
计算基于对的数据集的检索精度@k
参数:
- k – 在其中搜索相关文档的数量
distance_metric_name – 用于计算距离或相似性矩阵的距离度量名称。可用名称可在
Distance
中找到。reduce_func – 用于聚合计算度量的函数。例如 torch.mean、torch.max 等。如果您想捕获一些自定义参数,functools.partial 可能会很有用。
示例
假设 k 为 4。那么只有 4 个文档被检索作为查询响应。其中只有 2 个是相关的,分数将是 2/4 = 0.5。
注意