Skip to content
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

ImportError: cannot import name '_l2_norm' from 'gensim.models.keyedvectors #64

Closed
pratikkotian04 opened this issue Jan 12, 2022 · 2 comments

Comments

@pratikkotian04
Copy link

ImportError Traceback (most recent call last)

in ()
----> 1 from fse import Vectors, Average, IndexedList
2 vecs = Vectors.from_pretrained("fasttext-wiki-news-subwords-300")
3 model = Average(vecs)

3 frames

/usr/local/lib/python3.7/dist-packages/fse/models/base_s2v.py in ()
40
41 from gensim.models.base_any2vec import BaseWordEmbeddingsModel
---> 42 from gensim.models.keyedvectors import BaseKeyedVectors, FastTextKeyedVectors, _l2_norm
43 from gensim.utils import SaveLoad
44 from gensim.matutils import zeros_aligned

ImportError: cannot import name '_l2_norm' from 'gensim.models.keyedvectors' (/usr/local/lib/python3.7/dist-packages/gensim/models/keyedvectors.py)

@AleMuzzi
Copy link

Hi, I don't know which version of Gensim you are using but I can tell you that in versions >=4 the _l2_norm function has been removed from keyedvectors.py.
You can either choose to

  • edit your locally downloaded version of Gensim replacing _l2_norm with linalg.norm after adding linalg to the numpy import in the file's imports section
  • update your fse with the porting I just made for Gensim >=4 (which also solves this problem) by executing the command
pip install -U git+https://github.com/AleMuzzi/Fast_Sentence_Embeddings

works both as an upgrade and as a new version, pull request is waiting for approval (#65)

@oborchers
Copy link
Owner

Should be fixed in v1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants