i am facing HFValidationError Traceback (most recent call last) ,while loading model to jupyter notebook

#10
by aayushrehal - opened

from transformers import MistralForCausalLM, LlamaTokenizer
from transformers import AutoTokenizer
import warnings
import os
import torch
warnings.filterwarnings("ignore", category=DeprecationWarning)

Replace with the actual path to the downloaded model directory

model_dir = "E:\Actualisation\Mistral\mistral-7b-instruct-v0.2.Q2_K.gguf"
tokenizer = AutoTokenizer.from_pretrained(model_dir,local_files_only=True)

Error Below , Please Fix It ,


HFValidationError Traceback (most recent call last)
File D:\Anaconda\lib\site-packages\transformers\utils\hub.py:398, in cached_file(path_or_repo_id, filename, cache_dir, force_download, resume_download, proxies, token, revision, local_files_only, subfolder, repo_type, user_agent, _raise_exceptions_for_gated_repo, _raise_exceptions_for_missing_entries, _raise_exceptions_for_connection_errors, _commit_hash, **deprecated_kwargs)
396 try:
397 # Load from URL or cache if already cached
--> 398 resolved_file = hf_hub_download(
399 path_or_repo_id,
400 filename,
401 subfolder=None if len(subfolder) == 0 else subfolder,
402 repo_type=repo_type,
403 revision=revision,
404 cache_dir=cache_dir,
405 user_agent=user_agent,
406 force_download=force_download,
407 proxies=proxies,
408 resume_download=resume_download,
409 token=token,
410 local_files_only=local_files_only,
411 )
412 except GatedRepoError as e:

File D:\Anaconda\lib\site-packages\huggingface_hub\utils_validators.py:111, in validate_hf_hub_args.._inner_fn(*args, **kwargs)
110 if arg_name in ["repo_id", "from_id", "to_id"]:
--> 111 validate_repo_id(arg_value)
113 elif arg_name == "token" and arg_value is not None:

File D:\Anaconda\lib\site-packages\huggingface_hub\utils_validators.py:165, in validate_repo_id(repo_id)
164 if not REPO_ID_REGEX.match(repo_id):
--> 165 raise HFValidationError(
166 "Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are"
167 " forbidden, '-' and '.' cannot start or end the name, max length is 96:"
168 f" '{repo_id}'."
169 )
171 if "--" in repo_id or ".." in repo_id:

HFValidationError: Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are forbidden, '-' and '.' cannot start or end the name, max length is 96: 'E:\Actualisation\Mistral\mistral-7b-instruct-v0.2.Q2_K.gguf'.

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

OSError Traceback (most recent call last)
Cell In[9], line 1
----> 1 tokenizer = AutoTokenizer.from_pretrained(model_dir,local_files_only=True)

File D:\Anaconda\lib\site-packages\transformers\models\auto\tokenization_auto.py:804, in AutoTokenizer.from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs)
801 return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
803 # Next, let's try to use the tokenizer_config file to get the tokenizer class.
--> 804 tokenizer_config = get_tokenizer_config(pretrained_model_name_or_path, **kwargs)
805 if "_commit_hash" in tokenizer_config:
806 kwargs["_commit_hash"] = tokenizer_config["_commit_hash"]

File D:\Anaconda\lib\site-packages\transformers\models\auto\tokenization_auto.py:637, in get_tokenizer_config(pretrained_model_name_or_path, cache_dir, force_download, resume_download, proxies, token, revision, local_files_only, subfolder, **kwargs)
634 token = use_auth_token
636 commit_hash = kwargs.get("_commit_hash", None)
--> 637 resolved_config_file = cached_file(
638 pretrained_model_name_or_path,
639 TOKENIZER_CONFIG_FILE,
640 cache_dir=cache_dir,
641 force_download=force_download,
642 resume_download=resume_download,
643 proxies=proxies,
644 token=token,
645 revision=revision,
646 local_files_only=local_files_only,
647 subfolder=subfolder,
648 _raise_exceptions_for_gated_repo=False,
649 _raise_exceptions_for_missing_entries=False,
650 _raise_exceptions_for_connection_errors=False,
651 _commit_hash=commit_hash,
652 )
653 if resolved_config_file is None:
654 logger.info("Could not locate the tokenizer configuration file, will try to use the model config instead.")

File D:\Anaconda\lib\site-packages\transformers\utils\hub.py:462, in cached_file(path_or_repo_id, filename, cache_dir, force_download, resume_download, proxies, token, revision, local_files_only, subfolder, repo_type, user_agent, _raise_exceptions_for_gated_repo, _raise_exceptions_for_missing_entries, _raise_exceptions_for_connection_errors, _commit_hash, **deprecated_kwargs)
460 raise EnvironmentError(f"There was a specific connection error when trying to load {path_or_repo_id}:\n{err}")
461 except HFValidationError as e:
--> 462 raise EnvironmentError(
463 f"Incorrect path_or_model_id: '{path_or_repo_id}'. Please provide either the path to a local folder or the repo_id of a model on the Hub."
464 ) from e
465 return resolved_file

OSError: Incorrect path_or_model_id: 'E:\Actualisation\Mistral\mistral-7b-instruct-v0.2.Q2_K.gguf'. Please provide either the path to a local folder or the repo_id of a model on the Hub.
​

Sign up or log in to comment