From fdbab5f3ae4d9c80e76c6f012ea577146365208c Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Mon, 23 Jun 2025 15:59:10 +0800 Subject: [PATCH] 'commit' --- dsRag/T2_Txt2Vec.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dsRag/T2_Txt2Vec.py b/dsRag/T2_Txt2Vec.py index ec021191..fc99afa3 100644 --- a/dsRag/T2_Txt2Vec.py +++ b/dsRag/T2_Txt2Vec.py @@ -1,12 +1,20 @@ -# 安装向量化的包 -# conda activate rag -# 断开VPN后执行安装包 -# pip install text2vec +''' +# 安装向量化的包 (# 断开VPN后执行安装包) +conda activate rag +pip install text2vec torch torchvision torchaudio +''' from text2vec import SentenceModel sentences = ['如何更换花呗绑定银行卡', '花呗更改绑定银行卡'] +''' +- 自动下载预训练模型到缓存目录(通常是 ~/.cache/huggingface/hub ) +- 后续运行会直接使用缓存 +如果下载慢,可以设置镜像源: +import os +os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com' +''' model = SentenceModel('shibing624/text2vec-base-chinese') embeddings = model.encode(sentences) print(embeddings) \ No newline at end of file