Update sentence_compare.py
Browse files- sentence_compare.py +2 -2
sentence_compare.py
CHANGED
@@ -8,11 +8,11 @@ from sentence_transformers import util
|
|
8 |
|
9 |
def compare(input):
|
10 |
lines = input.splitlines()
|
11 |
-
embeddings1 = model.encode(lines[0], convert_to_tensor=True)
|
12 |
embeddings2 = model.encode(lines[1], convert_to_tensor=True)
|
13 |
cosine_scores = util.cos_sim(embeddings1, embeddings2)
|
14 |
return "Score: {:.4f} \t\t {} \t\t {}".format(cosine_scores[0][0], lines[0], lines[1])
|
15 |
|
16 |
model = SentenceTransformer("all-MiniLM-L6-v2")
|
17 |
-
demo = gr.Interface(fn=compare, inputs="
|
18 |
demo.launch()
|
|
|
8 |
|
9 |
def compare(input):
|
10 |
lines = input.splitlines()
|
11 |
+
embeddings1 = model.encode(lines[0], convert_to_tensor=True)
|
12 |
embeddings2 = model.encode(lines[1], convert_to_tensor=True)
|
13 |
cosine_scores = util.cos_sim(embeddings1, embeddings2)
|
14 |
return "Score: {:.4f} \t\t {} \t\t {}".format(cosine_scores[0][0], lines[0], lines[1])
|
15 |
|
16 |
model = SentenceTransformer("all-MiniLM-L6-v2")
|
17 |
+
demo = gr.Interface(fn=compare, inputs="textarea", outputs="text")
|
18 |
demo.launch()
|