Skip to content

Instantly share code, notes, and snippets.

@martinthenext
Created January 25, 2019 15:15
Show Gist options
  • Save martinthenext/e30ae18916b4f21394ffc94bf341e9e5 to your computer and use it in GitHub Desktop.
Save martinthenext/e30ae18916b4f21394ffc94bf341e9e5 to your computer and use it in GitHub Desktop.
from sklearn.metrics.pairwise import cosine_similarity
similarity = cosine_similarity(question_repr, sentence_repr)
ranks = (-similarity).argsort(axis=None)
context_sentences[ranks[0]]
'During the middle of 2010, iPhone sales overtook those of the iPod.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment