Spaces:
Runtime error
Runtime error
Download app.py from thoristhor/simscore: direct link, hf CLI and curl.
- Browser
- Download file 512 Bytes
-
https://huggingface.co/spaces/thoristhor/simscore/resolve/main/app.py
- Command line
-
hf download hf://spaces/thoristhor/simscore/app.py
-
curl -L -o app.py https://huggingface.co/spaces/thoristhor/simscore/resolve/main/app.py
512 Bytes
| 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() |