NLP

[NLP] Huggingface hub에 모델 공유하기

iamzieun 2023. 5. 5. 00:53

1. 라이브러리 설치

pip install transformers
brew install git-lfs
brew install huggingface-cli

2. 라이브러리 설치 여부 확인

pip list | grep transformers
git-lfs version
huggingface-cli

3. huggingface에 로그인

huggingface-cli login

  • 'write' permission의 access token 사용
    • Access Tokens 권한의 범위
      • https://huggingface.co/docs/hub/security-tokens
      • read: tokens with this role can only be used to provide read access to repositories you could read. That includes public and private repositories that you, or an organization you’re a member of, own. Use this role if you only need to read content from the Hugging Face Hub (e.g. when downloading private models or doing inference).
      • write: tokens with this role additionally grant write access to the repositories you have write access to. Use this token if you need to create or push content to a repository (e.g., when training a model or modifying a model card).

4. huggingface hub 저장소 생성

huggingface-cli repo create [저장소 이름]

5. 로컬에 저장소 clone

git clone https://[사용자 이름]:[token]@huggingface.co/[사용자 이름]/[저장소 이름]

6. git user.email과 user.name 입력

git config --global user.email [huggingface 이메일]
git config --global user.name [사용자 이름]

7. huggingface에 공유할 파일을 clone해온 저장소 폴더로 이동

8. push

git lfs install
git add --all
git commit -m "my test model upload"
git push