innocent-charles
commited on
Commit
•
fd06722
1
Parent(s):
707dfd2
Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ model = SentenceTransformer('sartifyllc/AviLaBSE')
|
|
7 |
# Function to compute similarities
|
8 |
def compute_similarity(original_sentence, sentences_to_compare):
|
9 |
# Encode the original sentence and the sentences to compare
|
10 |
-
embeddings_original = model.encode([original_sentence])
|
11 |
-
embeddings_sentences_to_compare = model.encode(sentences_to_compare)
|
12 |
|
13 |
# Compute cosine similarities
|
14 |
similarities = util.cos_sim(embeddings_original, embeddings_sentences_to_compare)
|
@@ -34,7 +34,7 @@ iface = gr.Interface(
|
|
34 |
gr.Textbox(label="Sentence 2"),
|
35 |
gr.Textbox(label="Sentence 3")
|
36 |
],
|
37 |
-
outputs=gr.
|
38 |
title="Sentence Similarity Calculator",
|
39 |
description="Enter an original sentence and three sentences to compare their similarity."
|
40 |
)
|
|
|
7 |
# Function to compute similarities
|
8 |
def compute_similarity(original_sentence, sentences_to_compare):
|
9 |
# Encode the original sentence and the sentences to compare
|
10 |
+
embeddings_original = model.encode([original_sentence], convert_to_tensor=True)
|
11 |
+
embeddings_sentences_to_compare = model.encode(sentences_to_compare, convert_to_tensor=True)
|
12 |
|
13 |
# Compute cosine similarities
|
14 |
similarities = util.cos_sim(embeddings_original, embeddings_sentences_to_compare)
|
|
|
34 |
gr.Textbox(label="Sentence 2"),
|
35 |
gr.Textbox(label="Sentence 3")
|
36 |
],
|
37 |
+
outputs=gr.Table(label="Similarity Scores", headers=["Sentence", "Similarity Score"]),
|
38 |
title="Sentence Similarity Calculator",
|
39 |
description="Enter an original sentence and three sentences to compare their similarity."
|
40 |
)
|