Solr相似度算法二:Okapi BM25

地址:https://en.wikipedia.org/wiki/Okapi_BM25

In information retrievalOkapi BM25 (BM stands for Best Matching) is a ranking function used by search engines to rank matching documents according to their relevance to a given search query. It is based on the probabilistic retrieval framework developed in the 1970s and 1980s byStephen E. RobertsonKaren Spärck Jones, and others.

The name of the actual ranking function is BM25. To set the right context, however, it usually referred to as "Okapi BM25", since the Okapi information retrieval system, implemented at London‘s City University in the 1980s and 1990s, was the first system to implement this function.

BM25, and its newer variants, e.g. BM25F (a version of BM25 that can take document structure and anchor text into account), represent state-of-the-art TF-IDF-like retrieval functions used in document retrieval, such as web search.

The ranking function[edit]

BM25 is a bag-of-words retrieval function that ranks a set of documents based on the query terms appearing in each document, regardless of the inter-relationship between the query terms within a document (e.g., their relative proximity). It is not a single function, but actually a whole family of scoring functions, with slightly different components and parameters. One of the most prominent instantiations of the function is as follows.

Given a query , containing keywords , the BM25 score of a document  is:

where  is ‘s term frequency in the document  is the length of the document  in words, and  is the average document length in the text collection from which documents are drawn.  and  are free parameters, usually chosen, in absence of an advanced optimization, as  and .[1]  is the IDF (inverse document frequency) weight of the query term . It is usually computed as:

where  is the total number of documents in the collection, and  is the number of documents containing .

There are several interpretations for IDF and slight variations on its formula. In the original BM25 derivation, the IDF component is derived from the Binary Independence Model.

Please note that the above formula for IDF shows potentially major drawbacks when using it for terms appearing in more than half of the corpus documents. These terms‘ IDF is negative, so for any two almost-identical documents, one which contains the term and one which does not contain it, the latter will possibly get a larger score. This means that terms appearing in more than half of the corpus will provide negative contributions to the final document score. This is often an undesirable behavior, so many real-world applications would deal with this IDF formula in a different way:

  • Each summand can be given a floor of 0, to trim out common terms;
  • The IDF function can be given a floor of a constant , to avoid common terms being ignored at all;
  • The IDF function can be replaced with a similarly shaped one which is non-negative, or strictly positive to avoid terms being ignored at all.

IDF information theoretic interpretation[edit]

Here is an interpretation from information theory. Suppose a query term  appears in  documents. Then a randomly picked document  will contain the term with probability  (where  is again the cardinality of the set of documents in the collection). Therefore, the informationcontent of the message " contains " is:

Now suppose we have two query terms  and . If the two terms occur in documents entirely independently of each other, then the probability of seeing both  and  in a randomly picked document  is:

and the information content of such an event is:

With a small variation, this is exactly what is expressed by the IDF component of BM25.

Modifications[edit]

  • At the extreme values of the coefficient  BM25 turns into ranking functions known as BM11 (for ) and BM15 (for ).[2]
  • BM25F[3] is a modification of BM25 in which the document is considered to be composed from several fields (such as headlines, main text, anchor text) with possibly different degrees of importance.
  • BM25+[4] is an extension of BM25. BM25+ was developed to address one deficiency of the standard BM25 in which the component of term frequency normalization by document length is not properly lower-bounded; as a result of this deficiency, long documents which do match the query term can often be scored unfairly by BM25 as having a similar relevancy to shorter documents that do not contain the query term at all. The scoring formula of BM25+ only has one additional free parameter  (a default value is  in absence of a training data) as compared with BM25:
时间: 2024-10-28 16:27:17

Solr相似度算法二:Okapi BM25的相关文章

Solr相似度算法二:BM25Similarity

BM25算法的全称是 Okapi BM25,是一种二元独立模型的扩展,也可以用来做搜索的相关度排序. Sphinx的默认相关性算法就是用的BM25.Lucene4.0之后也可以选择使用BM25算法(默认是TF-IDF).如果你使用的solr,只需要修改schema.xml,加入下面这行就可以 <similarity class="solr.BM25Similarity"/> BM25也是基于词频的算分公式,分词对它的算分结果也很重要 IDF公式 f(qi,D):就是词频 |

