﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-程序描绘人生-随笔分类-搜索引擎</title><link>http://www.cppblog.com/humanchao/category/20276.html</link><description>知识改变命运，学习成就未来。</description><language>zh-cn</language><lastBuildDate>Wed, 28 Feb 2018 18:53:27 GMT</lastBuildDate><pubDate>Wed, 28 Feb 2018 18:53:27 GMT</pubDate><ttl>60</ttl><item><title>深入浅出LSH</title><link>http://www.cppblog.com/humanchao/archive/2018/02/24/215521.html</link><dc:creator>胡满超</dc:creator><author>胡满超</author><pubDate>Sat, 24 Feb 2018 05:10:00 GMT</pubDate><guid>http://www.cppblog.com/humanchao/archive/2018/02/24/215521.html</guid><wfw:comment>http://www.cppblog.com/humanchao/comments/215521.html</wfw:comment><comments>http://www.cppblog.com/humanchao/archive/2018/02/24/215521.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/humanchao/comments/commentRss/215521.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/humanchao/services/trackbacks/215521.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 通过这篇文章我们主要回答以下几个问题：  &nbsp;  1.&nbsp;&nbsp;&nbsp; LSH解决问题的背景，即以图片相似性搜索为例，如何解决在海量数据中进行相似性查找？  2.&nbsp;&nbsp;&nbsp; 图像相似性查找的连带问题：相似性度量，特征提取；  3.&nbsp;&nbsp;&nbsp; LSH的数学分析，即局部敏感HASH函数的数学原理，通过与、或构造提升查找的查...&nbsp;&nbsp;<a href='http://www.cppblog.com/humanchao/archive/2018/02/24/215521.html'>阅读全文</a><img src ="http://www.cppblog.com/humanchao/aggbug/215521.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/humanchao/" target="_blank">胡满超</a> 2018-02-24 13:10 <a href="http://www.cppblog.com/humanchao/archive/2018/02/24/215521.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>这就是搜索引擎－笔试6-链接分析</title><link>http://www.cppblog.com/humanchao/archive/2013/11/12/204224.html</link><dc:creator>胡满超</dc:creator><author>胡满超</author><pubDate>Tue, 12 Nov 2013 06:06:00 GMT</pubDate><guid>http://www.cppblog.com/humanchao/archive/2013/11/12/204224.html</guid><wfw:comment>http://www.cppblog.com/humanchao/comments/204224.html</wfw:comment><comments>http://www.cppblog.com/humanchao/archive/2013/11/12/204224.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/humanchao/comments/commentRss/204224.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/humanchao/services/trackbacks/204224.html</trackback:ping><description><![CDATA[<div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="text-align: -webkit-auto;">搜索引擎在查找时主要考虑两方面因素：网页和查询的相关性、网页的重要性</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">链接分析解决网页重要性的问题</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">网页中最重要的三个要素，出链（Out Link），入链（In Links），锚文字</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>链接分析算法</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、随机游走模型：对直接跳转和远程跳转两种用户浏览行为进行抽象的概念模型，用户从当前网页到达某网页的概率</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、子集传播模型：把网页划分为若干子集，给予子集内网页初始权值，根据链接关系，按照一定方式将权值传递到其他网页</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">不同子集传播模型在如下方面存在差异：</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1）如何定义特殊子集合</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2）在确定了特殊子集合所具有的性质后，如果对子集内的网页赋初始<span style="font-size: medium; ">值</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">3）从特殊子集合将其分值传播到其他网页时，采取何种传播方式</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>PageRank算法</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">除了考虑到入链数量的影响，还参考了网页质量因素</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>数量假设</strong>：在Web图模型中，如果一个页面节点接收到的其他网页指向的入链数量越多，那么这个页面越重要</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>质量假设</strong>：质量高的页面会通过链接向其他页面传递更多的权重</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">算法开始赋予每个网页相同的重要性得分，通过迭代递归计算来更新每个页面节点的PageRank得分，直到稳定为止</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">远程跳转：解决链接陷阱的通用方式，在网页向外传递分值时，不限于向出链所指网页传递，也可以以一定的概率向任意其他网页跳转（虚拟边，权值通过虚拟边向外传递）</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>HITS(Hypertext Induced Topic Selection)算法</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong><br /></strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>Authority页面</strong>：某个领域或者某个话题相关的高质量网页</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>Hub页面</strong>：指向很多Authority页面</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>基本假设1</strong>：一个好的Authority页面会被很多好的Hub页面指向</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>基本假设2</strong>：一个好的Hub页面会向向很好的Authority页面</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>算法步骤：</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、将查询提交给某个现有的搜索引擎，或检索系统，提取排名靠前的结果（根集）</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、在根集的基础上，对其扩充（凡是与根集内网页有直接链接指向关系的网页都被扩充进来）</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、在根集+扩充网页，寻找好的Hub页面与好的Authority页面</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">4、初始情况下，在没有更多可利用信息前，把所有页面两个权值都设置为1</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">5、以相互增强的关系等原则进行多轮迭代计算，每轮迭代计算更新每个页面的两个权值，直到权值稳定为止</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">HITS算法不仅在搜索引擎领域应用，在自然语言处理，社交分析也有较好的效果</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">HITS算法的不足：计算效率较低、主题漂移，易被作弊者操纵结果，结果不稳定（添加删除个别网页或者改变少数链接关系，对排名影响会很大）</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>HITS算法与PageRank算法比较</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、HITS与用户输入查询相关，PageRank与查询无关</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、HITS计算效率低，PageRank离线计算，在线直接使用计算结果，计算效率高</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、HITS为局部计算，适合在客户端，<span style="font-size: medium; ">PageRank为全局计算，适合步骤在服务器端</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">4、HITS适合处理具体用户查询，</span><span style="font-size: medium; ">PageRank处理适合处理</span><span style="font-size: medium; ">宽泛的</span><span style="font-size: medium; ">用户查询</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">5、HITS算法在计算时，为每个页面计算两个分值，</span><span style="font-size: medium; ">PageRank只需计算一个分值，在搜索引擎领域，更重要Authority权值，其他应用领域Hub分值也很重要</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">6、从反作弊角度说，<span style="font-size: medium; ">PageRank从机制上优于HITS</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">7、</span><span style="font-size: medium; ">PageRank比HITS计算过程更稳定，原因是</span><span style="font-size: medium; ">PageRank计算时的远程跳转</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><br /></span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><strong>SALSA算法</strong></span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">很多实验数据表明，SALSA是目前最好的链接分析算法之一</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">计算流程分两个阶段：</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>1、确定计算对象集合</strong>，与HITS类似</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1）扩展网页集合，在收到用户查询后，利用现有搜索引擎或检索系统获取根集，并扩展</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2）转换为无向二分图，一个子集合Hub集合，Authority集合</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>2、链接关系传播过程</strong>，在这一阶段采纳了随机游走模型</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">在权值传播过程中，权值是被所有链接平均分配的</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">HITS模型关注的是Hub和<span style="font-size: medium; ">Authority之间的节点相互增强关系</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">SALSA实际上关注的是Hub-Hub及</span><span style="font-size: medium; ">Authority-</span><span style="font-size: medium; ">Authority之间的节点关系</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">Authority集合内从某个节点i转移到另一个节点j的概率，i与j之间概率是不同的，非对称</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">在二分图中，对于</span><span style="font-size: medium; ">Authority集合内的某个节点来说，一定可以通过Hub子集合的节点中转后再次返回本身</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">建立好</span><span style="font-size: medium; ">Authority节点关系图后，即可利用随机游走模型来计算每个节点的</span><span style="font-size: medium; ">Authority权值</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><strong>SALSA将搜索结合排序问题进一步转换为求</strong></span><span style="font-size: medium; "><strong>Authority节点矩阵的主秩问题</strong>，无需迭代，计算速度快</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><strong>决定</strong></span><span style="font-size: medium; "><strong>Authority权值的4个因子</strong>：</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">1）</span><span style="font-size: medium; ">Authority子集合中包含的节点总数</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">2）网页i所在连通图中的节点个数</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">3）网页i所在连通图中包含的入链总数</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">4）网页i的入链个数</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>SALSA算法的特点</strong>：</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、SALSA算法无需像HITS算法一样迭代计算，<span style="font-size: medium; ">计算速度快</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">2、解决了HITS主题漂移的问题，搜索质量优于HITS</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>主题敏感PageRank</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">该算法被Google使用在个性化搜索服务中，非常适合作为个性化搜索的技术方案</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">用户会对某些领域感兴趣，同时当浏览某个页面时，这个页面也是与某个主题相关，跳转时，更倾向于点击和当前页面主题类似的链接</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">主题敏感PageRank是将用户兴趣，页面主题及链接所指向网页与当前网页主题的相似程度综合考虑而建立模型</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">该算法引入16种主题类型，对于某个网页来说，对应某个主题类型都有相应的PageRank分值</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">主题敏感的PageRank与主题相关，在接收到用户查询后，主题敏感PageRank还需要利用分类器，计算该查询隶属于事先定义好的16个主题的相似度，并在排序时利用此相似度信息</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">计算流程：</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、离线的分类主题PageRank数值计算，计算网页对于16个分类的相似度</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">&nbsp; &nbsp; &nbsp;将网页划分为两个集合，一个ODP对应分类主题对应的所有网页S，剩下的网页为另一个集合T</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">&nbsp; &nbsp; &nbsp;通过链接关系，从S向T传递权重，即计算网页所属类别的概率</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、在线利用算好的PageRank分值，来评估网页和用户查询的相似度</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">&nbsp; &nbsp; &nbsp;通过计算查询词所属类别的概率*网页所属类别的概率，得出两者相关性的分值，进行排序</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>HillTop算法</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、从海量的互联网网页中通过一定的规则选出专家页面子集合，并单独为其建立索引</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、接收用户发出的查询请求时，根据用户查询的主题，从专家页面子集合中找出部分相关性最强的专家页面，对每个专家页面计算相关性得分</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、根据目标页面（从索引系统中中取到的页面）和这些专家页面的链接关系 对目标页面进行排序</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">4、整合相关专家页面和得分较高的目标页面作为搜索结果，返回给用户</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">从属组织页面：主机IP地址的前3个网段相同，网站域名中的主域名相同</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><strong>专家页面</strong></span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">1、与某个主题相关的高质量页面</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">2、这些页面的链接所指向的页面相互之间是非从属组织页面</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">3、这些被指向的页面大多数是与专家页面主题相近</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">HillTop可以与某个排序算法相结合，不适合作为一个独立的网页排序算法来使用，因为当无法得到一个足够大的专家页面时，会返回空结果。</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>步骤1：专家页面搜索</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">从1亿4千万网页中，筛选出250万作为专家页面，专家页面特征:</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、页面中至少包含K个出链，K可以人为指定</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、K个出链指向的所有页面相互之间的关系，都符合非从属组织页面</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">对专家页面单独建索引，且只对关键字段(Key Phrase)进行索引，关键字段包含3类信息：网页标题，H1标签内文字和URL锚文字</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">关键字段有影响范围（可以支配Qualify的链接），依次为，标题-&gt;H1标签-&gt;URL锚文字</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">在计算网页排序时，对查询字段在不同的关键字段中，会使用不同的权值</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">系统接收到用户查询Q，将对专家页面进行打分，主要考虑以下3类信息：</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、关键字段包含了多少词</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、关键片段本身的类型，即关键字段的类型</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、用户查询和关键词的失配率，即关键字段中不属于查询的单词个数占关键片段总单词个数的比率</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>步骤2：目标页面排序</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">Hilltop算法包含的基本假设：一个目标页面如果是满足用户查询的高质量搜索结果，其充分必要条件是该目标页面有高质量专家页面链接指向</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">为保证上述假设的成立，Hilltop算法在这个阶段需要对专家页面的出链仔细进行甄别，以保证查询时，选出那些和查询密切相关的目标页面。</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">在进行传递分值之前，首先需要对链接关系进行整理，<strong>能够获得专家页面分值的目标页面</strong>需要满足以下两点要求：</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>条件1</strong>、至少需要两个专家页面有链接指向目标页面，且两个专家页面不能是从属组织页面</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">能够获得传递分值的目标页面一定有多个专家页面链接指向，目标页面所获得的总传播分值是每个有链接指向的专家页面所传递的分值之和</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>条件2</strong>、专家页面和所指向的目标页面不能是从属组织页面</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>目标页面权值计算步骤</strong>：</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、找到专家页面中那些能够支配页面的关键片段集合S</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、统计S中包含用户查询词的关键片段个数T，T越大权值越大</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、专家页面给目标页面传递分值：E*T,E为专家页面本身在第一阶段计算得到的相关得分，T为b步骤计算分值</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">对于包含多个查询词的用户请求，则每个查询词单独计算，将多个查询词的传递分值累加</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">Hilltop算法存在与HITS算法类似的计算效率问题，随着专家页面集合的增大</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>其他改进算法</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>1、智能游走模型(Intelligent Surfer Model)</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">判断网页包含的链接所指向的网页内容和用户查询的相关性，以此来改善链接分析效果</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>2、偏置游走模型(Biased Sufer Model)</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">智能游走模型考虑的是网页内容和用户查询的相关性，而偏游走模型考虑的是链接指向的网页内容和当前浏览网页内容之间的相似性</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>3、PHITS算法(Probability Analogy of HITS)</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">PHITS是对HITS算法的直接改进。</span><span style="font-size: medium; ">PHITS算法认为不同链接其传递权值的能力应该是不同的，</span><span style="font-size: medium; ">PHITS需要计算两个页面S和T之间链接的连接强度</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">链接的强度依据页面S和T之间相似度确定</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><strong>4、BFS算法(Backward Forward Step)</strong></span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">对SALSA算法的扩展，对HITS算法的限制</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">解除了SALSA算法只允许直接相邻网页才能有影响的限制，只要网页S和T可通达，即可对网页T施加影响，如果网页S距离网页T距离越远，那么网页S的影响就随着距离增大而呈现衰减</div><img src ="http://www.cppblog.com/humanchao/aggbug/204224.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/humanchao/" target="_blank">胡满超</a> 2013-11-12 14:06 <a href="http://www.cppblog.com/humanchao/archive/2013/11/12/204224.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>这就是搜索引擎－笔试5-检索模型与搜索排序</title><link>http://www.cppblog.com/humanchao/archive/2013/11/04/204084.html</link><dc:creator>胡满超</dc:creator><author>胡满超</author><pubDate>Mon, 04 Nov 2013 04:56:00 GMT</pubDate><guid>http://www.cppblog.com/humanchao/archive/2013/11/04/204084.html</guid><wfw:comment>http://www.cppblog.com/humanchao/comments/204084.html</wfw:comment><comments>http://www.cppblog.com/humanchao/archive/2013/11/04/204084.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/humanchao/comments/commentRss/204084.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/humanchao/services/trackbacks/204084.html</trackback:ping><description><![CDATA[<div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>检索模型与搜索排序</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">最重要的两个因素，用户查询与网页相关性，网页链接情况</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">检索模型：用户查询与网页相关性</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">布尔模型，向量空间模型，概率模型，语言模型，机器学习排序算法</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><br /></span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>布尔模型</strong>：数据基础是集合论，搜索结果过于粗糙，无法量化搜索词与文档之前的相关性</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong><br /></strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>向量空间模型</strong>：把文档看做是由T维特征组成的一个向量，最常用的是以单词作为特征，实际应用中，文档的维度相当高（成千上万）</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">将查询和文档之间的内容相似性作为相关性的替代</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">计算相似性，使用COSINE，计算查询词特征权值与文档中每个特征权值向量的点积</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>特征权重</strong>：由词频Tf，逆文档频率IDF确定</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><strong>词频Tf</strong>：</span>Wtf=a+(1-a)*Tf/Max(Tf)</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">a取0.4效果较好</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>逆文档频率因子</strong>：文档集合范围的一种全局因子，特征单词之间的相对重要性</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">有研究者进一步分析认为：IDF代表了单词带有的信息量的多少（熵），其值越高，说明其信息含量越多，越有价值</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">IDFk=log(N/nk)</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">N代表文档集合中总共有多少个文档，nk代表特征单词k在其中多少个文档中出现过</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">Weight_word=Tf*IDF，特征权值越大，越可能是好的指示词</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>查询词在某个文档中的词频越高，在其他文档中出现的词频越低，这个词的权值越高</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">向量空间模型是经验型的模型，靠直觉和经验不断摸索完善，缺乏明确的理论指导改进方向</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>概率排序原理</strong>：给定一个用户查询，如果搜索系统能够在搜索结果排序时按照文档和用户需求的相关性由高到低排序，那么这个搜索系统的准确性是最优的。</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">将P(D|R)/P(D|NR)大小进行降序排列，得到搜索相关性排序</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong><br /></strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>二元独立模型</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong><br /></strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>二元假设：</strong>一遍文档在由特征进行表示的时候，以特征&#8220;出现&#8221;和&#8220;不出现&#8221;两种情况来表示</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>词汇独立假：</strong>文档中出现任意一个词在文档的分布概率不依赖于其他单词是否出现</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong style="font-size: medium; "><br /></strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong style="font-size: medium; ">BMI模型</strong><span style="font-size: medium; ">：基于二元假设推导而出，对于单词特征，只考虑是否在文档中出现过，而了考虑单词的权值</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">P(D|R)/P(D|NR) = pi(1-si)/si(1-pi)</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">log(</span>&nbsp;<span style="font-size: medium; ">pi(1-si)/si(1-pi) )</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">pi代表第i个单词在相关文档集合内出现的概率，在二元假设下，可以用包含这个单词的相关文档个数ri除以相关文档总数R来估算，pi=ri/R</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">si代表第i个词在不相关文档集合内出现的概率，可以用包含这个单词的不相关文档个数ni-ri，除以不相关文档总数(N-R)来估算，si=(ni-ri)/(N-R)</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">加上平滑处理</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">log((ri+0.5)/(R-ri+0.5)</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">/</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">(ni-ri+0.5)/((N-R)-(ni-ri)+0.5))</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">其含义：对于同时出现在用户查询Q和文档D中的单词，累加每个单词的估值，其和就是文档D和查询相关性度量值</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong><br /></strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>BM25模型</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">在BIM模型的基础上，考虑了单词在查询中的权值及单词在文档中的权值，拟合出综合上述考虑因素的公式，并通过引入一些经验参数</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">BM25模型是目前最成功的内容排序模型</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: 10.5pt; position: relative; top: 11.5pt; "><img distinguish="6CC322606F5F48A69A545D6A5A73D6D7" width="345" height="44" src="file:///C:/Documents%20and%20Settings/humanchao/Local%20Settings/Application%20Data/youdao/ynote/images/E84D8BF7758A4323A16CC60D0F02E9E2/clip_image002.jpg" alt="http://hi.csdn.net/attachment/201011/30/0_12911307384w69.gif" vshapes="图片_x0020_13" data-media-type="image" data-inited="true" style="cursor: default;" /></span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><p align="left"><span style="font-size: 12pt; color: #333333; ">k<sub>1</sub>,k<sub>2</sub>,K</span><span style="font-size: 12pt; font-family: 宋体; color: #333333; ">均为经验设置的参数，</span><span style="font-size: 12pt; color: #333333; ">f<sub>i</sub></span><span style="font-size: 12pt; font-family: 宋体; color: #333333; ">是词项在文档中的频率，</span><span style="font-size: 12pt; color: #333333; ">qf<sub>i</sub></span><span style="font-size: 12pt; font-family: 宋体; color: #333333; ">是词项在查询中的频率。</span></p><p align="left"><span style="background-color: white; line-height: 19.5pt; font-size: 12pt; color: #333333; ">K<sub>1</sub></span><span style="background-color: white; line-height: 19.5pt; font-size: 12pt; font-family: 宋体; color: #333333; ">通常为</span><span style="background-color: white; line-height: 19.5pt; font-size: 12pt; color: #333333; ">1.2</span><span style="background-color: white; line-height: 19.5pt; font-size: 12pt; font-family: 宋体; color: #333333; ">，通常为</span><span style="background-color: white; line-height: 19.5pt; font-size: 12pt; color: #333333; ">0-1000</span></p><p align="left"><span style="font-size: 12pt; color: #333333; ">K</span><span style="font-size: 12pt; font-family: 宋体; color: #333333; ">的形式较为复杂</span></p><p align="left"><span style="font-size: 14pt; color: #333333; ">K=</span><span style="font-family: Arial, sans-serif; color: #333333; position: relative; top: 10.5pt; "><img distinguish="83BCC84466C34743902489E224F471B1" width="166" height="35" src="file:///C:/Documents%20and%20Settings/humanchao/Local%20Settings/Application%20Data/youdao/ynote/images/4735DECBAE764616B79034DD2E1B381E/clip_image002.jpg" alt="http://hi.csdn.net/attachment/201011/30/0_1291130766F92C.gif" vshapes="图片_x0020_14" data-media-type="image" data-inited="true" style="cursor: default;" />&nbsp;</span></p><span style="font-size: 12pt; font-family: 宋体; color: #333333; ">上式中，</span><span style="font-size: 12pt; color: #333333; ">dl</span><span style="font-size: 12pt; font-family: 宋体; color: #333333; ">表示文档的长度，</span><span style="font-size: 12pt; color: #333333; ">avdl</span><span style="font-size: 12pt; font-family: 宋体; color: #333333; ">表示文档的平均长度，</span><span style="font-size: 12pt; color: #333333; ">b</span><span style="font-size: 12pt; font-family: 宋体; color: #333333; ">通常取</span><span style="font-size: 12pt; color: #333333; ">0.75</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>BM25F模型</strong>：是典型的BM25改进算法</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">将文档内容切换成不同的部分，为不同的部分赋予不同的权重</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>语言模型方法</strong>：借鉴语音识别领域采用的语言模型技术，将语言模型和信息检索相互融合</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">为每个文档建立一个语言模型，语言模型代表了单词或者单词序列在文档中的分布情况</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">对于查询中的单词来说，每个单词都对应一个抽取概率，将这些单词的抽取概率相乘就是文档生成查询的总体概率</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">一般采用<strong>数据平滑</strong>方式解决数据稀疏问题</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">用户提交查询Q，文档集合内所有文档都计算生成Q的概率，然后按照生成概率值由大到小排序，就是搜索结果</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">HMM，隐马尔科夫语言模型、相关模型、翻译模型是在基本语言模型的改进</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">语言模型检索方法效果略优于精调参数的向量空间模型，与BM25等概率模型效果相当</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">通过理论推导，可以得出：语言模型检索方法的排序公司符合概率模型的概率排序原理，类似向量空间模型Tf*IDF</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>机器学习排序</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">为何兴起较晚：</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、其他模型和方法，考虑的因素较少，人工进行公式拟合完全可行，效果尚可</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、机器学习需要大量训练数据，用户点击记录可以当做机器学习方法训练数据的一个替代品</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>机器学习排序系统的4个步骤</strong>：</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">人工标注训练数据：用户点击记录来模拟人工打分机制</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">文档特征抽取：查询词在文档中的词频、查询词的IDF信息，网页入链数量，<span style="font-size: medium; ">网页出链数量，网页PageRank值，网页URL长度，查询词的Proximity值（文档中多大的窗口内可以出现所有查询词）</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">学习分类函数</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">在实际搜索系统中采用机器学习模型</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>机器学习方法</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>1、单文档方法</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">对单独的一篇文档转换为特征向量，机器学习系统根据从训练数据中学习到的分类或回归函数对文档打分，打分结果为最后得分</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">在训练过程中，当打分大于一定的阈值，为相关文档，否则为不相关文档。</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2<strong>、文档对方法</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">通过训练，对文档顺序关系是否合理进行判断，判断两个文档的得分</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">使用SVM,BOOST,神经网络，都可以做为学习方法</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">缺点，只考虑了两个文档对的相对先后顺序，却没有考虑文档出现的搜索列表中的位置</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">不同的查询，相关文档数量差异很大，对机器学习系统的效果造成评价困难</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>3、文档列表方法</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">将每个查询对应的所有搜索结果列表作为一个训练实例</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">通过搜索结果排列组合的概率分布，训练评分函数</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>搜索质量评价标准</strong>：对于搜索引擎更加关注精确率</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">精确率：本次搜索结果中相关文档所占<strong>本次搜索返回的所有文档</strong>的比例</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">招回率：<span style="font-size: medium; ">本次搜索结果中相关文档占<strong>整个集合中所有相关文档</strong>的比例</span></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">P@10指标：在搜索结果排名最先前的头10个文档中有多大比例是相关的</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">MAP：AP兼顾了排在前列的相关性和系统招架率，MAP多组查询的AP平均值</div><img src ="http://www.cppblog.com/humanchao/aggbug/204084.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/humanchao/" target="_blank">胡满超</a> 2013-11-04 12:56 <a href="http://www.cppblog.com/humanchao/archive/2013/11/04/204084.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>这就是搜索引擎－笔试4-索引压缩</title><link>http://www.cppblog.com/humanchao/archive/2013/11/04/204083.html</link><dc:creator>胡满超</dc:creator><author>胡满超</author><pubDate>Mon, 04 Nov 2013 04:56:00 GMT</pubDate><guid>http://www.cppblog.com/humanchao/archive/2013/11/04/204083.html</guid><wfw:comment>http://www.cppblog.com/humanchao/comments/204083.html</wfw:comment><comments>http://www.cppblog.com/humanchao/archive/2013/11/04/204083.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/humanchao/comments/commentRss/204083.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/humanchao/services/trackbacks/204083.html</trackback:ping><description><![CDATA[<div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>词典压缩</strong>：减小词典的内存占用</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">好的压缩算法：压缩率，压缩速度，解压速度（最重要）</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>一元编码</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><table border="1" cellpadding="2" cellspacing="0" width="100%" style="font-size: inherit; border-style: solid; border-color: #999999; border-collapse: collapse; margin: 6px auto;"><tbody><tr><td valign="top" style="word-break: break-all; border-style: solid; border-color: #999999;">1</td><td valign="top" style="word-break: break-all; border-style: solid; border-color: #999999;">0</td></tr><tr><td valign="top" style="word-break: break-all; border-style: solid; border-color: #999999;">2</td><td valign="top" style="word-break: break-all; border-style: solid; border-color: #999999;">10</td></tr><tr><td valign="top" style="word-break: break-all; border-style: solid; border-color: #999999;">3</td><td valign="top" style="word-break: break-all; border-style: solid; border-color: #999999;">110</td></tr><tr><td valign="top" style="word-break: break-all; border-style: solid; border-color: #999999;">4</td><td valign="top" style="word-break: break-all; border-style: solid; border-color: #999999;">1110</td></tr><tr><td valign="top" style="word-break: break-all; border-style: solid; border-color: #999999;">5</td><td valign="top" style="word-break: break-all; border-style: solid; border-color: #999999;">11110</td></tr></tbody></table></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">Elias Gamma:</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">x=2^e+d</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">e+1:一元编码</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">d:二元编码</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>Elias Delta</strong>:</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><div>x=2^e+d</div><div>e+1:再使用<span style="font-size: medium; ">Elias Gamma编码一次</span></div><div>d:二元编码</div></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>Golomb &amp; Rice</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">因子1=(X-1)/b，因子1+1，一元编码</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">因子2=(X-1) mod b，使用二元编码，编码宽度在log(b)</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">Golomb: b=0.69*Avg(序列平均值)</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">Rice：2的整数次幂，所有小于Avg中最接近Avg的数值</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>变长压缩算法SimpleX</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">Simple9: 32位比特位，4个比特为管理数据存储区，28个比特压缩数据存储区</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">Simple9的28位有9种表示形式</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>Simple16</strong>: 28位有16种表示形式，并且通过非当项完全固定长度，解决数据区有浪费位的情况</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>PForDelta</strong>：目前解压速度最快的一种倒排文件压缩算法</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1，对待编码的连续K个数值（一般为128），确定10%的大数数值，根据70%小数确定夺取的比特宽度，确定整个序列</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2，对原始数据遍历，将大数放置到尾端，并转换成链表结构的序列</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、将所有数字压缩到队列中</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>文档编号重排序</strong></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">网页的文档ID+单词词频信息，文档ID使用D-Gap进行编码</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">将内容越相似的网页，在编排文档号时越相邻</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">海量数据文本聚类速度较慢，将URL相似的网页聚合在一起，假设同一个网站的很多页面表达的主题内容是近似的</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>静态索引裁剪</strong>：主动抛弃一部分不重要的信息（索引项）来达到数据压缩的效果</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>以单词为中心的索引裁剪</strong>：</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">判断单词与文档的相似性，每个词典中的单词，其对应的倒排排列中至少保留K个索引项，还要保留若干富余项目</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">实验证明，如果首先对所有索引项的原始得分减去得分最低索引项的得分，再采取（对K个项进行折扣，乘一个折扣因子，得出阈值a，剩下的大于a保留）方法进行裁剪，效果会大大提升</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">因为</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">索引项得分分差相关不大，比较集中在某个区间，所以减掉得分最低项</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>以文档为中心的索引裁剪</strong>：更为常用</div><div style="font-family: 微软雅黑; font-size: 18px; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">在建立索引之前进行数据预处理，把与文档主题表达不相关的单词抛弃，如停用词</div><img src ="http://www.cppblog.com/humanchao/aggbug/204083.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/humanchao/" target="_blank">胡满超</a> 2013-11-04 12:56 <a href="http://www.cppblog.com/humanchao/archive/2013/11/04/204083.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>这就是搜索引擎－笔试3-搜索引擎索引</title><link>http://www.cppblog.com/humanchao/archive/2013/09/16/203260.html</link><dc:creator>胡满超</dc:creator><author>胡满超</author><pubDate>Mon, 16 Sep 2013 06:01:00 GMT</pubDate><guid>http://www.cppblog.com/humanchao/archive/2013/09/16/203260.html</guid><wfw:comment>http://www.cppblog.com/humanchao/comments/203260.html</wfw:comment><comments>http://www.cppblog.com/humanchao/archive/2013/09/16/203260.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/humanchao/comments/commentRss/203260.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/humanchao/services/trackbacks/203260.html</trackback:ping><description><![CDATA[<div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">单词词典</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、哈希加链表</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、树形结构：B树或者B+树</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">倒排列表：</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">单词+文档号，词频，出现的位置</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">文档号一般采用差值存储，以节省空间</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">建立索引</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、两遍文档遍历法</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">第一遍，收集全局统计信息，文档数N，每个文档包含不同单词数M，每个单词在多少个文档中出现过的信息DF，通过这些信息可以计算出最终索引的大小</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">第二遍，在建立好的内存中建立索引，从磁盘读取文档并解析文档是最消耗时间的步骤</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、排序法</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">始终在内存中分配固定大小的空间，用来存放词典信息和索引中间结果，当分配空间消耗光的时候，把中间结果写入磁盘，清空内存数据进行下一轮索引</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>中间结果排序</strong>，排序前，文档ID，单词ID，单词频率</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">排序后，单词ID（主键），文档ID（次键）</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>合并中间结果</strong>，把中间结果文件进行合并，按单词ID写入最终结果文件</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、归并法</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">在中间结果排序完成以后，把字典信息也写入文档中，这样全额使用内存</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">在建立中间索引中，实际单词，文档编号，词频</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">合并时，针对每个单词的倒排列表进行合并，形成最终的词典信息</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>动态索引</strong></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">倒排索引：词典在内存里，倒排列表存储在磁盘文件中</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">临时索引：词典和倒排列表都在内存中，当有新文档加入时，放到临时索引中</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">删除文档列表：当文档内容被更改时，系统认为旧文档被删除，增加一篇新文档</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">当用户输入查询时，先从找倒排索引+临时索引，去掉删除文档列表中的文档结果</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>索引更新策略</strong></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、完全重建策略：当新增文档达到一定数量后，新老索引合并重建，适合小文档集合，主流商业搜索引擎一般也采用此方式来维护</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、再合并策略：<span style="font-size: medium; ">当新增文档达到一定数量后，新老索引合并重建，此时老索引还在被使用，由于老索引有序，所以合并策略执行较快，但是读老索引，建新索引，也需要较多IO时间，比较耗时</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、原地更新策略：在建立老索引时，在老索引倒排列表中留有一定的余地，新加入索引直接追加到预留空间，实验数据表明，更新效率比再合并策略低</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">4、混合策略：将单词根据不同性质进行分类，对其索引采取不同的索引更新策略，长倒排列表单词采取原地更新策略（读写开销大），短倒排列表采取再合并策略（读写开销不算太大<span style="font-size: medium; ">）</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><br /></span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><strong>查询处理</strong></span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">1、一次一文档，找到包含关键字的所有文档集合，一次计算一个文档的得分，依次计算所有文档，计算后一般采用优先队列对分数进行排序</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">2、一次一单词，一次计算一个单词的得分，并把结果以文档编写为关键值，以hash表存储得分，计算所有文档得分后，对hash表进行排序</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>跳跃指针</strong></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">在存储倒排索引文档编号时，通常使用跳跃指针节省空间，跳跃指针分块使用根号L为长度效果较好</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>多字段索引</strong>：对网页的不同区域进行字段划分，进行索引</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、多索引方式，对每个不同的字段分别建立索引</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、倒排列表方式，把字段信息存储到倒排列表项中</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、扩展列表方式，把每个字段出现的位置记录到一张列表里，倒排索引找到单词后，判断单词的位置是否在某字段范围中</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>短语查询</strong>：本质上是如何在索引中维护单词顺序关系或位置信息</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、位置信息索引，通过位置信息判断两个词是否为短语关系，适合常规短语</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、双词索引，首词+下词，只对计算代价高的短语建立双词索引，一般短语通过常规手段达到目的</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、短语索引，缺点无法将所有短语都建好索引，从用户查询日志或网页本身挖掘短语，适合热门短语</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">4、混合方法，用户查询-&gt;短语索引-&gt;双词索引-&gt;常规索引</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">分布式索引：多台机器协作完成索引</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、按文档划分，每台机器负责对某个文档子集建立索引</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、按单词划分，将单词分别传送给服务器1，计算结果后，再传送给服务器2，一次一单词的查询处理方式</div><img src ="http://www.cppblog.com/humanchao/aggbug/203260.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/humanchao/" target="_blank">胡满超</a> 2013-09-16 14:01 <a href="http://www.cppblog.com/humanchao/archive/2013/09/16/203260.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>这就是搜索引擎－笔试2</title><link>http://www.cppblog.com/humanchao/archive/2013/09/13/203210.html</link><dc:creator>胡满超</dc:creator><author>胡满超</author><pubDate>Fri, 13 Sep 2013 03:10:00 GMT</pubDate><guid>http://www.cppblog.com/humanchao/archive/2013/09/13/203210.html</guid><wfw:comment>http://www.cppblog.com/humanchao/comments/203210.html</wfw:comment><comments>http://www.cppblog.com/humanchao/archive/2013/09/13/203210.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/humanchao/comments/commentRss/203210.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/humanchao/services/trackbacks/203210.html</trackback:ping><description><![CDATA[<div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><strong>二、网络抓虫</strong></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><br />网页页面划分为5个部分：</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、已下载</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、已过期</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、待下载</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">4、可知网页集合，未下载，但可索引</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">5、不可知网页集合，暗网网页</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">爬虫分三种类型：</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、批量型：有明确的抓取范围和目标，当达到这个目标后停止抓取</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、增量型：不断抓取，抓取到以后定期更新</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、垂直型：抓取特定行业网页</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">优秀爬虫的特性：高性能、可扩展（良好的并发性）、健壮性、友好性（遵守Robot协议）</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">评价爬虫质量的标准：覆盖率，时新性，重要性</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">&nbsp;</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">抓取策略：优先选择重要网页进行抓取</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">1、宽度优先遍历策略，虽然机械，但是效果好，隐含了一些网页优秀级的假设</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">2、非完全PageRank策略，对已下载网页集合，加上待抓取URL，形成网页集合，进行PageRank计算，将待抓取按得分进行排序</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">3、OCIP策略，在线页面重要性计算，待下载页面都分配相同的cash，下载后把页面拥有的现金平分给包含的链接，</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">待抓取URL则根据手头现金排序，优先下载最充裕网页。计算速度快，适合实时计算，效果略优于宽度优先</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">4、大站优先策略，哪个网站等等下载的页面最多，则优先下载这些链接，<span style="font-size: medium; ">效果略优于宽度优先</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><br /></span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">网页更新策略</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">1、历史参考策略，过去频繁更新的网页，将来也会频繁更新，利用泊松过程</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">抓取策略应该忽略掉广告或导航等非重要区域的频繁变化，集中在主题内容的变化探测和建模</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">2、用户体验策略，对搜索结果排名靠前，更新以后对搜索质量（排名）的影响较大的页面进行更新</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">3、聚类抽样策略，先对网页进行聚类，对同一类网页采用相同的更新频率</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">聚类特征：</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">静态特征，页面的内容，图片数量，页面大小，链接深度，PageRank值</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">动态特征，随着时间的变化 ，静态特征的变化情况</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">聚类抽样策略效果好于前述两种，但是对亿计网页进行聚类，难度较大</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><br /></span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">暗网抓取</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">将暗网数据从数据库中挖掘出来，百度的&#8220;阿拉丁&#8221;计划就是解决此问题</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">查询组合：Google提出富含信息查询模板技术，使用</span><span style="font-size: medium; ">富含信息查询模板进行查询，获取有效的网页结果</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">富含信息查询模板：对于某固定的查询模板来说，如果给模板内每个属性都赋值，形成不同的查询组合，其返回内容差异较大，则这个查询模板为</span><span style="font-size: medium; ">富含信息查询模板</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; "><br /></span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">分布式爬虫</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">主从分布式：URL服务器容易成为整个系统的瓶颈</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-size: medium; ">对等分布式：没有URL服务器存在，每台抓取服务器的分工成为问题，对网址的主域名进行哈希计算，之后对m服务器数量取模，把计算后的模和抓取服务器号匹配</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">一致性哈希算法：将网站主域名进行哈希，映射到0~2^32之间某个数值，抓取服务器负责这个环状序列的一个片段的抓取，抓取内容由上一个服务器进行循环转发</div><img src ="http://www.cppblog.com/humanchao/aggbug/203210.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/humanchao/" target="_blank">胡满超</a> 2013-09-13 11:10 <a href="http://www.cppblog.com/humanchao/archive/2013/09/13/203210.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>这就是搜索引擎－笔试1</title><link>http://www.cppblog.com/humanchao/archive/2013/09/05/203023.html</link><dc:creator>胡满超</dc:creator><author>胡满超</author><pubDate>Thu, 05 Sep 2013 06:27:00 GMT</pubDate><guid>http://www.cppblog.com/humanchao/archive/2013/09/05/203023.html</guid><wfw:comment>http://www.cppblog.com/humanchao/comments/203023.html</wfw:comment><comments>http://www.cppblog.com/humanchao/archive/2013/09/05/203023.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/humanchao/comments/commentRss/203023.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/humanchao/services/trackbacks/203023.html</trackback:ping><description><![CDATA[<div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; "><strong>一、搜索引擎介绍</strong></span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; "><br /></span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">搜索引擎发展阶段：</span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">1、分类目录的一代</span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">2、文本检索的一代</span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">3、链接分析的一代</span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">4、用户中心的一代</span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; "><br /></span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">搜索引擎的三个目标：更全，更快，更准</span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; "><br /></span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">搜索引擎的3个核心问题：</span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">1、用户真正的需求是什么，搜索词背后的含义</span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">2、哪些信息是和用户需求真正相关，关键词匹配</span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">3、哪些信息是用户可以依赖的，返回给用户重要的，可依赖的网页</span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; "><br /></span></div><div style="word-wrap: break-word; font-family: 宋体, 'sans serif', tahoma, verdana, helvetica; font-size: 16px; line-height: 24px; "><span style="font-size: small; ">优秀的云存储与云计算机平台已经成为大型商业搜索引擎的核心竞争力</span></div><img src ="http://www.cppblog.com/humanchao/aggbug/203023.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/humanchao/" target="_blank">胡满超</a> 2013-09-05 14:27 <a href="http://www.cppblog.com/humanchao/archive/2013/09/05/203023.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转: 怎样量化评价搜索引擎的结果质量</title><link>http://www.cppblog.com/humanchao/archive/2012/12/19/196436.html</link><dc:creator>胡满超</dc:creator><author>胡满超</author><pubDate>Wed, 19 Dec 2012 03:03:00 GMT</pubDate><guid>http://www.cppblog.com/humanchao/archive/2012/12/19/196436.html</guid><wfw:comment>http://www.cppblog.com/humanchao/comments/196436.html</wfw:comment><comments>http://www.cppblog.com/humanchao/archive/2012/12/19/196436.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/humanchao/comments/commentRss/196436.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/humanchao/services/trackbacks/196436.html</trackback:ping><description><![CDATA[<h2>转自：<a href="http://www.infoq.com/cn/articles/cyw-evaluate-seachengine-result-quality">http://www.infoq.com/cn/articles/cyw-evaluate-seachengine-result-quality</a><br /><br />前言</h2><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">搜索质量评估是搜索技术研究的基础性工作，也是核心工作之一。评价（Metrics）在搜索技术研发中扮演着重要角色，以至于任何一种新方法与他们的评价方式是融为一体的。</p><div style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><br />搜索引擎结果的好坏与否，体现在业界所称的在相关性（Relevance）上。相关性的定义包括狭义和广义两方面，狭义的解释是：检索结果和用户查询的相关程度。而从广义的层面，相关性可以理解为为用户查询的综合满意度。直观的来看，从用户进入搜索框的那一刻起，到需求获得满足为止，这之间经历的过程越顺畅，越便捷，搜索相关性就越好。本文总结业界常用的相关性评价指标和量化评价方法。供对此感兴趣的朋友参考。</div><h2>Cranfield评价体系</h2><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">A Cranfield-like approach这个名称来源于英国Cranfield University，因为在二十世纪五十年代该大学首先提出了这样一套评价系统：由查询样例集、正确答案集、评测指标构成的完整评测方案，并从此确立了&#8220;评价&#8221;在信息检索研究中的核心地位。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">Cranfield评价体系由三个环节组成：</p><ol style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><li>抽取代表性的查询词，组成一个规模适当的集合</li><li>针对查询样例集合，从检索系统的语料库中寻找对应的结果，进行标注（通常人工进行）</li><li>将查询词和带有标注信息的语料库输入检索系统，对系统反馈的检索结果，使用预定义好的评价计算公式，用数值化的方法来评价检索系统结果和标注的理想结果的接近程度</li></ol><h2>查询词集合的选取</h2><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">Cranfield评价系统在各大搜索引擎公司内有广泛的应用。具体应用时，首先需要解决的问题是构造一个测试用查询词集合。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">按照Andrei Broder（曾在AltaVista/IBM/Yahoo任职）的研究，查询词可分为3类：寻址类查询（Navigational）、信息类查询(Informational)、事务类查询(Transactional)。对应的比例分别为</p><pre style="overflow: auto; width: 964.25px; padding: 0px 0px 5px; font-size: 12px; line-height: 15px; font-family: 'Courier New', Courier; color: #222222; margin-top: 0px; margin-bottom: 0px; background-color: #fafafa; border: 2px solid #efefef; ">Navigational ： 12.3%  Informational ： 62.0%  Transactional ： 25.7% </pre><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">为了使得评估符合线上实际情况，通常查询词集合也会按比例进行选取。通常从线上用户的Query Log文件中自动抽取。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">另外查询集合的构造时，除了上述查询类型外，还可以考虑Query的频次，对热门query（高频查询）、长尾query（中低频）分别占特定的比例。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">另外，在抽取Query时，往往Query的长短也是一个待考虑的因素。因为短query（单term的查询）和长Query（多Term的查询）排序算法往往会有一些不同。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">构成查询集合后，使用这些查询词，在不同系统（例如对比百度和Google）或不同技术间（新旧两套Ranking算法的环境）进行搜索，并对结果进行评分，以决定优劣。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">附图：对同一Query：&#8220;社会保险法&#8221;，各大搜索引擎的结果示意图。下面具体谈谈评分的方法。</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image1.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image2.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image3.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image4.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image5.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image6.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><h2>Precision-recall（准确率-召回率方法）</h2><h3>计算方法</h3><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">信息检索领域最广为人知的评价指标为Precision-Recall（准确率-召回率）方法。该方法从提出至今已经历半个世纪，至今在很多搜索引擎公司的效果评估中使用。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">顾名思义，这个方法由准确率和召回率这两个相互关联的统计量构成：召回率（Recall）衡量一个查询搜索到所有相关文档的能力，而准确率（Precision）衡量搜索系统排除不相关文档的能力。（通俗的解释一下：准确率就是算一算你查询得到的结果中有多少是靠谱的；而召回率表示所有靠谱的结果中，有多少被你给找回来了）。这两项是评价搜索效果的最基础指标，其具体的计算方法如下。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">Precision-recall方法假定对一个给定的查询，对应一个被检索的文档集合和一个不相关的文档集合。这里相关性被假设为二元的，用数学形式化方法来描述，则是：</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">A表示相关文档集合</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><span style="text-decoration: overline; ">A</span>表示不相关集合</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">B表示被检索到的文档集合</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><span style="text-decoration: overline; ">B</span>表示未被检索到的文档集合</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">则单次查询的准确率和召回率可以用下述公式来表达：</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img alt="" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image7.jpg" _href="img://image7.jpg" _p="true" style="border: 0px; " /></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">（运算符&#8745; 表示两个集合的交集。|x|符号表示集合x中的元素数量）</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">从上面的定义不难看出，召回率和准确率的取值范围均在[0,1]之间。那么不难想象，如果这个系统找回的相关越多，那么召回率越高，如果相关结果全部都给召回了，那么recall此时就等于1.0。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "></p><table cellspacing="0" cellpadding="0" border="1" style="color: #000000; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; text-align: start; background-color: #ffffff; "><tbody><tr><td width="156" valign="top" style="font-size: small; ">&nbsp;</td><td width="156" valign="top" style="font-size: small; "><p align="center">相关的</p></td><td width="156" valign="top" style="font-size: small; "><p align="center">不相关</p></td></tr><tr><td width="156" valign="top" style="font-size: small; "><p align="center">被检索到</p></td><td width="156" valign="top" style="font-size: small; "><p align="center">A&#8745; B</p></td><td width="156" valign="top" style="font-size: small; "><p align="center"><span style="text-decoration: overline; ">A</span>&#8745; B</p></td></tr><tr><td width="156" valign="top" style="font-size: small; "><p align="center">未被检索到</p></td><td width="156" valign="top" style="font-size: small; "><p align="center">A&#8745;<span style="text-decoration: overline; ">B</span></p></td><td width="156" valign="top" style="font-size: small; "><p align="center"><span style="text-decoration: overline; ">A</span>&#8745;<span style="text-decoration: overline; ">B</span></p></td></tr></tbody></table><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "></p><h3>Precision-Recall曲线</h3><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">召回率和准确率分别反映了检索系统的两个最重要的侧面，而这两个侧面又相互制约。因为大规模数据集合中，如果期望检索到更多相关的文档，必然需要&#8220;放宽&#8221;检索标准，因此会导致一些不相关结果混进来，从而使准确率受到影响。类似的，期望提高准确率，将不相关文档尽量去除时，务必要执行更&#8220;严格&#8221;的检索策略，这样也会使一些相关的文档被排除在外，使召回率下降。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">所以为了更清晰的描述两者间的关系，通常我们将Precison-Recall用曲线的方式绘制出来，可以简称为P-R diagram。常见的形式如下图所示。（通常曲线是一个逐步向下的走势，即随着Recall的提高，Precision逐步降低）</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image8.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><h3>P-R的其它形态</h3><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">一些特定搜索应用，会更关注搜索结果中错误的结果。例如，搜索引擎的反作弊系统（Anti-Spam System）会更关注检索结果中混入了多少条作弊结果。学术界把这些错误结果称作假阳性（False Positive）结果，对这些应用，通常选择用虚报率（Fallout）来统计：</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img alt="" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image9.jpg" _href="img://image9.jpg" _p="true" style="border: 0px; " /></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">Fallout和Presion本质是完全相同的。只是分别从正反两方面来计算。实际上是P-R的一个变种。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">再回到上图，Presion-Recall是一个曲线，用来比较两个方法的效果往往不够直观，能不能对两者进行综合，直接反映到一个数值上呢？为此IR学术界提出了F值度量（F -Measure）的方法。F-Measure通过Presion和Recall的调和平均数来计算，公式为：</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image10.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">其中参数&#955;&#949;(0,1)调节系统对Precision和Recall的平衡程度。（通常取&#955;=0.5，此时&nbsp;<img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image11-1.jpg" alt="" style="border: 0px; " />）</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">这里使用调和平均数而不是通常的几何平均或算术平均，原因是调和平均数强调较小数值的重要性，能敏感的反映小数字的变化，因此更适合用来反映检索效果。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">使用F Measure的好处是只需要一个单一的数字就可以总结系统的检索效果，便于比较不同搜索系统的整体效果。</p><h2>P@N方法</h2><h3>点击因素</h3><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">传统的Precision-Recall并不完全适用对搜索引擎的评估，原因是搜索引擎用户的点击方式有其特殊性，包括：</p><pre style="overflow: auto; width: 964.25px; padding: 0px 0px 5px; font-size: 12px; line-height: 15px; font-family: 'Courier New', Courier; color: #222222; margin-top: 0px; margin-bottom: 0px; background-color: #fafafa; border: 2px solid #efefef; ">A 60-65%的查询点击了名列搜索结果前10条的网页；  B 20-25%的人会考虑点击名列11到20的网页；  C 仅有3-4%的会点击名列搜索结果中列第21到第30名的网页 </pre><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">也就是说，绝大部分用户是不愿意翻页去看搜索引擎给出的后面的结果。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">而即使在搜索结果的首页（通常列出的是前10条结果），用户的点击行为也很有意思，我们通过下面的Google点击热图（Heat Map）来观察（这个热图在二维搜索结果页上通过光谱来形象的表达不同位置用户的点击热度。颜色约靠近红色表示点击强度越高）：</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image12.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">从图中可以看出，搜索结果的前3条吸引了大量的点击，属于热度最高的部分。也就是说，对搜苏引擎来说，最前的几条结果是最关键的，决定了用户的满意程度。</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image13.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">康乃尔大学的研究人员通过eye tracking实验获得了更为精确的Google搜索结果的用户行为分析图。从这张图中可以看出，第一条结果获得了56.38%的搜索流量，第二条和第三条结果的排名依次降低，但远低于排名第一的结果。前三条结果的点击比例大约为11:3:2 。而前三条结果的总点击几乎分流了搜索流量的80%。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">另外的一些有趣的结论是，点击量并不是按照顺序依次递减的。排名第七位获得的点击是最少的，原因可能在于用户在浏览过程中下拉页面到底部，这时候就只显示最后三位排名网站，第七名便容易被忽略。而首屏最后一个结果获得的注意力（2.55）是大于倒数第二位的(1.45)，原因是用户在翻页前，对最后一条结果印象相对较深。搜索结果页面第二页排名第一的网页（即总排名11位的结果）所获得的点击只有首页排名第十网站的40%，与首页的第一条结果相比，更是只有其1/60至1/100的点击量。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">因此在量化评估搜索引擎的效果时，往往需要根据以上搜索用户的行为特点，进行针对性的设计。</p><h3>P@N的计算方法</h3><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">P@N本身是Precision@N的简称，指的是对特定的查询，考虑位置因素，检测前N条结果的准确率。例如对单次搜索的结果中前5篇，如果有4篇为相关文档，则P@5 = 4/5 = 0.8 。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">测试通常会使用一个查询集合（按照前文所述方法构造），包含若干条不同的查询词，在实际使用P@N进行评估时，通常使用所有查询的P@N数据，计算算术平均值，用来评判该系统的整体搜索结果质量。</p><h3>N的选取</h3><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">对用户来说，通常只关注搜索结果最前若干条结果，因此通常搜索引擎的效果评估只关注前5、或者前3结果，所以我们常用的N取值为P@3或P@5等。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">对一些特定类型的查询应用，如寻址类的查询（Navigational Search），由于目标结果极为明确，因此在评估时，会选择N=1（即使用P@1）。举个例子来说，搜索&#8220;新浪网&#8221;、或&#8220;新浪首页&#8221;，如果首条结果不是 新浪网（url：<a href="http://www.sina.com.cn/" style="color: #0b59b2; ">www.sina.com.cn</a>），则直接判该次查询精度不满足需求，即P@1=0</p><h2>MRR</h2><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">上述的P@N方法，易于计算和理解。但细心的读者一定会发现问题，就是在前N结果中，排序第1位和第N位的结果，对准确率的影响是一样的。但实际情况是，搜索引擎的评价是和排序位置极为相关的。即排第一的结果错误，和第10位的结果错误，其严重程度有天壤之别。因此在评价系统中，需要引入位置这个因素。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">MRR是平均排序倒数（Mean Reciprocal Rank）的简称，MRR方法主要用于寻址类检索（Navigational Search）或问答类检索（Question Answering），这些检索方法只需要一个相关文档，对召回率不敏感，而是更关注搜索引擎检索到的相关文档是否排在结果列表的前面。MRR方法首先计算每一个查询的第一个相关文档位置的倒数，然后将所有倒数值求平均。例如一个包含三个查询词的测试集，前5结果分别为：</p><pre style="overflow: auto; width: 964.25px; padding: 0px 0px 5px; font-size: 12px; line-height: 15px; font-family: 'Courier New', Courier; color: #222222; margin-top: 0px; margin-bottom: 0px; background-color: #fafafa; border: 2px solid #efefef; ">查询一结果：1.AN 2.AR 3.AN 4.AN 5.AR  查询二结果：1.AN 2.AR 3.AR 4.AR 5.AN  查询三结果：1.AR 2.AN 3.AN 4.AN 5.AR  </pre><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">其中AN表示不相关结果，AR表示相关结果。那么第一个查询的排序倒数（Reciprocal Rank）RR<sub>1</sub>&nbsp;= 1/2=0.5 ；第二个结果RR<sub>2</sub>&nbsp;= 1/2 = 0.5 ； 注意倒数的值不变，即使查询二获得的相关结果更多。同理，RR<sub>3</sub>= 1/1 = 1。 对于这个测试集合，最终MRR=（RR<sub>1</sub>+RR<sub>2</sub>+RR<sub>3</sub>）/ 3 = 0.67</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">然而对大部分检索应用来说，只有一条结果无法满足需求，对这种情况，需要更合适的方法来计算效果，其中最常用的是下述MAP方法。</p><h2>MAP</h2><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">MAP方法是Mean Average Precison，即平均准确率法的简称。其定义是求每个相关文档检索出后的准确率的平均值（即Average Precision）的算术平均值（Mean）。这里对准确率求了两次平均，因此称为Mean Average Precision。（注：没叫Average Average Precision一是因为难听，二是因为无法区分两次平均的意义）</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">MAP 是反映系统在全部相关文档上性能的单值指标。系统检索出来的相关文档越靠前(rank 越高)，MAP就应该越高。如果系统没有返回相关文档，则准确率默认为0。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">例如：假设有两个主题：</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">主题1有4个相关网页，主题2有5个相关网页。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">某系统对于主题1检索出4个相关网页，其rank分别为1, 2, 4, 7；</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">对于主题2检索出3个相关网页，其rank分别为1,3,5。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">对于主题1，平均准确率MAP计算公式为：</p><pre style="overflow: auto; width: 964.25px; padding: 0px 0px 5px; font-size: 12px; line-height: 15px; font-family: 'Courier New', Courier; color: #222222; margin-top: 0px; margin-bottom: 0px; background-color: #fafafa; border: 2px solid #efefef; ">(1/1+2/2+3/4+4/7)/4=0.83。 </pre><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">对于主题2，平均准确率MAP计算公式为：</p><pre style="overflow: auto; width: 964.25px; padding: 0px 0px 5px; font-size: 12px; line-height: 15px; font-family: 'Courier New', Courier; color: #222222; margin-top: 0px; margin-bottom: 0px; background-color: #fafafa; border: 2px solid #efefef; ">(1/1+2/3+3/5+0+0)/5=0.45。 </pre><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">则MAP= (0.83+0.45)/2=0.64。&#8221;</p><h2>DCG方法</h2><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">DCG是英文Discounted cumulative gain的简称，中文可翻译为&#8220;折扣增益值&#8221;。DCG方法的基本思想是：</p><ol style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><li>每条结果的相关性分等级来衡量</li><li>考虑结果所在的位置，位置越靠前的则重要程度越高</li><li>等级高（即好结果）的结果位置越靠前则值应该越高，否则给予惩罚</li></ol><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">我们首先来看第一条：相关性分级。这里比计算Precision时简单统计&#8220;准确&#8221;或&#8220;不准确&#8221;要更为精细。我们可以将结果细分为多个等级。比如常用的3级：Good（好）、Fair（一般）、Bad（差）。对应的分值rel为：Good:3 / Fair:2 / Bad:1 。一些更为细致的评估使用5级分类法：Very Good（明显好）、Good（好）、Fair（一般）、Bad（差）、Very Bad（明显差），可以将对应分值rel设置为：Very Good:2 / Good:1 / Fair:0 / Bad:-1 / Very Bad: -2</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">评判结果的标准可以根据具体的应用来确定，Very Good通常是指结果的主题完全相关，并且网页内容丰富、质量很高。而具体到每条</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image14.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">DCG的计算公式并不唯一，理论上只要求对数折扣因子的平滑性。我个人认为下面的DCG公式更合理，强调了相关性，第1、2条结果的折扣系数也更合理：</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image15.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">此时DCG前4个位置上结果的折扣因子（Discount factor）数值为：</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "></p><table cellspacing="0" cellpadding="0" border="1" style="color: #000000; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; text-align: start; background-color: #ffffff; "><tbody><tr><td width="189" valign="top" style="font-size: small; "><p align="center">i</p></td><td width="189" valign="top" style="font-size: small; "><p align="center">log<sub>2</sub>&nbsp;(i+1)</p></td><td width="189" valign="top" style="font-size: small; "><p align="center">1/log<sub>2</sub>&nbsp;(i+1)</p></td></tr><tr><td width="189" valign="top" style="font-size: small; "><p align="center">1</p></td><td width="189" valign="top" style="font-size: small; "><p align="center">1</p></td><td width="189" valign="top" style="font-size: small; "><p align="center">1</p></td></tr><tr><td width="189" valign="top" style="font-size: small; "><p align="center">2</p></td><td width="189" valign="top" style="font-size: small; "><p align="center">1.59</p></td><td width="189" valign="top" style="font-size: small; "><p align="center">0.63</p></td></tr><tr><td width="189" valign="top" style="font-size: small; "><p align="center">3</p></td><td width="189" valign="top" style="font-size: small; "><p align="center">2</p></td><td width="189" valign="top" style="font-size: small; "><p align="center">0.5</p></td></tr><tr><td width="189" valign="top" style="font-size: small; "><p align="center">4</p></td><td width="189" valign="top" style="font-size: small; "><p align="center">2.32</p></td><td width="189" valign="top" style="font-size: small; "><p align="center">0.43</p></td></tr></tbody></table><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">取以2为底的log值也来自于经验公式，并不存在理论上的依据。实际上，Log的基数可以根据平滑的需求进行修改，当加大数值时（例如使用log<sub>5</sub>&nbsp;代替log<sub>2</sub>），折扣因子降低更为迅速，此时强调了前面结果的权重。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">为了便于不同类型的query结果之间横向比较，以DCG为基础，一些评价系统还对DCG进行了归一，这些方法统称为nDCG（即 normalize DCG）。最常用的计算方法是通过除以每一个查询的理想值iDCG（ideal DCG）来进行归一，公式为：</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image16.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">求nDCG需要标定出理想情况的iDCG，实际操作的时候是异常困难的，因为每个人对&#8220;最好的结果&#8221;理解往往各不相同，从海量数据里选出最优结果是很困难的任务，但是比较两组结果哪个更好通常更容易，所以实践应用中，通常选择结果对比的方法进行评估。</p><h2>怎样实现自动化的评估？</h2><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">以上所介绍的搜索引擎量化评估指标，在Cranfield评估框架（Cranfield Evaluation Framework）中被广泛使用。业界知名的TREC（文本信息检索会议）就一直基于此类方法组织信息检索评测和技术交流。除了TREC外，一些针对不同应用设计的Cranfield评测论坛也在进行进行（如 NTCIR、IREX等）。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">但Cranfield评估框架存在的问题是查询样例集合的标注上。利用手工标注答案的方式进行网络信息检索的评价是一个既耗费人力、又耗费时间的过程，只有少数大公司能够使用。并且由于搜索引擎算法改进、运营维护的需要，检索效果评价反馈的时间需要尽量缩短，因此自动化的评测方法对提高评估效率十分重要。最常用的自动评估方法是A/B testing系统。</p><h3>A/B Testing</h3><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image17.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p align="center" style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><strong>A/B Testing系统</strong></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">A/B testing系统在用户搜索时，由系统来自动决定用户的分组号（Bucket id），通过自动抽取流量导入不同分支，使得相应分组的用户看到的是不同产品版本（或不同搜索引擎）提供的结果。用户在不同版本产品下的行为将被记录下来，这些行为数据通过数据分析形成一系列指标，而通过这些指标的比较，最后就形成了各版本之间孰优孰劣的结论。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">在指标计算时，又可细分为两种方法，一种是基于专家评分的方法；一种是基于点击统计的方法。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">专家评分的方法通常由搜索核心技术研发和产品人员来进行，根据预先设定的标准对A、B两套环境的结果给予评分，获取每个Query的结果对比，并根据nDCG等方法计算整体质量。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">点击评分有更高的自动化程度，这里使用了一个假设：同样的排序位置，点击数量多的结果质量优于点击数量少的结果。（即A2表示A测试环境第2条结果，如果A2 &gt; B2，则表示A2质量更好）。通俗的说，相信群众（因为群众的眼睛是雪亮的）。在这个假设前提下，我们可以将A/B环境前N条结果的点击率自动映射为评分，通过统计大量的Query点击结果，可以获得可靠的评分对比。</p><h3>Interleaving Testing</h3><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">另外2003年由Thorsten Joachims 等人提出的Interleaving testing方法也被广泛使用。该方法设计了一个元搜索引擎，用户输入查询词后，将查询词在几个著名搜索引擎中的查询结果随机混合反馈给用户，并收集随后用户的结果点击行为信息．根据用户不同的点击倾向性，就可以判断搜索引擎返回结果的优劣，</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">如下图所示，将算法A和B的结果交叉放置，并分流量进行测试，记录用户点击信息。根据点击分布来判断A和B环境的优劣。</p><p style="overflow-x: auto; width: 964.25px; overflow-y: hidden; font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><img border="0" _href="img://image1.jpg" _p="true" src="http://www.infoq.com/resource/articles/cyw-evaluate-seachengine-result-quality/zh/resources/image18.jpg" alt="" style="border: 0px; display: block; float: none; margin-left: auto; margin-right: auto; " /></p><p align="center" style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; "><strong>Interleaving Testing评估方法</strong></p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">Joachims同时证明了Interleaving Testing评价方法与传统Cranfield评价方法的结果具有较高的相关性。由于记录用户选择检索结果的行为是一个不耗费人力的过程，因此可以便捷的实现自动化的搜索效果评估。</p><h2>总结</h2><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">没有评估就没有进步&#8212;&#8212;对搜索效果的量化评测，目的是准确的找出现有搜索系统的不足（没有哪个搜索系统是完美的），进而一步一个脚印对算法、系统进行改进。本文为大家总结了常用的评价框架和评价指标。这些技术像一把把尺子，度量着搜索技术每一次前进的距离。</p><hr style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; " /><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">感谢<a href="http://www.infoq.com/cn/bycategory.action?authorName=%E5%BC%A0%E5%87%AF%E5%B3%B0" style="color: #0b59b2; ">张凯峰</a>对 本文的审校。</p><p style="font-family: Lucida, 'Lucida Grande', Tahoma, sans-serif; font-size: 13px; line-height: 19px; background-color: #ffffff; ">给InfoQ中文站投稿或者参与内容翻译工作，请邮件至<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#101;&#100;&#105;&#116;&#111;&#114;&#115;&#64;&#99;&#110;&#46;&#105;&#110;&#102;&#111;&#113;&#46;&#99;&#111;&#109;" style="color: #0b59b2; ">editors@cn.infoq.com</a>。也欢迎大家加入到<a target="_blank" href="http://groups.google.com/group/InfoQChina" style="color: #0b59b2; ">InfoQ中文站用户讨论组</a>中与我们的编辑和其他读者 朋友交流。</p><img src ="http://www.cppblog.com/humanchao/aggbug/196436.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/humanchao/" target="_blank">胡满超</a> 2012-12-19 11:03 <a href="http://www.cppblog.com/humanchao/archive/2012/12/19/196436.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>