有了一個語言模型,就要判斷這個模型的好壞。
現在假設:
- 我們有一些測試數據,test data.測試數據中有m個句子;s1,s2,s3…,sm
我們也知道,如果計算相乘是非常麻煩的,可以在此基礎上,以另一種形式來計算模型的好壞程度。
在相乘的基礎上,運用Log,來把乘法轉換成加法來計算。
補充一下,在這里的p(Si)其實就等於我們前面所介紹的q(the|*,*)*q(dog|*,the)*q(…)…
有了上面的式子,評價一個模型是否好壞的原理在於:
a good model should assign as high probability as possible to these test data sentences.
,this value as being a measure of how well the alleviate to make sth less painful or difficult to deal with language model predict these test data sentences.
The higher the better.
- 實際上,普遍的評價的指標是perplexity
其中,M的值是測試數據test data中的所有的數量。
那么從公式當中查看,可以知道。perplexity的值越小越好。
為了更好的理解perplexity,看下面這個例子:
- 我們現在有一個單詞集V,N=|V|+1
有了上面的條件,可以很容易的計算出:
Perplexity是測試branching factor的數值。
branching factor又是什么呢?有的翻譯為分叉率。如果branching factor高,計算起來代價會越大。也可以理解成,分叉率越高,可能性就越多,需要計算的量就越大。
上面的例子q=1/N只是一個舉例,再看看下面這些真實的數據:
- Goodman的結果,其中|V|=50000,在trigram model的
中,Perplexity=74 - 在bigram model中,
,Perplexity=137 - 在unigram model中,
,perplexity=955
在這里也看到了,幾個模型的perplexity的值是不同的,這也就表明了三元模型一般是性能良好的。