Solr相似度算法三:DRFSimilarity框架介绍

地址:http://terrier.org/docs/v3.5/dfr_description.html The Divergence from Randomness (DFR) paradigm is a generalisation of one of the very first models of Information Retrieval, Harter's 2-Poisson indexing-model [1]. The 2-Poisson model is based on th

Solr相似度算法三:DRFSimilarity

该Similarity 实现了  divergence from randomness (偏离随机性)框架,这是一种基于同名概率模型的相似度模型. 该 similarity有以下配置选项: basic_model – 可能的值: be, d, g, if, in, ine 和 p. after_effect – 可能的值: no, b 和 l. normalization – 可能的值: no, h1, h2, h3 和 z.所有选项除了第一个,都需要一个标准值.

基于word分词提供的文本相似度算法来实现通用的网页相似度检测

实现代码:基于word分词提供的文本相似度算法来实现通用的网页相似度检测 运行结果: 检查的博文数:128 1.检查博文:192本软件著作用词分析(五)用词最复杂99级,相似度分值:Simple=0.968589 Cosine=0.955598 EditDistance=0.916884 EuclideanDistance=0.00825 ManhattanDistance=0.001209 Jaccard=0.859838 JaroDistance=0.824469 JaroWinklerDi

相似度算法之余弦相似度

转自:http://blog.csdn.net/u012160689/article/details/15341303 余弦距离,也称为余弦相似度,是用向量空间中两个向量夹角的余弦值作为衡量两个个体间差异的大小的度量. 余弦值越接近1,就表明夹角越接近0度,也就是两个向量越相似,这就叫"余弦相似性". 上图两个向量a,b的夹角很小可以说a向量和b向量有很高的的相似性,极端情况下,a和b向量完全重合.如下图: 如上图二:可以认为a和b向量是相等的,也即a,b向量代表的文本是完全相似的,或

深入学习图像处理——图像相似度算法

最近一段时间学习并做的都是对图像进行处理,其实自己也是新手,各种尝试,所以我这个门外汉想总结一下自己学习的东西,图像处理的流程.但是动起笔来想总结,一下却不知道自己要写什么,那就把自己做过的相似图片搜索的流程整理一下,想到什么说什么吧. 首先在进行图片灰度化处理之前,我觉得有必要了解一下为什么要进行灰度化处理. 图像灰度化的目的是什么? 将彩色图像转化为灰度图像的过程是图像的灰度化处理.彩色图像中的每个像素的颜色由R,G,B三个分量决定,而每个分量有255中值可取,这样一个像素点可以有1600多

转:文本相似度算法

文本相似度算法 原文出自:http://www.cnblogs.com/liangxiaxu/archive/2012/05/05/2484972.html 1.信息检索中的重要发明TF-IDF 1.1TF Term frequency即关键词词频,是指一篇文章中关键词出现的频率,比如在一篇M个词的文章中有N个该关键词,则 (公式1.1-1) 为该关键词在这篇文章中的词频. 1.2IDF Inverse document frequency指逆向文本频率,是用于衡量关键词权重的指数,由公式 (公

集成Nutch/Hbase/Solr构建搜索引擎之二:内容分析

请先参见"集成Nutch/Hbase/Solr构建搜索引擎之一:安装及运行",搭建测试环境 http://blog.csdn.net/jediael_lu/article/details/37329731 一.被索引的域 Schema.xml 在使用solr对Nutch抓取到的网页进行索引时,schema.xml被改变成以下内容. 文件中指定了哪些域被索引.存储等内容. <?xml version="1.0" encoding="UTF-8"

数据结构与算法二

1.课程安排表: 1. 线性表 2. 字符串 3. 栈和队列 4.树 5.查找 6.排序 7.暴力枚举法 8.广度优先搜索 9.深度优先搜索 10.分治 11.贪心 12.动态规划 13.图 14.数学方法与常见模型 15.大整数运算 16. 基础功能 2.   编程技巧: 1.把较大的数组放在main 函数(全局变量)外,作为全局变量,这样可以防止栈溢出,因为栈的大小是有限制的.GCC (C编译器) 段错误 2.如果能够预估栈,队列的上限,则不要用stack,queue,使用数组来模拟,这样速