Skip to content

如何加载模型 #162

@YiingWei

Description

@YiingWei

作者你好,当我用下面的代码尝试加载您的中文词向量模型

加载中英文词向量模型

ch_model = KeyedVectors.load_word2vec_format('./ch_model/merge_sgns_bigram_char300.txt', binary=True)
结果显示下面报错,应该如何解决呢
Traceback (most recent call last):
File "c:/Users/11323/Desktop/score_comment/socore_comments.py", line 127, in
ch_model = KeyedVectors.load_word2vec_format('./ch_model/merge_sgns_bigram_char300.txt', binary=True)
File "C:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\gensim\models\keyedvectors.py", line 1719, in
load_word2vec_format
return _load_word2vec_format(
File "C:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\gensim\models\keyedvectors.py", line 2065, in
_load_word2vec_format
_word2vec_read_binary(
File "C:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\gensim\models\keyedvectors.py", line 1960, in
_word2vec_read_binary
processed_words, chunk = _add_bytes_to_kv(
File "C:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\gensim\models\keyedvectors.py", line 1939, in
_add_bytes_to_kv
word = chunk[start:i_space].decode(encoding, errors=unicode_errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaf in position 0: invalid start byte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions