gpt4 book ai didi

c# - 为什么 Lucene 提升查询的分数低于相同的普通查询?

转载 作者:太空宇宙 更新时间:2023-11-03 12:37:46 25 4
gpt4 key购买 nike

我在 lucene 中测试 boost 运算符并发现了奇怪的行为

示例

  1. query1 = "红狐狸"
  2. query2 = "red^1.2 fox"

当我针对文本测试查询时:

"wonderful red fox"

查询 2 的分数低于查询 1。但我希望 query2 应该获胜。

以下查询说明

解释query1

{0,4339554 = (MATCH) sum of:
0,2169777 = (MATCH) weight(content:fox in 0), product of:
0,7071068 = queryWeight(content:fox), product of:
0,3068528 = idf(docFreq=1, maxDocs=1)
2,304384 = queryNorm
0,3068528 = (MATCH) fieldWeight(content:fox in 0), product of:
1 = tf(termFreq(content:fox)=1)
0,3068528 = idf(docFreq=1, maxDocs=1)
1 = fieldNorm(field=content, doc=0)
0,2169777 = (MATCH) weight(content:red in 0), product of:
0,7071068 = queryWeight(content:red), product of:
0,3068528 = idf(docFreq=1, maxDocs=1)
2,304384 = queryNorm
0,3068528 = (MATCH) fieldWeight(content:red in 0), product of:
1 = tf(termFreq(content:red)=1)
0,3068528 = idf(docFreq=1, maxDocs=1)
1 = fieldNorm(field=content, doc=0)
}

解释query2

{0,4313012 = (MATCH) sum of:
0,2396118 = (MATCH) weight(content:fox^1.25 in 0), product of:
0,7808688 = queryWeight(content:fox^1.25), product of:
1,25 = boost
0,3068528 = idf(docFreq=1, maxDocs=1)
2,035813 = queryNorm
0,3068528 = (MATCH) fieldWeight(content:fox in 0), product of:
1 = tf(termFreq(content:fox)=1)
0,3068528 = idf(docFreq=1, maxDocs=1)
1 = fieldNorm(field=content, doc=0)
0,1916894 = (MATCH) weight(content:red in 0), product of:
0,6246951 = queryWeight(content:red), product of:
0,3068528 = idf(docFreq=1, maxDocs=1)
2,035813 = queryNorm
0,3068528 = (MATCH) fieldWeight(content:red in 0), product of:
1 = tf(termFreq(content:red)=1)
0,3068528 = idf(docFreq=1, maxDocs=1)
1 = fieldNorm(field=content, doc=0)
}

我想知道为什么提升查询的分数低于普通查询?

最佳答案

这是由于查询规范。评分算法的这一特性试图使一个查询与下一个查询的分数大致可比。

计算如下:

queryNorm = 1 / sumOfSquaredWeights½

地点:

sumOfSquaredWeights = query boost2 · ∑ ( idf · term boost )2

如果您从解释中删除该因素,只需将最终分数除以查询范数,您就会发现第二个查询确实获得了更高的分数:

  • query1 --> .4339554/2.304384 = 0.1883

  • query2 --> .4313012/2.035813 = 0.2119

但更重要的一点是:您不应该过多地阅读比较一个查询与下一个查询的分数。分数仅与生成它们的查询真正相关。您可以在解释中看到,提升项为分数贡献了更大的相对权重,这是所有提升的真正目的。

关于c# - 为什么 Lucene 提升查询的分数低于相同的普通查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40250210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com