You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用bert-base-nli-mean-tokens模型时遇ProxyError问题求助

解决调用bert-base-nli-mean-tokens时的ProxyError问题

错误原因

你的代理仅支持HTTP协议,但代码请求Hugging Face的HTTPS地址时,代理无法正确处理SSL请求,触发了SSL版本不匹配错误。

解决方法

  • 修改代理配置为HTTP协议
    无论是系统环境变量还是代码内设置,将HTTPS代理的地址改为HTTP开头(即使目标地址是HTTPS):

    import os
    # 替换成你的代理地址和端口
    os.environ['HTTP_PROXY'] = 'http://proxy-host:proxy-port'
    os.environ['HTTPS_PROXY'] = 'http://proxy-host:proxy-port'
    
    from sentence_transformers import SentenceTransformer
    model = SentenceTransformer('bert-base-nli-mean-tokens')
    body = list(data['preprocessedBody'])
    bodyEmbedding = model.encode(body, show_progress_bar=True)
    

    如果是系统环境变量,直接修改HTTPS_PROXY的值为HTTP开头的代理地址即可。

  • 本地加载模型
    手动下载sentence-transformers/bert-base-nli-mean-tokens的全部文件,保存到本地目录(比如./local-models/bert-base-nli-mean-tokens),然后修改代码加载本地模型:

    model = SentenceTransformer('./local-models/bert-base-nli-mean-tokens')
    
  • 检查代理兼容性
    确认你的代理是否真的不支持HTTPS,如果支持,检查代理地址、端口是否配置正确,排除地址错误或端口不通的情况。

内容的提问来源于stack exchange,提问作者python_pi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 17:25:26