Skip to content

Doc.similarity either outputting 0 or 1 (only when it's the same string) #11115

@JayThibs

Description

@JayThibs

How to reproduce the behaviour

When I run the code below, I get a score of 0.0. I only get a score of 1 if I use "apple" for doc2. Everything else it 0.

!pip install -U pip setuptools wheel --quiet
!pip install -U 'spacy[cuda113]' --quiet
!python -m spacy download en_core_web_trf --quiet
import spacy
nlp = spacy.load("en_core_web_trf")
doc1 = nlp(u"apple")
doc2 = nlp(u"green apple")
doc1.similarity(doc2)

Any ideas what's wrong?

Your Environment

  • Operating System: Colab
  • Python Version Used: 3.7
  • spaCy Version Used: Latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions