I cannot download model from hugging face. I already click granted access to this model in this page https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3
This is my code. I test all read, write and finetune permission. It show same error.
from huggingface_hub import notebook_login
notebook_login()
from huggingface_hub import snapshot_download
from pathlib import Path
mistral_models_path = Path.home().joinpath('mistral_models', '7B-v0.3')
mistral_models_path.mkdir(parents=True, exist_ok=True)
snapshot_download(repo_id="mistralai/Mistral-7B-v0.3", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
It show error like this. How to fix it?
HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/api/models/mistralai/Mistral-7B-v0.3/revision/main
The above exception was the direct cause of the following exception:
GatedRepoError Traceback (most recent call last)
<ipython-input-15-22e2c71ce7aa> in <cell line: 7>()
5 mistral_models_path.mkdir(parents=True, exist_ok=True)
6
----> 7 snapshot_download(repo_id="mistralai/Mistral-7B-v0.3", allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
8
9 get_ipython().system(' cp -r /root/mistral_models/7B-v0.3 /content/mistral_models')
/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py in _inner_fn(*args, **kwargs)
112 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
113
--> 114 return fn(*args, **kwargs)
115
116 return _inner_fn # type: ignore
/usr/local/lib/python3.10/dist-packages/huggingface_hub/_snapshot_download.py in snapshot_download(repo_id, repo_type, revision, cache_dir, local_dir, library_name, library_version, user_agent, proxies, etag_timeout, force_download, token, local_files_only, allow_patterns, ignore_patterns, max_workers, tqdm_class, headers, endpoint, local_dir_use_symlinks, resume_download)
231 elif isinstance(api_call_error, RepositoryNotFoundError) or isinstance(api_call_error, GatedRepoError):
232 # Repo not found => let's raise the actual error
--> 233 raise api_call_error
234 else:
235 # Otherwise: most likely a connection issue or Hub downtime => let's warn the user
/usr/local/lib/python3.10/dist-packages/huggingface_hub/_snapshot_download.py in snapshot_download(repo_id, repo_type, revision, cache_dir, local_dir, library_name, library_version, user_agent, proxies, etag_timeout, force_download, token, local_files_only, allow_patterns, ignore_patterns, max_workers, tqdm_class, headers, endpoint, local_dir_use_symlinks, resume_download)
162 headers=headers,
163 )
--> 164 repo_info = api.repo_info(repo_id=repo_id, repo_type=repo_type, revision=revision, token=token)
165 except (requests.exceptions.SSLError, requests.exceptions.ProxyError):
166 # Actually raise for those subclasses of ConnectionError
/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py in _inner_fn(*args, **kwargs)
112 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
113
--> 114 return fn(*args, **kwargs)
115
116 return _inner_fn # type: ignore
/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py in repo_info(self, repo_id, revision, repo_type, timeout, files_metadata, token)
2489 else:
2490 raise ValueError("Unsupported repo type.")
-> 2491 return method(
2492 repo_id,
2493 revision=revision,
/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py in _inner_fn(*args, **kwargs)
112 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
113
--> 114 return fn(*args, **kwargs)
115
116 return _inner_fn # type: ignore
/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py in model_info(self, repo_id, revision, timeout, securityStatus, files_metadata, token)
2299 params["blobs"] = True
2300 r = get_session().get(path, headers=headers, timeout=timeout, params=params)
-> 2301 hf_raise_for_status(r)
2302 data = r.json()
2303 return ModelInfo(**data)
/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_errors.py in hf_raise_for_status(response, endpoint_name)
319 f"{response.status_code} Client Error." + "\n\n" + f"Cannot access gated repo for url {response.url}."
320 )
--> 321 raise GatedRepoError(message, response) from e
322
323 elif error_message == "Access to this resource is disabled.":
GatedRepoError: 401 Client Error. (Request ID: Root=1-66843d81-37ed393f2c5d875136f7d8b8;f6188f83-46ed-444d-bb2c-711f12f8a30a)
Cannot access gated repo for url https://huggingface.co/api/models/mistralai/Mistral-7B-v0.3/revision/main.
Access to model mistralai/Mistral-7B-v0.3 is restricted. You must be authenticated to access it.