Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
!pip3 install --upgrade tensorflow-gpu
# Install TF-Hub.
!pip3 install tensorflow-hub
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
module_url = ""
model = hub.load(module_url)
print ("module %s loaded" % module_url)
sentence_embeddings = model(sentences)
query = "I had pizza and pasta"
query_vec = model([query])[0]
for sent in sentences:
sim = cosine(query_vec, model([sent])[0])
print("Sentence = ", sent, "; similarity = ", sim)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment