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 pd.DataFrame(embeddings.T).corr().iloc[0, 1] |