File size: 280 Bytes
325e69e
 
 
 
 
 
b337b8f
1
2
3
4
5
6
7
import pandas as pd
from sentence_transformers import SentenceTransformer
cmp_model = SentenceTransformer('uer/sbert-base-chinese-nli')

def compare(text0, text1):
    embeddings = cmp_model.encode([text0, text1])
    return int(pd.DataFrame(embeddings.T).corr().iloc[0, 1] * 100)