-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not open and score a Word2vec model generated in v3.8.0 in v4.2.0 #3413
Comments
The way to load (and save) Gensim models is using this pattern: https://radimrehurek.com/gensim/models/word2vec.html#usage-examples It looks like you're doing something else – could that be the source of the error? |
@piskvorky model = Word2Vec.load("word2vec.model") didn't change anything model = Word2Vec(
window=6,
workers=6,
sg=0,
hs=1,
seed=21,
vector_size=300,
min_count=4,
batch_words=1000
)
model.build_vocab(cleaned_content, progress_per=10000)
logging.root.level = logging.ERROR # Temporarily reduce logging verbosity
model.train(
cleaned_content,
total_examples=model.corpus_count,
epochs=60,
report_delay=1
) |
I see. In that case, it should work. I'll try to check later, thanks for reporting. |
@piskvorky docker run -v $PWD:/app -w /app python:3.8-slim bash -c "pip install gensim==3.8.0; python -c \"from gensim.models import Word2Vec; model = Word2Vec(window=6,workers=6,sg=0,hs=1,seed=21,size=300,min_count=1,batch_words=1000); cleaned_content=['test']; model.build_vocab(cleaned_content, progress_per=10000); model.train(cleaned_content,total_examples=model.corpus_count,epochs=60,report_delay=1); model.save('test.mdl')\""
docker run -v $PWD:/app -w /app python:3.8-slim bash -c "pip install gensim==4.2.0; python -c \"from gensim.models import Word2Vec; model = Word2Vec.load('test.mdl'); model.score(['test'])\"" Please let me know if I can help you further |
I found this dodgy code in Gensim that's probably the culprit: This is a part of the code that loads (converts) old models. I'll have to check the commit history to see what this is about (CC @gojomo ), but could you try removing that block and see if that helps? |
I traced the bug down to https://github.com/RaRe-Technologies/gensim/pull/2698/files Looks like a botched migration; @Wats0ns can you verify removing the 3 lines above fixes the issue, and then submit a PR? We're about to do a new release this week so we could still squeeze that in. Thanks. |
@Wats0ns please confirm the fix. |
@piskvorky I confirm that it works now with your fix, thanks a lot for your fast responses and fix, very impressed ! |
Problem description
Hello,
I'm trying to score a sentence in a script using gensim v4.2.0, with a model trained in v3.8.0. However, I meet the error
AttributeError: 'Word2Vec' object has no attribute 'syn1'
Steps/code/corpus to reproduce
Link to the model file: https://filetransfer.io/data-package/DIMOegMO#link
Versions
Thanks a lot !
The text was updated successfully, but these errors were encountered: