Spaces:
Sleeping
Sleeping
Update apps/similarity.py
Browse files- apps/similarity.py +3 -3
apps/similarity.py
CHANGED
@@ -10,7 +10,7 @@ def app():
|
|
10 |
st.write(
|
11 |
"""
|
12 |
Information cartography - Get your word/phrase/sentence/paragraph embedded and visualized.
|
13 |
-
The (English) sentence-transformers model "all-MiniLM-L6-v2" maps sentences & paragraphs to a 384 dimensional dense vector space This is normally used for tasks like clustering or semantic search, but in this case, we use it to calculate the (cosine) similarity. The sentence transformer is context sensitive and works best with whole sentences
|
14 |
|
15 |
Simply put in your text and press COMPARE, the higher the similarity the closer the text in the embedding space (max 1).
|
16 |
""")
|
@@ -28,9 +28,9 @@ def app():
|
|
28 |
with st.spinner("Embedding comparing your inputs"):
|
29 |
|
30 |
document = [word_to_embed1 ,word_to_embed2]
|
31 |
-
|
32 |
#Encode paragraphs
|
33 |
-
document_embeddings = model.encode(
|
34 |
#Compute cosine similarity between labels sentences and paragraphs
|
35 |
similarity_matrix = cosine_similarity(document_embeddings)
|
36 |
|
|
|
10 |
st.write(
|
11 |
"""
|
12 |
Information cartography - Get your word/phrase/sentence/paragraph embedded and visualized.
|
13 |
+
The (English) sentence-transformers model "all-MiniLM-L6-v2" maps sentences & paragraphs to a 384 dimensional dense vector space This is normally used for tasks like clustering or semantic search, but in this case, we use it to calculate the (cosine) similarity. The sentence transformer is context sensitive and works best with whole sentences.
|
14 |
|
15 |
Simply put in your text and press COMPARE, the higher the similarity the closer the text in the embedding space (max 1).
|
16 |
""")
|
|
|
28 |
with st.spinner("Embedding comparing your inputs"):
|
29 |
|
30 |
document = [word_to_embed1 ,word_to_embed2]
|
31 |
+
|
32 |
#Encode paragraphs
|
33 |
+
document_embeddings = model.encode(document , show_progress_bar=False)
|
34 |
#Compute cosine similarity between labels sentences and paragraphs
|
35 |
similarity_matrix = cosine_similarity(document_embeddings)
|
36 |
|