File size: 512 Bytes
1dad570
566338a
 
 
 
1dad570
 
773849a
 
 
 
1dad570
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from sentence_transformers.util import cos_sim
import gradio as gr
module_url = "https://tfhub.dev/google/universal-sentence-encoder/4"
import tensorflow_hub as hub
model = hub.load(module_url)

def compute_similarity_score(name1, name2):
  vec1 = model([name1]).numpy().tolist()[0]
  vec2 = model([name2]).numpy().tolist()[0]
  print(vec1)              
  return cos_sim(vec1, vec2).numpy().tolist()[0][0]

iface = gr.Interface(fn=compute_similarity_score, inputs=["text","text"], outputs="text")
iface.launch()