Aytaj commited on
Commit
8e9e777
1 Parent(s): 0be776f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from sentence_transformers import SentenceTransformer
3
+ import numpy as np
4
+
5
+ st.title("Sentence Similarity")
6
+
7
+ st.write("This app uses Sentence Transformer to calculate the similarity between two sentences.")
8
+
9
+ sentence1 = st.text_input("Enter the first sentence")
10
+ sentence2 = st.text_input("Enter the second sentence")
11
+
12
+ if st.button("Calculate Similarity"):
13
+ model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
14
+ embeddings = model.encode([sentence1, sentence2])
15
+ similarity = np.dot(embeddings[0], embeddings[1])
16
+ st.write("The similarity between the two sentences is:", similarity)