赞
踩
参考:https://www.sbert.net/docs/quickstart.html
sentence_transformers 基于transformers库
from sentence_transformers import SentenceTransformer,util
## cache_folder指定保存路径
model1 = SentenceTransformer('peterchou/simbert-chinese-base',cache_folder =r"D:\simcse")
embeddings1 = model1.encode("语言模型", show_progress_bar=True)
embeddings2 = model1.encode("自然语言", show_progress_bar=True)
print(embeddings1)
cos_sim = util.cos_sim(embeddings1, embeddings2)
print("Cosine-Similarity:", cos_sim)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。