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()