Spaces:
Runtime error
Runtime error
Commit
·
418bd7c
1
Parent(s):
88993fe
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,20 +9,12 @@ model = SentenceTransformer('paraphrase-xlm-r-multilingual-v1')
|
|
| 9 |
|
| 10 |
sentences = []
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
for sentence, embedding in zip(sentences, sentence_embeddings):
|
| 15 |
-
print("Sentence:", sentence)
|
| 16 |
-
print("Embedding:", embedding)
|
| 17 |
-
print("")
|
| 18 |
-
|
| 19 |
-
print('Similarity between {} and {} is {}'.format(sentences[0],
|
| 20 |
-
sentences[1],
|
| 21 |
-
cosine_similarity(sentence_embeddings[0].reshape(1, -1),
|
| 22 |
-
sentence_embeddings[1].reshape(1, -1))[0][0]))
|
| 23 |
-
|
| 24 |
st.title("Sentence Similarity")
|
| 25 |
|
|
|
|
|
|
|
| 26 |
sentence_1 = st.text_input("Sentence 1 input")
|
| 27 |
|
| 28 |
sentence_2 = st.text_input("Sentence 2 input")
|
|
@@ -30,6 +22,11 @@ sentence_2 = st.text_input("Sentence 2 input")
|
|
| 30 |
submit_button = st.button("submit")
|
| 31 |
|
| 32 |
if st.button('submit'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
sentences.append(sentence_1)
|
| 34 |
sentences.append(sentence_2)
|
| 35 |
st.write(sentences)
|
|
|
|
| 9 |
|
| 10 |
sentences = []
|
| 11 |
|
| 12 |
+
# Streamlit interface
|
| 13 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
st.title("Sentence Similarity")
|
| 15 |
|
| 16 |
+
# Streamlit webpage elements
|
| 17 |
+
|
| 18 |
sentence_1 = st.text_input("Sentence 1 input")
|
| 19 |
|
| 20 |
sentence_2 = st.text_input("Sentence 2 input")
|
|
|
|
| 22 |
submit_button = st.button("submit")
|
| 23 |
|
| 24 |
if st.button('submit'):
|
| 25 |
+
|
| 26 |
+
# Perform calculations
|
| 27 |
+
|
| 28 |
+
sentence_embeddings = model.encode(sentences)
|
| 29 |
+
|
| 30 |
sentences.append(sentence_1)
|
| 31 |
sentences.append(sentence_2)
|
| 32 |
st.write(sentences)
|