培训Pytorch的Parsebert模型的问题

发布于 2025-02-06 19:02:57 字数 5889 浏览 2 评论 0原文

我通过Google合作中的HuggingFace模型培训了Parsebert模型,而且运行良好。但是,当我在Pycharm中训练模型时,我遇到了很多错误。

Parsebert模型

  model_name_or_path =“ hooshvarelab/bert-fa-zwnj-base”
    tokenizer = autotokenizer.from_pretaining(model_name_or_path)
    bert = automodel.from_pretrataining(model_name_or_path)
 

错误

HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /HooshvareLab/bert-fa-zwnj-base/resolve/main/config.json (Caused by SSLError(SSLError(1, '[SSL: WRONG_
VERSION_NUMBER] wrong version number (_ssl.c:1129)')))
Traceback (most recent call last):
  File "C:\....\python\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
    self._prepare_proxy(conn)
  File "C:\....\python\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
    conn.connect()
  File "C:\....\python\lib\site-packages\urllib3\connection.py", line 364, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File "C:\....\python\lib\site-packages\urllib3\connection.py", line 501, in _connect_tls_proxy
    socket = ssl_wrap_socket(
  File "C:\....\python\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "C:\....\python\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "C:\....\python\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\....\python\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\....\python\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\....\python\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\....\python\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\....\python\lib\site-packages\urllib3\util\retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /HooshvareLab/bert-fa-zwnj-base/resolve/main/config.json (Caused by 
SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\alish\python\lib\site-packages\transformers\configuration_utils.py", line 550, in get_config_dict
    resolved_config_file = cached_path(
  File "C:\....\python\lib\site-packages\transformers\file_utils.py", line 1491, in cached_path
    output_path = get_from_cache(
  File "C:\....\python\lib\site-packages\transformers\file_utils.py", line 1662, in get_from_cache
    r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=etag_timeout)
  File "C:\....\python\lib\site-packages\requests\api.py", line 102, in head
    return request('head', url, **kwargs)
  File "C:\....\python\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\....\python\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\....\python\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\....\python\lib\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /HooshvareLab/bert-fa-zwnj-base/resolve/main/config.json (Caused by SSLE
rror(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\My_file\Collegue Project\bert\pycharm_exe\content\project\run.py", line 110, in <module>
    run()
  File "C:\My_file\Collegue Project\bert\pycharm_exe\content\project\run.py", line 33, in run
    bert, tokenizer = main_model(args.bert_model)
  File "C:\My_file\Collegue Project\bert\pycharm_exe\content\project\bert\bert.py", line 8, in main_model
    tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
  File "C:\....\python\lib\site-packages\transformers\models\auto\tokenization_auto.py", line 470, in from_pretrained
    config = AutoConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
  File "C:\....\python\lib\site-packages\transformers\models\auto\configuration_auto.py", line 558, in from_pretrained
    config_dict, _ = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
  File "C:\....\python\lib\site-packages\transformers\configuration_utils.py", line 575, in get_config_dict
    raise EnvironmentError(msg)
OSError: Can't load config for 'HooshvareLab/bert-fa-zwnj-base'. Make sure that:

- 'HooshvareLab/bert-fa-zwnj-base' is a correct model identifier listed on 'https://huggingface.co/models'
  (make sure 'HooshvareLab/bert-fa-zwnj-base' is not a path to a local directory with something else, in that case)

- or 'HooshvareLab/bert-fa-zwnj-base' is the correct path to a directory containing a config.json file

当我使用伯特(Bert)这样的英语模型切换模型时,奥索尔(Oserror)消失了,但其他错误仍在不断。

合作中的工具版本

python:3.7.13

Pytorch:1.11.0+CU113

变形金刚:4.19.4

工具的版本 local

python:3.9.8

pytorch:pytorch:pytorch: 1.10.1+CPU

变形金刚:4.12.5

I trained the ParseBERT model via HuggingFace models in google collab and it was working fine. but while I was training the model in Pycharm, I got bunches of errors.

ParseBERT model

    model_name_or_path = "HooshvareLab/bert-fa-zwnj-base"
    tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
    bert = AutoModel.from_pretrained(model_name_or_path)

Errors

HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /HooshvareLab/bert-fa-zwnj-base/resolve/main/config.json (Caused by SSLError(SSLError(1, '[SSL: WRONG_
VERSION_NUMBER] wrong version number (_ssl.c:1129)')))
Traceback (most recent call last):
  File "C:\....\python\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
    self._prepare_proxy(conn)
  File "C:\....\python\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
    conn.connect()
  File "C:\....\python\lib\site-packages\urllib3\connection.py", line 364, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File "C:\....\python\lib\site-packages\urllib3\connection.py", line 501, in _connect_tls_proxy
    socket = ssl_wrap_socket(
  File "C:\....\python\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "C:\....\python\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "C:\....\python\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\....\python\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\....\python\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\....\python\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\....\python\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\....\python\lib\site-packages\urllib3\util\retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /HooshvareLab/bert-fa-zwnj-base/resolve/main/config.json (Caused by 
SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\alish\python\lib\site-packages\transformers\configuration_utils.py", line 550, in get_config_dict
    resolved_config_file = cached_path(
  File "C:\....\python\lib\site-packages\transformers\file_utils.py", line 1491, in cached_path
    output_path = get_from_cache(
  File "C:\....\python\lib\site-packages\transformers\file_utils.py", line 1662, in get_from_cache
    r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=etag_timeout)
  File "C:\....\python\lib\site-packages\requests\api.py", line 102, in head
    return request('head', url, **kwargs)
  File "C:\....\python\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\....\python\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\....\python\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\....\python\lib\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /HooshvareLab/bert-fa-zwnj-base/resolve/main/config.json (Caused by SSLE
rror(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\My_file\Collegue Project\bert\pycharm_exe\content\project\run.py", line 110, in <module>
    run()
  File "C:\My_file\Collegue Project\bert\pycharm_exe\content\project\run.py", line 33, in run
    bert, tokenizer = main_model(args.bert_model)
  File "C:\My_file\Collegue Project\bert\pycharm_exe\content\project\bert\bert.py", line 8, in main_model
    tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
  File "C:\....\python\lib\site-packages\transformers\models\auto\tokenization_auto.py", line 470, in from_pretrained
    config = AutoConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
  File "C:\....\python\lib\site-packages\transformers\models\auto\configuration_auto.py", line 558, in from_pretrained
    config_dict, _ = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
  File "C:\....\python\lib\site-packages\transformers\configuration_utils.py", line 575, in get_config_dict
    raise EnvironmentError(msg)
OSError: Can't load config for 'HooshvareLab/bert-fa-zwnj-base'. Make sure that:

- 'HooshvareLab/bert-fa-zwnj-base' is a correct model identifier listed on 'https://huggingface.co/models'
  (make sure 'HooshvareLab/bert-fa-zwnj-base' is not a path to a local directory with something else, in that case)

- or 'HooshvareLab/bert-fa-zwnj-base' is the correct path to a directory containing a config.json file

When I switched the model with English language models like Bert, the OSError disappeared but other errors remain constantly.

Version of tools in Collab:

Python: 3.7.13

PyTorch: 1.11.0+cu113

Transformers: 4.19.4

Version of tools in local:

Python: 3.9.8

Pytorch: 1.10.1+cpu

Transformers: 4.12.5

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文