Python 및 Torch 코딩 이모저모

HuggingFace OSError: You are trying to access a gated repo.Make sure to request access at 에러

섬섬옥수수 2024. 1. 24. 17:30
huggingface-cli login​
Exception has occurred: OSError
You are trying to access a gated repo.
Make sure to request access at https://huggingface.co/LDCC/LDCC-Instruct-Llama-2-ko-13B-v1.4 and pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`.
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/LDCC/LDCC-Instruct-Llama-2-ko-13B-v1.4/resolve/main/tokenizer_config.json

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

huggingface_hub.utils._errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-65b0c2a4-2b36563c34034f1f35a70571;1e2fe910-5469-46b9-b027-fc09b3641ef8)

Cannot access gated repo for url https://huggingface.co/LDCC/LDCC-Instruct-Llama-2-ko-13B-v1.4/resolve/main/tokenizer_config.json.
Repo model LDCC/LDCC-Instruct-Llama-2-ko-13B-v1.4 is gated. You must be authenticated to access it.

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

OSError: You are trying to access a gated repo.
Make sure to request access at https://huggingface.co/LDCC/LDCC-Instruct-Llama-2-ko-13B-v1.4 and pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`.

 

위와 같은 에러는 LLM 모델을 다운받을 때 huggingface 나 meta 등의 만든 회사 측의 승인이 필요한데 내가 승인이 안되어있거나 승인은 받았지만 huggingface 로그인이 터미널 상에서 안되어있을때 나타나는 에러이다.

 

이럴 때에는

모델마다 승인을 받는 방식이 다른데, 보통은 허깅페이스 해당 모델 사이트에서 클릭만 하면 grant 를 얻을 수 있다.

 

LDCC 모델 승인

 

이렇게 승인을 받은 후

 

HuggingFace 공식 사이트에 로그인 후 프로필 사진의 메뉴에서 Settings > Access Tokens 에 들어가면 자신의 token 을 복사할 수 있다. hf_~ 꼴이다.

이후 돌리려고 하는 python 파일에 아래와 같이 기재해주면 된다!

 

from huggingface_hub import login

login("hf_XXXXXXXXXXX")

 

https://discuss.huggingface.co/t/your-request-to-access-this-repo-has-been-successfully-submitted-and-is-pending-a-review-from-the-repos-authors/57698

 

Your request to access this repo has been successfully submitted, and is pending a review from the repo's authors

Hi, I have a Pro account of Hugging Face. But when I try to call the HuggingFace Model API, I get this error :- OSError: You are trying to access a gated repo. Make sure to request access at meta-llama/Llama-2-70b-chat-hf · Hugging Face and pass a token h

discuss.huggingface.co

 

혹은 git 에 올려야해서 token 노출이 싫다면

 

huggingface-cli login

 

터미널 창에 위처럼 치면 

 

_|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
_|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
_|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
_|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
_|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|

To log in, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token:
Add token as git credential? (Y/n)
Token is valid (permission: write).
Your token has been saved in your configured git credential helpers (store).
Your token has been saved to /home/wauplin/.cache/huggingface/token
Login successful

 

위와 같이 hf token 을 칠 수 있는 창이 나온다. 이렇게 할 수 도 있다..!