You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
622 B

1 month ago
'''
# 安装向量化的包 # 断开VPN后执行安装包
conda activate rag
pip install text2vec torch torchvision torchaudio
'''
1 month ago
from text2vec import SentenceModel
sentences = ['如何更换花呗绑定银行卡', '花呗更改绑定银行卡']
1 month ago
'''
- 自动下载预训练模型到缓存目录通常是 ~/.cache/huggingface/hub
- 后续运行会直接使用缓存
1 month ago
1 month ago
如果下载慢可以设置镜像源
import os
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
'''
1 month ago
model = SentenceModel('shibing624/text2vec-base-chinese')
embeddings = model.encode(sentences)
print(embeddings)