Exercise#3 HuggingFace Token
Steps overview
- Register on HuggingFace
- Get access to gated models
- Create a HuggingFace Token which is the same as API_KEY; add it to the key file(HUGGINGFACEHUB_API_TOKEN)
- Test access to models from code
Steps
1. Register with HuggingFace
Skip this step if you have already registered :-)
Sign Up
2. Generate the Hugging Face API token
Login to your Hugging Face account. Use steps to create token or use the link below:
- Click on profile icon on top-right of the page
- Select Settings in the drop down
- Select Access Tokens in left navigation panel
- Click on + Create new token to create the token
- Select the Write token
- Give a name to the token e.g., GENAI_APP_DEV_COURSE
- Click on the button to create the token
Create token
3. Add token to the key file
Copy/Paste the token from HuggingFace hub. Replace the placeholder with your token in your key file:
HUGGINGFACEHUB_API_TOKEN=hf_XXXXXXXXXXXXXXXXXXXXX
4. Get access to gated models
One access request is needed per model family. Once the request is approved, you will be able to access all models and their variants within that family. E.g., when you get approved for google/gemma-2-2b, you will be able to access google/gemma-2-2b-it as well.,
Most times access is granted immediately but it may take hours and in some rare cases days !!!
Multiple highly performant models on Hugginface are gated. You will permissions to use these models.
- Search for the model : mistralai/Mistral-7B-Instruct-v0.2
- Request for access
- Once access request is approved, you will see a refreshed notice & you will receive an email
Additional models to request access for:
- google/gemma-2-9b-it Requires acknowledgement of license; gets access to username & email
- meta-llama/Meta-Llama-3.1-70B-Instruct Requires a number of other PII in addition to username & email
- meta-llama/Llama-2-7b-chat-hf
5. Test the setup
- Change the path to the key file
- RUN cell with the title : Setup the environment
- RUN cells in the section titled : HuggingFace token
6. Explore
- Try out a model that can summarize a given text
- Find a dataset in CSV format for Q&A
- Take a look at space for creators of the Mistral family of models