gpt4 book ai didi

python - 继续训练 FastText 模型

转载 作者:太空宇宙 更新时间:2023-11-04 04:34:19 33 4
gpt4 key购买 nike

我已经下载了一个.bin FastText 模型,我将它与gensim 一起使用,如下所示:

model = FastText.load_fasttext_format("cc.fr.300.bin")

我想继续训练模型以使其适应我的领域。检查后FastText's GithubGensim documentation从使用此人建议的 modification 来看,目前看来它是可行的(尚未合并)。

我错过了什么吗?

最佳答案

您可以继续使用某些版本的 Gensim fastText(例如,v.3.7.*)进行训练。这是“Loading, inferring, continuing training”的示例

from gensim.test.utils import datapath
model = load_facebook_model(datapath("crime-and-punishment.bin"))
sent = [['lord', 'of', 'the', 'rings'], ['lord', 'of', 'the', 'semi-groups']]
model.build_vocab(sent, update=True)
model.train(sentences=sent, total_examples = len(sent), epochs=5)

出于某种原因,gensim.models.fasttext.load_facebook_model() 在 Windows 上缺失,但在 Mac 上存在。或者,可以使用 gensim.models.FastText.load_fasttext_format() 加载预训练模型并继续训练。

这里有各种pre-trained Wiki word models and vectors (或 here )。

Another example . “注意:与 Word2Vec 的情况一样,您可以在使用 Gensim 的 fastText 本地实现的同时继续训练您的模型。

关于python - 继续训练 FastText 模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52080365/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com