SRILM語言模型格式解讀

來源:互聯網
上載者:User

標籤:str   span   word   log   http   格式   htm   tag   ons   

先看一下語言模型的輸出格式

 

[html] view plain copy 
  1. \data\  
  2. ngram 1=64000  
  3. ngram 2=522530  
  4. ngram 3=173445  
  5.   
  6. \1-grams:  
  7. -5.24036        ‘cause  -0.2084827  
  8. -4.675221       ‘em     -0.221857  
  9. -4.989297       ‘n      -0.05809768  
  10. -5.365303       ‘til    -0.1855581  
  11. -2.111539       </s>    0.0  
  12. -99     <s>     -0.7736475  
  13. -1.128404       <unk>   -0.8049794  
  14. -2.271447       a       -0.6163939  
  15. -5.174762       a‘s     -0.03869072  
  16. -3.384722       a.      -0.1877073  
  17. -5.789208       a.‘s    0.0  
  18. -6.000091       aachen  0.0  
  19. -4.707208       aaron   -0.2046838  
  20. -5.580914       aaron‘s -0.06230035  
  21. -5.789208       aarons  -0.07077657  
  22. -5.881973       aaronson        -0.2173971  

(註:上面的值都是以10為底的對數值)

 


上面是一個語言模型的一部分,三元語言模型的綜合格式如下:

 

[html] view plain copy 
  1. \data  
  2. ngram 1=nr # 一元語言模型  
  3. ngram 2=nr # 二元語言模型  
  4. ngram 3=nr # 三元語言模型  
  5.    
  6. \1-grams:  
  7. pro_1 word1 back_pro1  
  8.    
  9. \2-grams:  
  10. pro_2 word1 word2 back_pro2  
  11.    
  12. \3-grams:  
  13. pro_3 word1 word2 word3  
  14.    
  15. \end\  

第一項表示ngram的條件機率,就是P(wordN | word1,word2,。。。,wordN-1)。

 

第二項表示ngram的詞。

最後一項是回退的權重。

 

舉例來說,對於三個連續的詞來說,我們計算三個詞一起出現的機率:

 

[html] view plain copy 
  1. P(word3|word1,word2)  

表示word1和word2出現的情況下word3出現的機率,比如P(平|習,進)的意思是已經出現了“習進”兩個字,後面是平的機率,這個機率這麼計算:

 

 

[html] view plain copy 
  1. if(存在(word1,word2,word3)的三元模型){  
  2.   
  3.     return pro_3(word1,word2,word3) ;  
  4.   
  5. }else if(存在(word1,word2)二元模型){  
  6.   
  7.     return back_pro2(word1,word2)*P(word3|word2) ;  
  8.   
  9. }else{  
  10.       
  11.     return P(word3 | word2);  
  12.   
  13. }  


上面的計算又集中在計算P(word3 | word2)的機率上,就是如果不存在習進平的三元模型,此時不管何種路徑,都要計算P(word3 | word2) 的機率,計算如下:

 

 

[html] view plain copy 
    1. if(存在(word1,word2)的二元模型){  
    2.   
    3.     return pro_2(word1,word2);  
    4.   
    5. }else{  
    6.       
    7.     return back_pro2(word1)*pro_1(word2) ;  
    8.   
    9. }  

SRILM語言模型格式解讀

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.