|
45 | 45 | { |
46 | 46 | "cell_type": "markdown", |
47 | 47 | "source": [ |
48 | | - "# Generate text embeddings by using Hugging Face Hub models\n", |
| 48 | + "# Generate text embeddings by using the EmbeddingGemma model from Hugging Face\n", |
49 | 49 | "\n", |
50 | 50 | "<table align=\"left\">\n", |
51 | 51 | " <td>\n", |
|
75 | 75 | "\n", |
76 | 76 | "This notebook uses Apache Beam's `MLTransform` to generate embeddings from text data.\n", |
77 | 77 | "\n", |
| 78 | + "Using a small, highly efficient open model like EmbeddingGemma at the core of your pipeline makes the entire process self-contained, which can simplify management by eliminating the need for external network calls to other services for the embedding step. Because it's an open model, it can be hosted entirely within Dataflow. This provides the confidence to securely process large-scale, private datasets. For more information about the model, see the [model card](https://huggingface.co/google/embeddinggemma-300m)\n", |
| 79 | + "\n", |
78 | 80 | "Hugging Face's [`SentenceTransformers`](https://huggingface.co/sentence-transformers) framework uses Python to generate sentence, text, and image embeddings.\n", |
79 | 81 | "\n", |
80 | 82 | "To generate text embeddings that use Hugging Face models and `MLTransform`, use the `SentenceTransformerEmbeddings` module to specify the model configuration.\n" |
|
120 | 122 | "execution_count": 29, |
121 | 123 | "outputs": [] |
122 | 124 | }, |
| 125 | + { |
| 126 | + "cell_type": "markdown", |
| 127 | + "source": [ |
| 128 | + "### Authenticate with HuggingFace\n", |
| 129 | + "\n", |
| 130 | + "To ensure that you can pull the correct model, authenticate with HuggingFace by following the prompts in the cell." |
| 131 | + ], |
| 132 | + "metadata": { |
| 133 | + "id": "kXDM8C7d3nPW" |
| 134 | + } |
| 135 | + }, |
| 136 | + { |
| 137 | + "cell_type": "code", |
| 138 | + "source": [ |
| 139 | + "!hf auth login" |
| 140 | + ], |
| 141 | + "metadata": { |
| 142 | + "id": "jVxSi2jS3M3c" |
| 143 | + }, |
| 144 | + "execution_count": 29, |
| 145 | + "outputs": [] |
| 146 | + }, |
123 | 147 | { |
124 | 148 | "cell_type": "markdown", |
125 | 149 | "source": [ |
|
170 | 194 | " {'x': \"Should I sign up for Medicare Part B if I have Veterans' Benefits?\"}\n", |
171 | 195 | "]\n", |
172 | 196 | "\n", |
173 | | - "text_embedding_model_name = 'sentence-transformers/sentence-t5-large'\n", |
| 197 | + "text_embedding_model_name = 'google/embeddinggemma-300m'\n", |
174 | 198 | "\n", |
175 | 199 | "\n", |
176 | 200 | "# helper function that returns a dict containing only first\n", |
|
191 | 215 | "source": [ |
192 | 216 | "\n", |
193 | 217 | "### Generate text embeddings\n", |
194 | | - "This example uses the model `sentence-transformers/sentence-t5-large` to generate text embeddings. The model uses only the encoder from a `T5-large model`. The weights are stored in FP16. For more information about the model, see [Sentence-T5: Scalable Sentence Encoders from Pre-trained Text-to-Text Models](https://arxiv.org/abs/2108.08877)." |
| 218 | + "This example uses the model `google/embeddinggemma-300m` to generate text embeddings. For more information about the model, see [the model card](https://huggingface.co/google/embeddinggemma-300m)." |
195 | 219 | ], |
196 | 220 | "metadata": { |
197 | 221 | "id": "SApMmlRLRv_e" |
|
0 commit comments