Create synonyms.py
Browse files- 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]
|