svjack commited on
Commit
325e69e
1 Parent(s): 40dece0

Create synonyms.py

Browse files
Files changed (1) hide show
  1. synonyms.py +7 -0
synonyms.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from sentence_transformers import SentenceTransformer
3
+ cmp_model = SentenceTransformer('uer/sbert-base-chinese-nli')
4
+
5
+ def compare(text0, text1):
6
+ embeddings = cmp_model.encode([text0, text1])
7
+ return pd.DataFrame(embeddings.T).corr().iloc[0, 1]