Spaces:
Sleeping
Sleeping
File size: 1,207 Bytes
4ad1414 16e2733 4ad1414 36401c9 da58e58 16e2733 da58e58 16e2733 4ad1414 da58e58 d1d829b a704e92 16e2733 da58e58 16e2733 da58e58 16e2733 da58e58 d1d829b a704e92 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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_area('First', 'This is a test')
right_text = st.text_area('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.info("Legal-BERTimbau-sts-base: score ->")
st.dataframe(similarity)
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.info("legal-bert-base-uncased: score ->")
st.dataframe(similarity)
|