How to resolve DeprecationWarning: Call to deprecated glove2word2vec

1,614 views
Skip to first unread message

Hsmann

unread,
Apr 5, 2021, 7:01:00 PM4/5/21
to Gensim
Gensim Version: 4.0.1

Code:

from gensim.models import KeyedVectors

from gensim.scripts.glove2word2vec import glove2word2vec

input-file

file_glove_wiki = folder / "glove.6B.300d.txt"

output-file 

file_glove_wiki_w2vec_format = folder / "glove.6B.300d.word2vec.txt"

save in word2vec format

glove2word2vec(file_glove_wiki,file_glove_wiki_w2vec_format)

load model 

glove_wiki = KeyedVectors.load_word2vec_format(file_glove_wiki_w2vec_format,binary=False)


Warning message :
DeprecationWarning: Call to deprecated `glove2word2vec` (KeyedVectors.load_word2vec_format(.., binary=False, no_header=True) loads GLoVE text vectors.).

How can I resolve this warning message?

Gordon Mohr

unread,
Apr 5, 2021, 7:48:22 PM4/5/21
to Gensim
Don't call the now-deprecated `glove2wod2vec()` function. As the warning message notes: "KeyedVectors.load_word2vec_format(.., binary=False, no_header=True) loads GLoVE text vectors." So you can skip the explicit conversion, and just use that instead:

    glove_wiki = KeyedVectors.load_word2vec_format(file_glove_wiki, binary=False, no_header=True)

(This read will require 2 passes, so you might still want to re-save it, with `.save_word2vec_format()`, if load-speed is a concern.)

- Gordon

Hsmann

unread,
Apr 5, 2021, 11:58:23 PM4/5/21
to Gensim
It worked perfectly.

Thanks
Harpreet

Reply all
Reply to author
Forward
0 new messages