Create a Hugging Face API Token
To be able to interact with the Hugging Face community, you need to create an API token. Let's take a look at the steps.
Sign up for Hugging Face
If you haven't gotten an account yet, sign up here: https://huggingface.co/joinHover over the account icon in the upper right corner and choose "settings"
From the left menu, choose "Access Tokens"
Then, choose "Create New Token"
For most cases, I choose "Fine-grained" and give it these three permissions:
Copy the token and store it somewhere safe (don't worry I've deleted the token from the screenshot below).
Store the Token in a Google Colab Notebook
Cool! You now have access to Hugging Face repos via this token. But how do you use the token? Well, in a Google Colab notebook, you do the following:
Select the key icon.
Select "Add new secret".
Use the following:
Name:HF_TOKEN
Value:[your token]
Then select the toggle to grant "Notebook access"
From within a code block you can now access the token like this:
userdata.get('HF_TOKEN')
Subscribe to my newsletter
Read articles from Sam Schneider directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by