Solr相似度算法二:Okapi BM25
In information retrieval, Okapi 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. Robertson, Karen 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:
Solr相似度算法二:Okapi BM25的更多相关文章
- Solr相似度算法二:BM25Similarity
BM25算法的全称是 Okapi BM25,是一种二元独立模型的扩展,也可以用来做搜索的相关度排序. Sphinx的默认相关性算法就是用的BM25.Lucene4.0之后也可以选择使用BM25算法(默 ...
- Solr相似度算法三:DRFSimilarity框架介绍
地址:http://terrier.org/docs/v3.5/dfr_description.html The Divergence from Randomness (DFR) paradigm i ...
- elasticsearch算法之词项相似度算法(二)
六.莱文斯坦编辑距离 前边的几种距离计算方法都是针对相同长度的词项,莱文斯坦编辑距离可以计算两个长度不同的单词之间的距离:莱文斯坦编辑距离是通过添加.删除.或者将一个字符替换为另外一个字符所需的最小编 ...
- Solr相似度算法四:IBSimilarity
Information based:它与Diveragence from randomness模型非常相似.与DFR相似度模型类似,据说该模型也适用于自然语言类的文本.
- Solr相似度算法三:DRFSimilarity
该Similarity 实现了 divergence from randomness (偏离随机性)框架,这是一种基于同名概率模型的相似度模型. 该 similarity有以下配置选项: basic ...
- Okapi BM25算法
引言 Okapi BM25,一般简称 BM25 算法,在 20 世纪 70 年代到 80 年代,由英国一批信息检索领域的计算机科学家发明.这里的 BM 是"最佳匹配"(Best M ...
- ES BM25 TF-IDF相似度算法设置——
Pluggable Similarity Algorithms Before we move on from relevance and scoring, we will finish this ch ...
- TensorFlow 入门之手写识别(MNIST) softmax算法 二
TensorFlow 入门之手写识别(MNIST) softmax算法 二 MNIST Fly softmax回归 softmax回归算法 TensorFlow实现softmax softmax回归算 ...
- elasticsearch算法之词项相似度算法(一)
一.词项相似度 elasticsearch支持拼写纠错,其建议词的获取就需要进行词项相似度的计算:今天我们来通过不同的距离算法来学习一下词项相似度算法: 二.数据准备 计算词项相似度,就需要首先将词项 ...
随机推荐
- webkit内核的浏览器为什么removeAttribute('style')会失效?
做了一些研究,应该算是理清了问题. 首先,我们在这里常说的「属性」(attributes)其实分为两种:内容属性(content attributes)以及 IDL 属性(IDL attributes ...
- Django的学习之路
Django基础 Django框架基础 http协议及web框架 Django-2的路由层(URLconf) Django的视图层 Django框架之第三篇模板语法(重要!!!) Django框架之模 ...
- Python实践练习:将一个文件夹备份到一个 ZIP 文件
题目 项目要求:假定你正在做一个项目,它的文件保存在 C:\AlsPythonBook 文件夹中.你担心工作会丢失, 所以希望为整个文件夹创建一个 ZIP 文件, 作为"快照" . ...
- 智能指针--C++
智能指针(一):STL auto_ptr实现原理 智能指针实际上是一个类(class),里面封装了一个指针.它的用处是啥呢? 指针与内存 说到指针自然涉及到内存.我们如果是在堆栈(stack)中分配了 ...
- delphi 工具
http://blog.csdn.net/maxwoods/article/category/1285993
- 解决MongoDB分页查询之count查询慢的问题
一.概述 问题描述:在项目中优化动态查询分页接口时,发现count查询很慢(数据量大概30万),那如何解决这个问题呢? 解决方法:添加索引,多个查询条件可以添加复合索引 二.测试对比 1. 未加索引时 ...
- Redis AOF文件
[Redis AOF文件] 1.关于AOF AOF 持久化记录服务器执行的所有写操作命令,并在服务器启动时,通过重新执行这些命令来还原数据集. AOF 文件中的命令全部以 Redis 协议的格式来保存 ...
- Website蝴蝶结构
[Website蝴蝶结构] 网页的其正向链接连结在一起表现为一种蝴蝶结结构. 1.蝴蝶结中部(SCC, Strongly Connected Componnet) 这种网页彼此相连. 2.蝴蝶结左部( ...
- js 滚动条滚动到底部触发事件
一.前言 在开发项目时,常常需要展示大量数据.如果全部显示出来,数据相对少时,看不出来什么不同,如果数据很多时,一次请求全部显示,这就相当可怕了. 面对这种问题,PC里使用了分页效果,将数据分成一页页 ...
- JS如何判断浏览器类型,如何模拟浏览器类型(模拟微信浏览器)
一.前言 在编写前端代码时,为了页面兼容性,我们往往需要考虑不同的浏览器类型 而这就需要在前端代码中进行识别和区分 接下来就来谈谈对浏览器类型的识别 二.正文 (一).查看浏览器类型的核心代码 var ...





