Spaces:
Runtime error
Runtime error
File size: 757 Bytes
acf0ee9 6ddfa35 9c7a582 6b02e3d be8daf6 6b02e3d 4c9ba47 e922469 4c9ba47 be8daf6 acf0ee9 be8daf6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import streamlit as st
import torch
from transformers import AutoTokenizer, AutoModel
# load the pre-trained model
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
# set the app title
st.title("Brazilian Portuguese Sentence Similarity Checker")
# get the input sentences from the user
sentence1 = st.text_input("Enter the first sentence:")
sentence2 = st.text_input("Enter the second sentence:")
# check if both sentences are not empty
if sentence1 and sentence2:
embedding_1= model.encode(sentence1, convert_to_tensor=True)
embedding_2 = model.encode(sentence2, convert_to_tensor=True)
similarity = util.pytorch_cos_sim(embedding_1, embedding_2)
st.write("Similarity score between the sentences:", similarity) |