Private Hugging Face model
Load a gated or private model from Hugging Face
To load a gated or private model from Hugging Face, follow these steps:
- Create an access token in your Hugging Face account.
- Store the token securely as
hf_access_token
in Baseten’s secret manager. - Reference the token in
model.py
usinguse_auth_token
.
Configuring Secrets
Add the token reference to config.yaml
:
config.yaml
Then, update model.py
:
model/model.py
Never store secrets directly in
config.yaml
— use the Baseten secret manager.Example: Deploying a Private BERT Model
We’ll deploy a gated version of BERT base (uncased), a masked language model.
1: Initialize Truss
Get started by creating a new Truss:
Step 2: Set Dependencies
config.yaml
Step 3: Store the Access Token
- Accept the model terms on Hugging Face.
- Generate an access token.
- Store it as
hf_access_token
in the Baseten secret manager.
4. Deploy and invoke
Invoke the model:
Was this page helpful?