Huggingface#

Huggingface is an open-source machine learning company that provides state-of-the-art ML models and tools for developers.

To enable Huggingface access within MosaicML platform, please create an environment variable secret:

mcli create secret hf

Then, test that the API key was added correctly with a small test script below:

name: huggingface-api-key
compute:
  gpus: 0
image: mosaicml/pytorch
integrations:
  - integration_type: pip_packages
    packages:
      - huggingface-hub
command: |
  export hf_token=$HUGGING_FACE_HUB_TOKEN
  echo "Checking if HF Token is set..."
  if [ -z "$hf_token" ]; then
    echo "Error: HF Token is empty"
    exit 1
  else
    echo "Logging in to Hugging Face..."
    huggingface-cli login --token $hf_token
    echo "Logged in. Running whoami to display the current user..."
    huggingface-cli whoami
  fi