语言模型
p
(
w
i
∣
w
i
−
4
,
w
i
−
3
,
w
i
−
2
,
w
i
−
1
)
p(w_i|w_{i-4}, w_{i-3}, w_{i-2}, w_{i-1})
p(wi∣wi−4,wi−3,wi−2,wi−1)
在得到前4个词后,得到当前词的概率最大。
实例展示
import gensim.downloader as api
#%%
info = api.info()
print(info)
"""
corpora: ['semeval-2016-2017-task3-subtaskBC', 'semeval-2016-2017-task3-subtaskA-unannotated', 'patent-2017',
'quora-duplicate-questions', 'wiki-english-20171001', 'text8', 'fake-news', '20-newsgroups',
'__testing_matrix-synopsis', '__testing_multipart-matrix-synopsis']
models:['fasttext-wiki-news-subwords-300', 'conceptnet-numberbatch-17-06-300', 'word2vec-ruscorpora-300',
'word2vec-google-news-300', 'glove-wiki-gigaword-50', 'glove-wiki-gigaword-100', 'glove-wiki-gigaword-200',
'glove-wiki-gigaword-300', 'glove-twitter-25', 'glove-twitter-50', 'glove-twitter-100', 'glove-twitter-200',
'__testing_word2vec-matrix-synopsis']
"""
#%%
model = api.load('glove-wiki-gigaword-50')
#%%
result = model.most_similar('cat') # change the word as you like
print(result)