7

I am facing below issue while loading the pretrained BERT model from HuggingFace due to SSL certificate error.

Error:

SSLError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /dslim/bert-base-NER/resolve/main/tokenizer_config.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)')))

The line that is causing the issue is:

tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")

Source code:

from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
model = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")

I am expecting to download pre-trained models while running the code in jupyter lab on Windows.

Nikita Malviya
  • 181
  • 1
  • 2
  • 7

5 Answers5

6

Try to add the following in your main python file

import os

os.environ['CURL_CA_BUNDLE'] = ''
Herb
  • 91
  • 1
  • 5
3

A working solution to this is the following:

1)

 pip install requests==2.27.1   

Please note that both prerequisites need to take place, just running the following code will not work unless you have that specific version of requests (I had to downgrade in my case from 2.29.0 to 2.27.1.

2)

import os
os.environ['CURL_CA_BUNDLE'] = ''
Timbus Calin
  • 13,809
  • 5
  • 41
  • 59
0

This could be due to a firewall issue. For example for some organisations this occurs when using LAN but not with WIFI.

Aaron C
  • 301
  • 1
  • 8
0

conda install onnxruntime -c conda-forge\n

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 14 '23 at 16:44
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34679501) – Amolgorithm Jul 17 '23 at 05:12
0

A working solution for this is Enable your device for development.

if you're writing software with Visual Studio on a computer for the first time, you will need to enable Developer Mode on both the development PC and on any devices you'll use to test your code.

Pitts
  • 1
  • 1