【问题标题】:Error when loading FastText's french pre-trained model with gensim使用 gensim 加载 FastText 的法语预训练模型时出错
【发布时间】:2018-07-23 14:43:44
【问题描述】:

我正在尝试使用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

令人惊讶的是,当我尝试加载 english 二进制模型时,它工作得很好

我正在运行 python 3.6 和 gensim 3.5.0。

欢迎任何关于为什么它不适用于法国向量的想法!

【问题讨论】:

    标签: python gensim pre-trained-model fasttext french


    【解决方案1】:

    我遇到了同样的问题,最终使用 Facebook python wrapper 代替了 gensim 的实现。

    import fastText 
    model = fastText.load(path_to_french_bin)
    

    然后你可以像这样获得词汇外单词的词向量:

    oov_vector = model.get_word_vector(oov_word)

    至于为什么 gensim 的 load_fasttext_format 适用于英国模型而不是法国模型,我不知道!

    【讨论】:

    • 这确实是我发现的唯一解决方法。谢谢!
    【解决方案2】:

    我从未使用过 FastText,但问题可能出在文件的编码上。如果您是 macOS,请尝试将其更改为 Utf-8;如果您使用的是 Windows,请尝试将其更改为 Latin-1。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-26
      • 1970-01-01
      • 2020-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-17
      相关资源
      最近更新 更多