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