-
-
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
FastText model gets error with typical methods #1343
Comments
@beeva-enriqueotero For fastText trained models, parameter A proper way of using from gensim.models.wrappers import FastText
model = FastText.load_fasttext_format('wiki.es')
print model.doesnt_match("rey reina patata".split()) |
To load the full FastText model, you need the from gensim.models.wrappers import FastText
model = FastText.load_fasttext_format('wiki.es') # Note that you don't specify .bin or .vec, both files are loaded
print model.doesnt_match("rey reina patata".split())
print model.most_similar("rey") The full model allows you to use out-of-vocabulary words. If you only wish to use the from gensim.models.keyedvectors import KeyedVectors
model = KeyedVectors.load_word2vec_format('wiki.es.vec')
print model.doesnt_match("rey reina patata".split())
print model.most_similar("rey") Note that using only the |
@jayantj - should 2nd line of your 1st "use of the full model" code block really be |
Thanks - fixed. |
@jayantj I've seen several questions about this functionality now. Worth adding to the gensim FAQ? |
Thanks for your answers! However when I tried I guess this issue is related to #1236 Any further advance regarding this error? Regards
|
@beeva-enriqueotero PR #1319 (supporting both old and new fastText model) resolves this mismatch error. It should be merged very soon. For now, you can load the model using only |
@piskvorky Yes, that would be a good idea. Let's wait for #1319 to be merged though, as the version in master/develop right now doesn't have the latest changes required to load the newer FastText models. |
Fixed in #1319 |
Thank you very much for your quick and efficient answers! :) |
I'm using fasttext binaries files trained before
The error is: AttributeError: 'FastText' object has no attribute 'get_nearest_neighbors' |
@eduamf You're commenting on a ticket that was resolved over 3 years ago. Please open a new ticket and fill out the template. |
@eduamf method |
Description
I get an error with (Spanish) FastText model and methods
doesnt_match
, ormost_similar
:AttributeError: 'FastTextKeyedVectors' object has no attribute 'syn0_all'
Steps/Code/Corpus to Reproduce
Download pretrained (Spanish) .vec
Expected Results
patata
Actual Results
Versions
Linux-4.4.0-75-generic-x86_64-with-Ubuntu-16.04-xenial
('Python', '2.7.12 (default, Nov 19 2016, 06:48:10) \n[GCC 5.4.0 20160609]')
('NumPy', '1.12.1')
('SciPy', '0.19.0')
('gensim', '2.1.0')
('FAST_VERSION', 1)
I've tried also gensim versions 2.0.0 and 1.0.1 with same results.
The text was updated successfully, but these errors were encountered: