token secrets hugging face

Create a Hugging Face token#

In order to download and access gated models from Hugging Face, you need to provide a Hugging Face token. Tokens contain sensitive information. To keep them secure and prevent unauthorized access, they should not be stored in plain text in your code or configuration files. Instead, they are stored as secrets, a secure way to manage sensitive data.

How to get a Hugging Face token#

  1. Create or log in to your Hugging Face account: https://huggingface.co.

  2. Navigate to your account settings.

  3. Under Access Tokens, generate a new token.

  4. Copy the token (keep it safe; don’t share it).

Where to install the token#

The AMD AI Workbench provides a built-in secrets management system for storing Hugging Face tokens securely. You can add tokens through the UI when needed as part of the process of deploying or fine-tuning your models. You will be prompted to enter your Hugging Face token, which will be securely saved on your Kubernetes cluster.

Adding HF Tokens#

  1. In the deployment or fine-tune dialog, you’ll see a Hugging Face Authentication section.

  2. Choose one of two options:

    • Select existing token: Pick from previously added tokens in this project.

    • Add new token: Enter a name and paste your Hugging Face token.

  3. The token is automatically stored as a Kubernetes secret scoped to your project.

Token Management#

  • Scope: Hugging Face tokens are scoped to individual projects for security.

  • Reusability: Once added, tokens can be reused for multiple fine-tuning jobs or AIM deployments within the same project.

  • Storage: Tokens are stored as Kubernetes secrets and never exposed in plain text after creation.

  • Validation: Tokens must start with hf_ to be accepted.