[GH-ISSUE #457] OSError: None is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models' #36

Closed
opened 2026-02-17 17:19:02 -05:00 by yindo · 1 comment
Owner

Originally created by @vidyalatha-badde on GitHub (May 22, 2025).
Original GitHub issue: https://github.com/langchain-ai/docs/issues/457

Checked other resources

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Example Code

Reproducer:

from langchain_huggingface import ChatHuggingFace, HuggingFacePipeline

print("Initializing....")

model_id="TinyLlama/TinyLlama-1.1B-Chat-v1.0"

llm = HuggingFacePipeline.from_model_id(
    model_id=model_id,
    device_map="auto",
    task="text-generation",
    pipeline_kwargs=dict(
        max_new_tokens=512,
        do_sample=False,
        repetition_penalty=1.03,
    ),
   ) 
chat_model = ChatHuggingFace(llm=llm)

Error Message and Stack Trace (if applicable)

Observed the below error upon running the reproducer code

Initializing....
Device set to use xpu:0
The following generation flags are not valid and may be ignored: ['temperature']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
Traceback (most recent call last):
  File "lib/python3.11/site-packages/huggingface_hub/utils/_http.py", line 409, in hf_raise_for_status
    response.raise_for_status()
  File "lib/python3.11/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/None/resolve/main/tokenizer_config.json

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

Traceback (most recent call last):
  File "lib/python3.11/site-packages/transformers/utils/hub.py", line 470, in cached_files
    hf_hub_download(
  File "lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1008, in hf_hub_download
    return _hf_hub_download_to_cache_dir(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1115, in _hf_hub_download_to_cache_dir
    _raise_on_head_call_error(head_call_error, force_download, local_files_only)
  File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1643, in _raise_on_head_call_error
    raise head_call_error
  File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1531, in _get_metadata_or_catch_error
    metadata = get_hf_file_metadata(
               ^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1448, in get_hf_file_metadata
    r = _request_wrapper(
        ^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 286, in _request_wrapper
    response = _request_wrapper(
               ^^^^^^^^^^^^^^^^^
  File "/home/ua35077413e3700bf7248ccc60b25990/vidya/HF/lib/python3.11/site-packages/huggingface_hub/file_download.py", line 310, in _request_wrapper
    hf_raise_for_status(response)
  File "lib/python3.11/site-packages/huggingface_hub/utils/_http.py", line 459, in hf_raise_for_status
    raise _format(RepositoryNotFoundError, message, response) from e
huggingface_hub.errors.RepositoryNotFoundError: 404 Client Error. (Request ID: Root=1-682f69bd-52ecdfc55a059e0160910f18;52e85e22-53c4-4828-8e26-670e53e0b3ea)

Repository Not Found for url: https://huggingface.co/None/resolve/main/tokenizer_config.json.
Please make sure you specified the correct `repo_id` and `repo_type`.
If you are trying to access a private or gated repo, make sure you are authenticated. For more details, see https://huggingface.co/docs/huggingface_hub/authentication

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

Traceback (most recent call last):
  File "test_HF.py", line 17, in <module>
    chat_model = ChatHuggingFace(llm=llm)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/langchain_huggingface/chat_models/huggingface.py", line 504, in __init__
    self._resolve_model_id()
  File "lib/python3.11/site-packages/langchain_huggingface/chat_models/huggingface.py", line 779, in _resolve_model_id
    AutoTokenizer.from_pretrained(self.model_id)
  File "lib/python3.11/site-packages/transformers/models/auto/tokenization_auto.py", line 950, in from_pretrained
    tokenizer_config = get_tokenizer_config(pretrained_model_name_or_path, **kwargs)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/transformers/models/auto/tokenization_auto.py", line 782, in get_tokenizer_config
    resolved_config_file = cached_file(
                           ^^^^^^^^^^^^
  File "lib/python3.11/site-packages/transformers/utils/hub.py", line 312, in cached_file
    file = cached_files(path_or_repo_id=path_or_repo_id, filenames=[filename], **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/transformers/utils/hub.py", line 502, in cached_files
    raise OSError(
OSError: None is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`

Description

I tried using the chat models provided by langchain-huggingface as shown in the reproducer code but when i tried to run it, I'm getting the huggingface login error.
Even after logging in via huggingface-cli login it is showing the same error.

TinyLlama/TinyLlama-1.1B-Chat-v1.0 is the model used in the code which is not a private repo

System Info

Dependencies installed & Versions:

pip install langchain-huggingface accelerate

Name: langchain-huggingface
Version: 0.2.0

Name: accelerate
Version: 1.7.0

Originally created by @vidyalatha-badde on GitHub (May 22, 2025). Original GitHub issue: https://github.com/langchain-ai/docs/issues/457 ### Checked other resources - [x] I added a very descriptive title to this issue. - [x] I used the GitHub search to find a similar question and didn't find it. - [x] I am sure that this is a bug in LangChain rather than my code. - [x] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package). - [x] I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS. ### Example Code **Reproducer:** ``` from langchain_huggingface import ChatHuggingFace, HuggingFacePipeline print("Initializing....") model_id="TinyLlama/TinyLlama-1.1B-Chat-v1.0" llm = HuggingFacePipeline.from_model_id( model_id=model_id, device_map="auto", task="text-generation", pipeline_kwargs=dict( max_new_tokens=512, do_sample=False, repetition_penalty=1.03, ), ) chat_model = ChatHuggingFace(llm=llm) ``` ### Error Message and Stack Trace (if applicable) Observed the below error upon running the reproducer code ``` Initializing.... Device set to use xpu:0 The following generation flags are not valid and may be ignored: ['temperature']. Set `TRANSFORMERS_VERBOSITY=info` for more details. Traceback (most recent call last): File "lib/python3.11/site-packages/huggingface_hub/utils/_http.py", line 409, in hf_raise_for_status response.raise_for_status() File "lib/python3.11/site-packages/requests/models.py", line 1024, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/None/resolve/main/tokenizer_config.json The above exception was the direct cause of the following exception: Traceback (most recent call last): File "lib/python3.11/site-packages/transformers/utils/hub.py", line 470, in cached_files hf_hub_download( File "lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1008, in hf_hub_download return _hf_hub_download_to_cache_dir( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1115, in _hf_hub_download_to_cache_dir _raise_on_head_call_error(head_call_error, force_download, local_files_only) File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1643, in _raise_on_head_call_error raise head_call_error File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1531, in _get_metadata_or_catch_error metadata = get_hf_file_metadata( ^^^^^^^^^^^^^^^^^^^^^ File "lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1448, in get_hf_file_metadata r = _request_wrapper( ^^^^^^^^^^^^^^^^^ File "lib/python3.11/site-packages/huggingface_hub/file_download.py", line 286, in _request_wrapper response = _request_wrapper( ^^^^^^^^^^^^^^^^^ File "/home/ua35077413e3700bf7248ccc60b25990/vidya/HF/lib/python3.11/site-packages/huggingface_hub/file_download.py", line 310, in _request_wrapper hf_raise_for_status(response) File "lib/python3.11/site-packages/huggingface_hub/utils/_http.py", line 459, in hf_raise_for_status raise _format(RepositoryNotFoundError, message, response) from e huggingface_hub.errors.RepositoryNotFoundError: 404 Client Error. (Request ID: Root=1-682f69bd-52ecdfc55a059e0160910f18;52e85e22-53c4-4828-8e26-670e53e0b3ea) Repository Not Found for url: https://huggingface.co/None/resolve/main/tokenizer_config.json. Please make sure you specified the correct `repo_id` and `repo_type`. If you are trying to access a private or gated repo, make sure you are authenticated. For more details, see https://huggingface.co/docs/huggingface_hub/authentication The above exception was the direct cause of the following exception: Traceback (most recent call last): File "test_HF.py", line 17, in <module> chat_model = ChatHuggingFace(llm=llm) ^^^^^^^^^^^^^^^^^^^^^^^^ File "lib/python3.11/site-packages/langchain_huggingface/chat_models/huggingface.py", line 504, in __init__ self._resolve_model_id() File "lib/python3.11/site-packages/langchain_huggingface/chat_models/huggingface.py", line 779, in _resolve_model_id AutoTokenizer.from_pretrained(self.model_id) File "lib/python3.11/site-packages/transformers/models/auto/tokenization_auto.py", line 950, in from_pretrained tokenizer_config = get_tokenizer_config(pretrained_model_name_or_path, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "lib/python3.11/site-packages/transformers/models/auto/tokenization_auto.py", line 782, in get_tokenizer_config resolved_config_file = cached_file( ^^^^^^^^^^^^ File "lib/python3.11/site-packages/transformers/utils/hub.py", line 312, in cached_file file = cached_files(path_or_repo_id=path_or_repo_id, filenames=[filename], **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "lib/python3.11/site-packages/transformers/utils/hub.py", line 502, in cached_files raise OSError( OSError: None is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models' If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>` ``` ### Description I tried using the chat models provided by langchain-huggingface as shown in the reproducer code but when i tried to run it, I'm getting the huggingface login error. Even after logging in via `huggingface-cli login` it is showing the same error. > TinyLlama/TinyLlama-1.1B-Chat-v1.0 is the model used in the code which is not a private repo ### System Info Dependencies installed & Versions: pip install langchain-huggingface accelerate Name: langchain-huggingface Version: 0.2.0 Name: accelerate Version: 1.7.0
yindo added the langchainpython labels 2026-02-17 17:19:02 -05:00
yindo closed this issue 2026-02-17 17:19:02 -05:00
Author
Owner

@jedick commented on GitHub (Jul 9, 2025):

The None in the URL of the first 404 suggests a missing tokenizer. Digging into the documentation for ChatHuggingFace shows:

param tokenizer: Any = None
Tokenizer for the model. Only used for HuggingFacePipeline.

Try out this modification to your code:

from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(model_id)
chat_model = ChatHuggingFace(llm=llm, tokenizer=tokenizer)

My guess is that chat_model = ChatHuggingFace(llm=llm) (with no tokenizer specified) works with HuggingFaceEndpoint (I haven't tested this) but doesn't work with HuggingFacePipeline. Perhaps the HuggingFacePipeline example at ChatHuggingFace | 🦜🔗 LangChain needs to be updated?

@jedick commented on GitHub (Jul 9, 2025): The `None` in the URL of the first 404 suggests a missing tokenizer. [Digging into the documentation for ChatHuggingFace](https://python.langchain.com/api_reference/huggingface/chat_models/langchain_huggingface.chat_models.huggingface.ChatHuggingFace.html#langchain_huggingface.chat_models.huggingface.ChatHuggingFace.tokenizer) shows: > param tokenizer: Any = None > Tokenizer for the model. Only used for HuggingFacePipeline. Try out this modification to your code: ```python from transformers import AutoTokenizer tokenizer = AutoTokenizer.from_pretrained(model_id) chat_model = ChatHuggingFace(llm=llm, tokenizer=tokenizer) ``` My guess is that `chat_model = ChatHuggingFace(llm=llm)` (with no tokenizer specified) works with HuggingFaceEndpoint (I haven't tested this) but doesn't work with HuggingFacePipeline. Perhaps the HuggingFacePipeline example at [ChatHuggingFace | 🦜️🔗 LangChain](https://python.langchain.com/docs/integrations/chat/huggingface/#huggingfacepipeline) needs to be updated?
yindo changed title from OSError: None is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models' to [GH-ISSUE #457] OSError: None is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models' 2026-06-05 17:24:41 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#36