import streamlit as st import numpy as np from sentence_transformers import SentenceTransformer from sklearn.metrics.pairwise import cosine_similarity import spacy nlp = spacy.load("en_core_web_sm") model = SentenceTransformer("rufimelo/Legal-BERTimbau-sts-base") def compute_similarity(left_text: str, right_text: str) -> np.ndarray: embeddings = model.encode([left_text, right_text]) similarity = cosine_similarity(embeddings[0], embeddings[1]) return similarity first = st.text_input('First', 'This is a test') second = st.text_input('Second', 'This is another test') s = compute_similarity(left_text=first, right_texts=second) st.datafeame(s)