Spaces:
Runtime error
Runtime error
initial stuff with en and fr demo example.
Browse files- .gitignore +1 -0
- app.py +20 -0
- requirements.txt +2 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.idea
|
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from sentence_transformers import SentenceTransformer, util
|
3 |
+
|
4 |
+
i18n_model = SentenceTransformer('distiluse-base-multilingual-cased-v2')
|
5 |
+
|
6 |
+
def inference(s1:str, s2:str):
|
7 |
+
score = util.cos_sim(i18n_model.encode(s1), i18n_model.encode(s2)).item()
|
8 |
+
return f'{score:.3f}'
|
9 |
+
|
10 |
+
gr.Interface(
|
11 |
+
inference,
|
12 |
+
[ gr.Textbox(label="Sentence 1"), gr.Textbox(label="Sentence 2") ],
|
13 |
+
[ gr.components.Label(label="Similarity score") ],
|
14 |
+
title="Similarity score between 2 sentences",
|
15 |
+
description="In this demo do provide 2 sentences bellow. They can even be in distinct languages. Powered by S-BERT multilingual model : https://www.sbert.net.",
|
16 |
+
examples=[['The sentences are mapped such that sentences with similar meanings are close in vector space.', 'Les phrases sont mappées de manière à ce que les phrases ayant des significations similaires soient proches dans l\'espace vectoriel.'],
|
17 |
+
['You do not need to specify the input language.', 'You can use any language.']],
|
18 |
+
live=True,
|
19 |
+
allow_flagging="never"
|
20 |
+
).launch(debug=True, enable_queue=True)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
sentence_transformers
|