|
105 | 105 | }, |
106 | 106 | "outputs": [], |
107 | 107 | "source": [ |
| 108 | + "# @title install Hugging Face Transformers v4.50+\n", |
108 | 109 | "! pip install -q 'transformers>=4.50.0'" |
109 | 110 | ] |
110 | 111 | }, |
|
116 | 117 | }, |
117 | 118 | "outputs": [], |
118 | 119 | "source": [ |
119 | | - "! huggingface-cli login" |
| 120 | + "# @title Authenticate with Hugging Face Hub\n", |
| 121 | + "# @markdown ShieldGemma is a gated model. To access the weights, you must accept\n", |
| 122 | + "# @markdown the license on Hugging Face Hub under your account and then provide\n", |
| 123 | + "# @markdown an [Access Token](https://huggingface.co/docs/hub/en/security-tokens)\n", |
| 124 | + "# @markdown to authenticate with the Hugging Face Hub API. If using Colab, the\n", |
| 125 | + "# @markdown easiest way to do this is by creating a read-only token specifically\n", |
| 126 | + "# @markdown for Colab and setting this as the value of the `HF_TOKEN` secret;\n", |
| 127 | + "# @markdown this token will then be reusable across all Colab notebooks. Other\n", |
| 128 | + "# @markdown Python notebook platforms may provide a similar mechanism. For those\n", |
| 129 | + "# @markdown that do not, un-comment the lines in this cell to install the\n", |
| 130 | + "# @markdown Hugging Face Hub CLI and login in interactively.\n", |
| 131 | + "# ! pip install -q 'huggingface_hub[cli]'\n", |
| 132 | + "# ! huggingface-cli login" |
120 | 133 | ] |
121 | 134 | }, |
122 | 135 | { |
|
188 | 201 | "\n", |
189 | 202 | "# ShieldGemma prompts are constructed such that predicting the `Yes` token means\n", |
190 | 203 | "# the content does violate the policy. If you are only interested in the\n", |
191 | | - "# violative condition, use to extract that slice from the output tensors.\n", |
| 204 | + "# violative condition, you can extract only that slice from the output tensors.\n", |
192 | 205 | "p_violated = scores.probabilities[:, 0]\n", |
193 | 206 | "print(p_violated)\n" |
194 | 207 | ] |
|
0 commit comments