View on Github
- Create an access token on your Hugging Face account.
- Add the `hf_access_token“ key to your config.yaml secrets and value to your Baseten account.
- Add
use_auth_token
when creating the actual model.
Setting up the model
In this example, we use a private version of the BERT base model. The model is publicly available, but for the purposes of our example, we copied it into a private model repository, with the path “baseten/docs-example-gated-model”. First, like with other Hugging Face models, start by importing thepipeline
function from the
transformers library, and defining the Model
class.
model/model.py
__init__
function.
model/model.py
pipeline
, we use the use_auth_token
parameter,
pass the hf_access_token
secret that is on our Baseten account.
model/model.py
Setting up the config.yaml
The main things that need to be set up in the config arerequirements
, which need to include Hugging Face transformers,
and the secrets.
config.yaml
hf_access_token
available in the Truss, we need to include
it in the config. Setting the value to null
here means that the value
will be set by the Baseten secrets manager.
config.yaml
Deploying the model
An important note for deploying models with secrets is that you must use the--trusted
flag to give the model access to
secrets stored on the remote secrets manager.