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

Loading embeddings #22

Open
Joseph94m opened this issue Oct 13, 2018 · 3 comments
Open

Loading embeddings #22

Joseph94m opened this issue Oct 13, 2018 · 3 comments

Comments

@Joseph94m
Copy link

Hi,

I downloaded the French embeddings, and extracted the zip file.
How can I load these embeddings in a python code and return the embeddings for a specified word, e.g.: embedding("bonjour") -----> [0.2, -0,2, etc...]

Thanks

@nvietsang
Copy link

nvietsang commented Mar 12, 2019

You can use gensim to load the .bin model:

from gensim.models import Word2Vec
model = Word2Vec.load("vi.bin")
model.wv['nhà']

Then, you will get the embedding vector of the word "nhà", in Vietnamese for example.
Remember to install gensim library

@fadeawaygod
Copy link

fadeawaygod commented Mar 13, 2019

But it didn't work with FastText, below is my code:

from gensim.models import FastText

model_f = FastText.load("zh.bin")
v = model_f.wv['你好']`

It throws a exception:
Exception has occurred: _pickle.UnpicklingError
invalid load key, ','.

@fadeawaygod
Copy link

fadeawaygod commented Mar 13, 2019

But it didn't work with FastText, below is my code:

from gensim.models import FastText

model_f = FastText.load("zh.bin")
v = model_f.wv['你好']`

It throws a exception:
Exception has occurred: _pickle.UnpicklingError
invalid load key, ','.

I fixed it by replacing load with load_fasttext_format.

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