查询语言模型

Query Language Model


1 TFIDF

 在一份给定的文件里,词频(term frequency,TF)指的是某一个给定的词语在该文件中出现的频率。这个数字是对词数(term count)的归一化,以防止它偏向长的文件。(同一个词语在长文件里可能会比短文件有更高的词数,而不管该词语重要与否。)对于在某一特定文件里的词语  t_{i}  来说,它的重要性可表示为:

  \mathrm{tf_{i,j}} = \frac{n_{i,j}}{\sum_k n_{k,j}}

      以上式子中 n_{i,j} 是该词 t_{i}  在文件d_{j}中的出现次数,而分母则是在文件d_{j}中所有字词的出现次数之和

      逆向文件频率(inverse document frequency,IDF)是一个词语普遍重要性的度量。某一特定词语的IDF,可以由总文件数目除以包含该词语之文件的数目,再将得到的商取对数得到:

 \mathrm{idf_{i}} =  \log \frac{|D|}{|\{j: t_{i} \in d_{j}\}|}

其中

  • |D|:语料库中的文件总数
  •  |\{ j: t_{i} \in d_{j}\}| 包含词语 t_{i} 的文件数目(即 n_{i,j} \neq 0的文件数目)如果该词语不在语料库中,就会导致被除数为零,因此一般情况下使用1 + |\{j : t_{i} \in d_{j}\}|

然后

 \mathrm{tf{}idf_{i,j}} = \mathrm{tf_{i,j}} \times  \mathrm{idf_{i}}


2 BM25

考虑的是tf, qtf,和文档长度

Given a query Q, containing keywords {\displaystyle q_{1},...,q_{n}}q_1, ..., q_n, the BM25 score of a document D is:

{\displaystyle {\text{score}}(D,Q)=\sum _{i=1}^{n}{\text{IDF}}(q_{i})\cdot {\frac {f(q_{i},D)\cdot (k_{1}+1)}{f(q_{i},D)+k_{1}\cdot \left(1-b+b\cdot {\frac {|D|}{\text{avgdl}}}\right)}},}
{\displaystyle {\text{score}}(D,Q)=\sum _{i=1}^{n}{\text{IDF}}(q_{i})\cdot {\frac {f(q_{i},D)\cdot (k_{1}+1)}{f(q_{i},D)+k_{1}\cdot \left(1-b+b\cdot {\frac {|D|}{\text{avgdl}}}\right)}},}

where {\displaystyle f(q_{i},D)}f(q_i, D) is {\displaystyle q_{i}}q_{i}'s term frequency in the document D{\displaystyle |D|}|D| is the length of the document D in words, and avgdl is the average document length in the text collection from which documents are drawn. {\displaystyle k_{1}}k_{1} and b are free parameters, usually chosen, in absence of an advanced optimization, as {\displaystyle k_{1}\in [1.2,2.0]}k_1 \in [1.2,2.0] and {\displaystyle b=0.75}b = 0.75.[1] {\displaystyle {\text{IDF}}(q_{i})}\text{IDF}(q_i) is the IDF (inverse document frequency) weight of the query term {\displaystyle q_{i}}q_{i}. It is usually computed as:

{\displaystyle {\text{IDF}}(q_{i})=\log {\frac {N-n(q_{i})+0.5}{n(q_{i})+0.5}},}
\text{IDF}(q_i) = \log \frac{N - n(q_i) + 0.5}{n(q_i) + 0.5},

where N is the total number of documents in the collection, and {\displaystyle n(q_{i})}n(q_i) is the number of documents containing {\displaystyle q_{i}}q_{i}.


3 Query likelihood

Rank documents by the probability that the query could be generated by the document model (i.e. same topic)

Given query, start with P(D|Q)

Using Bayes Rule

 

Assuming prior is uniform, unigram model



Jelinek-Mercer Smoothing】 


C_q_i:q_i在语料中出现的次数;|C|:语料中总词数(不是词汇数,相同的词可算多次)

Dirichlet Smoothing】 

4 K-L Divergence

描述两个分布的差异程度


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值