LegalSimilarity / app.py
bikram-riverus's picture
model compare
da58e58 verified
raw
history blame
1.1 kB
import streamlit as st
import numpy as np
from sentence_transformers import SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity
import spacy
left_text = st.text_input('First', 'This is a test')
right_text = st.text_input('Second', 'This is another test')
st.toast("Loading spacy...")
nlp = spacy.load("en_core_web_sm")
st.toast("Loading rufimelo/Legal-BERTimbau-sts-base...")
model = SentenceTransformer("rufimelo/Legal-BERTimbau-sts-base")
st.toast("Legal-BERTimbau-sts-base: computing embeddings...")
embeddings = model.encode([left_text, right_text])
st.toast("Legal-BERTimbau-sts-base: computing similarity...")
similarity = cosine_similarity(embeddings[: 1], embeddings[1 :])
st.dataframe(s)
st.toast("Loading nlpaueb/legal-bert-base-uncased...")
model = SentenceTransformer("nlpaueb/legal-bert-base-uncased")
st.toast("legal-bert-base-uncased: computing embeddings...")
embeddings = model.encode([left_text, right_text])
st.toast("legal-bert-base-uncased: computing similarity...")
similarity = cosine_similarity(embeddings[: 1], embeddings[1 :])
st.dataframe(s)