python huggingface模型超时的解决方案
以embedding模型为例
- 修改之前的代码
from langchain_huggingface import HuggingFaceEmbeddings
bge_embeddings = HuggingFaceEmbeddings(model_name="BAAI/bge-small-zh-v1.5", cache_folder="./models")
- 修改之后的代码
import os
from langchain_huggingface import HuggingFaceEmbeddings
os.environ['HF_ENDPOINT'] = r'https://hf-mirror.com'
bge_embeddings = HuggingFaceEmbeddings(model_name="BAAI/bge-small-zh-v1.5", cache_folder="./models")
huggingface 镜像地址
【https://hf-mirror.com/】