gpt4 book ai didi

python - 使用 gensim 加载 FastText 的法语预训练模型时出错

转载 作者:行者123 更新时间:2023-12-03 16:24:37 26 4
gpt4 key购买 nike

我正在尝试使用 FastText 的法语预训练二进制模型(从官方 FastText's github page 下载)。我需要 .bin模型而不是 .vec词向量以近似拼写错误和词汇外的词。
但是,当我尝试加载所述模型时,使用:

from gensim.models import FastText
model = FastText.load_fasttext_format('french_bin_model_path')
我收到以下错误:
NotImplementedError: Supervised fastText models are not supported
令人惊讶的是,当我尝试加载 时它工作得很好。英文 二元模型。
我正在运行 python 3.6 和 gensim 3.5.0。
欢迎任何关于为什么它不适用于法语矢量的想法!

最佳答案

我遇到了同样的问题并最终使用了 Facebook python wrapper 用于 FastText 而不是 gensim 的实现。

import fastText 
model = fastText.load(path_to_french_bin)

然后,您可以获得词汇表外单词的词向量,如下所示:
oov_vector = model.get_word_vector(oov_word)
至于为什么gensim的 load_fasttext_format适用于英国模型而不是我不知道的法国模型!

关于python - 使用 gensim 加载 FastText 的法语预训练模型时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51481553/

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