Clarify HuggingFace token handling in workspace, noting the standard CLI location and adding support for an environment variable.

This commit is contained in:
Foke Singh 2023-03-14 15:28:03 +00:00
parent cd2f2209d0
commit fe531aef06
3 changed files with 21 additions and 16 deletions

View File

@ -20,19 +20,19 @@ download models.
* store the token on your machine (replace the placeholder with your actual * store the token on your machine (replace the placeholder with your actual
token): token):
You can use the `HUGGINGFACE_TOKEN` environment variable to store the token or use
its standard location:
``` ```
echo -n <hf_my_token> > `$HOME/.cache/huggingface/token` mkdir -p $HOME/.cache/huggingface/; echo <hf_my_token> > "$HOME/.cache/huggingface/token"
``` ```
The `-n` is important in order to not append an "end of line" character at the
end of the file that would corrupt the token.
Now you're ready to download a gated model like `Meta-Llama-3-8b`! Now you're ready to download a gated model like `Meta-Llama-3-8b`!
**Example:** **Example:**
``` ```
# requires token in $HOME/.cache/huggingface/token # requires token in $HOME/.cache/huggingface/token, as created by the
# `huggingface-cli login` command, or the `HUGGINGFACE_TOKEN` environment variable.
cd examples cd examples
bazel run -c opt //llama:Meta-Llama-3-8b bazel run -c opt //llama:Meta-Llama-3-8b
bazel run -c opt //llama:Meta-Llama-3-8b -- --promt="Once upon a time," bazel run -c opt //llama:Meta-Llama-3-8b -- --promt="Once upon a time,"

View File

@ -3,7 +3,10 @@
Some models have restrictions and may require some sort of approval or agreement Some models have restrictions and may require some sort of approval or agreement
process, which, by consequence, **requires token-authentication with Huggingface**. process, which, by consequence, **requires token-authentication with Huggingface**.
Here is how you can generate a **"read-only public repositories"** access token to log into your account on Huggingface, directly from `bazel`, in order to download models. The easiest way might be to use the `huggingface-cli login` command.
Alternatively, here is how you can generate a **"read-only public repositories"**
access token to log into your account on Huggingface, directly from `bazel`, in order to download models.
* log in at [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens). * log in at [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens).
* click on "Create new token" * click on "Create new token"
@ -14,18 +17,19 @@ Here is how you can generate a **"read-only public repositories"** access token
* the token looks something like `hf_abCdEfGhijKlM`. * the token looks something like `hf_abCdEfGhijKlM`.
* store the token on your machine (replace the placeholder with your actual token): * store the token on your machine (replace the placeholder with your actual token):
You can use the `HUGGINGFACE_TOKEN` environment variable to store the token or use
its standard location:
``` ```
mkdir -p $HOME/.cache/huggingface/; echo -n <hf_my_token> > "$HOME/.cache/huggingface/token" mkdir -p $HOME/.cache/huggingface/; echo <hf_my_token> > "$HOME/.cache/huggingface/token"
``` ```
The `-n` is important in order to not append an "end of line" character at the end of the file that would corrupt the token.
Now you're ready to download a gated model like `Meta-Llama-3-8b`! Now you're ready to download a gated model like `Meta-Llama-3-8b`!
**Example:** **Example:**
``` ```
# requires token in $HOME/.cache/huggingface/token # requires token in $HOME/.cache/huggingface/token, as created by the
# `huggingface-cli login` command, or the `HUGGINGFACE_TOKEN` environment variable.
cd examples cd examples
bazel run -c opt //llama:Meta-Llama-3-8b bazel run -c opt //llama:Meta-Llama-3-8b
bazel run -c opt //llama:Meta-Llama-3-8b -- --promt="Once upon a time," bazel run -c opt //llama:Meta-Llama-3-8b -- --promt="Once upon a time,"

View File

@ -93,7 +93,8 @@ Once you've been granted access, you're ready to download a gated model like
`Meta-Llama-3-8b`! `Meta-Llama-3-8b`!
``` ```
# requires token in $HOME/.cache/huggingface/token # requires token in $HOME/.cache/huggingface/token, as created by the
# `huggingface-cli login` command, or the `HUGGINGFACE_TOKEN` environment variable.
cd examples cd examples
bazel run -c opt //llama:Meta-Llama-3-8b bazel run -c opt //llama:Meta-Llama-3-8b
bazel run -c opt //llama:Meta-Llama-3-8b -- --promt="Once upon a time," bazel run -c opt //llama:Meta-Llama-3-8b -- --promt="Once upon a time,"