+
Skip to content

[BUG] 从hf加载模型失败 #75

@johntime2005

Description

@johntime2005

错误描述

从hf拉取模型(测试代码为readme中的示例代码)显示Distant resource does not have a Content-Length.

重现步骤

  1. 使用readme所示代码
  2. 使用python运行
  3. 出现Distant resource does not have a Content-Length.

预期行为

正常从hf拉取所需文件

受影响的平台

Hugging Face

问题 URL 示例

https://xget.xi-xu.me/hf

操作类型

文件下载

错误信息

正在从镜像下载模型: microsoft/DialoGPT-medium
Traceback (most recent call last):
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\huggingface_hub\file_download.py", line 1585, in _get_metadata_or_catch_error
    raise FileMetadataError("Distant resource does not have a Content-Length.")
huggingface_hub.errors.FileMetadataError: Distant resource does not have a Content-Length.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\transformers\utils\hub.py", line 479, in cached_files
    hf_hub_download(
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\huggingface_hub\file_download.py", line 1010, in hf_hub_download
    return _hf_hub_download_to_cache_dir(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\huggingface_hub\file_download.py", line 1117, in _hf_hub_download_to_cache_dir    
    _raise_on_head_call_error(head_call_error, force_download, local_files_only)
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\huggingface_hub\file_download.py", line 1661, in _raise_on_head_call_error        
    raise LocalEntryNotFoundError(
huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\johntimeson\Downloads\code\testload.py", line 14, in <module>
    tokenizer = AutoTokenizer.from_pretrained(model_name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\transformers\models\auto\tokenization_auto.py", line 1093, in from_pretrained     
    config = AutoConfig.from_pretrained(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\transformers\models\auto\configuration_auto.py", line 1333, in from_pretrained    
    config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\transformers\configuration_utils.py", line 662, in get_config_dict
    config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\transformers\configuration_utils.py", line 721, in _get_config_dict
    resolved_config_file = cached_file(
                           ^^^^^^^^^^^^
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\transformers\utils\hub.py", line 322, in cached_file
    file = cached_files(path_or_repo_id=path_or_repo_id, filenames=[filename], **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\johntimeson\.conda\envs\sentry-moe-v2\Lib\site-packages\transformers\utils\hub.py", line 553, in cached_files
    raise OSError(
OSError: We couldn't connect to 'https://xget.xi-xu.me/hf' to load the files, and couldn't find them in the cached files.
Check your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

浏览器/工具

No response

实例 URL

No response

附加信息

No response

确认

  • 我已经搜索了现有的 issues,确认这不是重复报告
  • 我已经阅读了存储库文档和故障排除指南
  • 我提供的信息准确且完整

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载