Use NLP to go beyond vanilla word2vec

sense2vec (Trask et. al, 2015) is a nice twist on word2vec that lets you learn more interesting, detailed and context-sensitive word vectors. For an interactive example of the technology, see our sense2vec demo that lets you explore semantic similarities across all Reddit comments of 2015.


import spacy nlp = spacy.load("en_core_web_sm") s2v = nlp.add_pipe("sense2vec") s2v.from_disk("/path/to/s2v_reddit_2015_md") doc = nlp("A sentence about natural language processing.") assert doc[3:6].text == "natural language processing" freq = doc[3:6]._.s2v_freq vector = doc[3:6]._.s2v_vec most_similar = doc[3:6]._.s2v_most_similar(3) # [(('machine learning', 'NOUN'), 0.8986967), # (('computer vision', 'NOUN'), 0.8636297), # (('deep learning', 'NOUN'), 0.8573361)]

View more
Author info



Categories pipeline standalone visualizers

Submit your project

If you have a project that you want the spaCy community to make use of, you can suggest it by submitting a pull request to the spaCy website repository. The Universe database is open-source and collected in a simple JSON file. For more details on the formats and available fields, see the documentation. Looking for inspiration your own spaCy plugin or extension? Check out the project idea label on the issue tracker.

Read the docsJSON source