【发布时间】:2019-11-26 12:16:22
【问题描述】:
在阅读了 gensim 的 docs 的教程后,我不明白从经过训练的模型生成新嵌入的正确方法是什么。到目前为止,我已经像这样训练了 gensim 的快速文本嵌入:
from gensim.models.fasttext import FastText as FT_gensim
model_gensim = FT_gensim(size=100)
# build the vocabulary
model_gensim.build_vocab(corpus_file=corpus_file)
# train the model
model_gensim.train(
corpus_file=corpus_file, epochs=model_gensim.epochs,
total_examples=model_gensim.corpus_count, total_words=model_gensim.corpus_total_words
)
然后,假设我想获得与这句话相关的嵌入向量:
sentence_obama = 'Obama speaks to the media in Illinois'.lower().split()
sentence_president = 'The president greets the press in Chicago'.lower().split()
如何使用我之前训练的model_gensim 获得它们?
【问题讨论】:
标签: machine-learning nlp gensim embedding