Getting setup for the Hugging Face ecosystem
The following steps are to help you get started with the Hugging Face ecosystem.
Best to follow the “Start here” steps and then go through the other setup steps as necessary.
Start here (universal steps)
- Create a free Hugging Face account at https://huggingface.co/join.
- Create a Hugging Face access token with read and write access at https://huggingface.co/settings/tokens.
- You can create a read/write token using the fine-grained settings and selecting all the appropriate options.
- Read more on Hugging Face access tokens at https://huggingface.co/docs/hub/en/security-tokens.
Note: Do not share your token with others. Always keep it private and avoid saving it in raw text format.
Getting setup on Google Colab
Note: If you’re unfamiliar with Google Colab, I’d recommend going through Sam Witteveen’s video Colab 101 and then Advanced Colab to learn more.
- Follow the steps in Start here.
- Add your Hugging Face read/write token as a Secret in Google Colab.
- Naming this Secret
HF_TOKEN
will mean that Hugging Face libraries automatically recognize your token for future use.
- Naming this Secret
Alternatively, if you need to force relogin for a notebook session, you can run:
import huggingface_hub # requires !pip install huggingface_hub
# Login to Hugging Face
huggingface_hub.login()
And enter your token in the box that appears (note: this token will only be active for the current notebook session and will delete when your Google Colab instance terminates).
TK - Getting started locally
- Follow the steps in Start here.
- Install the Hugging Face CLI with
pip install -U "huggingface_hub[cli]"
. - Follow the setup steps mentioned in https://huggingface.co/docs/huggingface_hub/en/guides/cli.
Installing Hugging Face libraries
We’ll need to install the following libraries from the Hugging Face ecosystem:
transformers
- comes pre-installed on Google Colab but if you’re running on your local machine, you can install it viapip install transformers
.datasets
- a library for accessing and manipulating datasets on and off the Hugging Face Hub, you can install it viapip install datasets
.evaluate
- a library for evaluating machine learning model performance with various metrics, you can install it viapip install evaluate
.accelerate
- a library for training machine learning models faster, you can install it viapip install accelerate
.gradio
- a library for creating interactive demos of machine learning models, you can install it viapip install gradio
.