I understand that spacy 2 alpha (or called spacy-nightly) is building vectors of words based on their context - so I do understand differences between values of similarity for words in nlp('apples oranges') and separated nlp('apples') and nlp('oranges') (and of course I am using different models for spacy 1 and spacy 2). But what I do not understand how I am suppose to call/input strings let say into similarity method.
Do they changed data model? I have not found anything in documentation... Am I doing something wrong - i.e. are my results reasonable?
Of course I am running those codes in separated virtual environments
spacy 1 - this works fine:
print(nlp('apples').similarity(nlp('oranges')))
# 0.77809414836
spacy 2 - this returns 0.0 - so it does not work:
print(nlp('apples').similarity(nlp('oranges')))
# 0.0
Any ideas? Code below shows what works for me and what does not..
import spacy # version spacy (1.9.0)
nlp = spacy.load('en_core_web_md')
doc = nlp('apples oranges')
print(doc[0].similarity(doc[1]))
#0.77809414836
print(nlp('apples')[0].similarity(nlp('oranges')[0]))
#0.77809414836
print(nlp('apples').similarity(nlp('oranges')))
# 0.77809414836
#----------------
import spacy # spacy-nightly (2.0.0a14)
nlp = spacy.load('en_core_web_sm')
doc = nlp('apples oranges')
print(doc[0].similarity(doc[1]))
# 0.630915
print(nlp('apples')[0].similarity(nlp('oranges')[0]))
# 0.892392
print(nlp('apples').similarity(nlp('oranges')))
# 0.0