spaCy - Universal Sentence Encoder

Make use of Google's Universal Sentence Encoder directly within spaCy

This library lets you use Universal Sentence Encoder embeddings of Docs, Spans and Tokens directly from TensorFlow Hub


import spacy_universal_sentence_encoder # load one of the models: ['en_use_md', 'en_use_lg', 'xx_use_md', 'xx_use_lg'] nlp = spacy_universal_sentence_encoder.load_model('en_use_lg') # get two documents doc_1 = nlp('Hi there, how are you?') doc_2 = nlp('Hello there, how are you doing today?') # use the similarity method that is based on the vectors, on Doc, Span or Token print(doc_1.similarity(doc_2[0:7]))
Author info

Martino Mensio


Categories models pipeline

Found a mistake or something isn't working?

If you've come across a universe project that isn't working or is incompatible with the reported spaCy version, let us know by opening a discussion thread.

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