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

most_similar() not working as expected (KeyError) #2648

Closed
neurotroph opened this issue Aug 9, 2018 · 5 comments
Closed

most_similar() not working as expected (KeyError) #2648

neurotroph opened this issue Aug 9, 2018 · 5 comments
Labels
bug Bugs and behaviour differing from documentation feat / vectors Feature: Word vectors and similarity

Comments

@neurotroph
Copy link

How to reproduce the behaviour

Using the en_core_web_lg model, I try to find the most similar word(s) for a given word or word vector:

import spacy
import numpy as np

nlp = spacy.load("en_core_web_lg")
tvec = nlp(u"dog").vector
# According to documentation in the source code (https:/explosion/spaCy/blob/3141e04822a8c40e0d64e51a040305ade3f66d8c/spacy/vectors.pyx#L269), an array with one or more vectors should be supplied
nlp.vocab.vectors.most_similar(np.array([tvec]))

This yields a KeyError:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "vectors.pyx", line 302, in spacy.vectors.Vectors.most_similar
KeyError: 0

Your Environment

  • spaCy version: 2.0.11
  • Platform: Windows-10-10.0.16299-SP0
  • Python version: 3.6.6
@poke1024
Copy link

Same problem here :(

spacy 2.0.11, macOS 10.13.6, python 3.6.6

@ahmedmagdiosman
Copy link

Same issue 😭
spacy 2.0.12, Ubuntu 16.04, python 3.6

@PadenZach
Copy link

Also having this issue...

spaCy version      2.0.12         
Location           /usr/lib/python3.7/site-packages/spacy
Platform           Linux-4.19.4-arch1-1-ARCH-x86_64-with-arch-18.9-Minimal-ISO-Rolling
Python version     3.7.1          
Models             en_core_web_lg 

Tried passing the vector in several ways, and all end up giving an error.

@honnibal honnibal added bug Bugs and behaviour differing from documentation feat / vectors Feature: Word vectors and similarity labels Dec 6, 2018
@honnibal
Copy link
Member

honnibal commented Dec 6, 2018

Thanks for the report, and sorry for the delay getting to this. Would you mind making a pull request with an xfail-ed test? The test should go in spacy/tests/regression.

@lock
Copy link

lock bot commented Jan 9, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs and behaviour differing from documentation feat / vectors Feature: Word vectors and similarity
Projects
None yet
Development

No branches or pull requests

5 participants