|
37 | 37 | "id": "1_3oPpdBAduw" |
38 | 38 | }, |
39 | 39 | "source": [ |
40 | | - "# Semantic Retriever Quickstart" |
| 40 | + "# Get started with semantic retrieval" |
41 | 41 | ] |
42 | 42 | }, |
43 | 43 | { |
|
48 | 48 | "source": [ |
49 | 49 | "<table class=\"tfo-notebook-buttons\" align=\"left\">\n", |
50 | 50 | " <td>\n", |
51 | | - " <a target=\"_blank\" href=\"https://ai.google.dev/docs/semantic_retriever\"><img src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on ai.google.dev</a>\n", |
| 51 | + " <a target=\"_blank\" href=\"https://ai.google.dev/gemini-api/docs/semantic_retrieval\"><img src=\"https://ai.google.dev/static/site-assets/images/docs/notebook-site-button.png\" height=\"32\" width=\"32\" />View on ai.google.dev</a>\n", |
52 | 52 | " <td>\n", |
53 | | - " <a target=\"_blank\" href=\"https://colab.research.google.com/github/google/generative-ai-docs/blob/main/site/en/docs/semantic_retriever.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n", |
| 53 | + " <a target=\"_blank\" href=\"https://colab.research.google.com/github/google/generative-ai-docs/blob/main/site/en/gemini-api/docs/semantic_retrieval.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n", |
54 | 54 | " </td>\n", |
55 | 55 | " <td>\n", |
56 | | - " <a target=\"_blank\" href=\"https://github.com/google/generative-ai-docs/blob/main/site/en/docs/semantic_retriever.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n", |
| 56 | + " <a target=\"_blank\" href=\"https://github.com/google/generative-ai-docs/blob/main/site/en/gemini-api/docs/semantic_retrieval.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n", |
57 | 57 | " </td>\n", |
58 | 58 | "</table>" |
59 | 59 | ] |
|
113 | 113 | "source": [ |
114 | 114 | "## Authenticate\n", |
115 | 115 | "\n", |
116 | | - "The Semantic Retriever API lets you perform semantic search on your own data. Since it's **your data**, this needs stricter access controls than API keys. Authenticate with OAuth with [service accounts](#scrollTo=eLjhFIOQ7_Dk) or through your [user credentials](#scrollTo=9YGv4x9ehLba).\n", |
| 116 | + "The Semantic Retriever API lets you perform semantic search on your own data. Since it's **your data**, this needs stricter access controls than API keys. Authenticate with OAuth with [service accounts](#service-oauth) or through your [user credentials](#user-oauth).\n", |
117 | 117 | "\n", |
118 | 118 | "This quickstart uses a simplified authentication approach meant for a testing environment, and service account setups are typically easier to start from. For a production environment, learn about [authentication and authorization](https://developers.google.com/workspace/guides/auth-overview){:.external} before choosing the [access credentials](https://developers.google.com/workspace/guides/create-credentials#choose_the_access_credential_that_is_right_for_you){:.external} that are appropriate for your app.\n" |
119 | 119 | ] |
|
124 | 124 | "id": "eLjhFIOQ7_Dk" |
125 | 125 | }, |
126 | 126 | "source": [ |
127 | | - "### Setup OAuth using service accounts\n", |
| 127 | + "### Setup OAuth using service accounts {:#service-oauth}\n", |
128 | 128 | "\n", |
129 | 129 | "Follow the steps below to setup OAuth using service accounts:\n", |
130 | 130 | "\n", |
|
204 | 204 | "id": "4EQJD2PWD56T" |
205 | 205 | }, |
206 | 206 | "source": [ |
207 | | - "## Create a corpus\n", |
| 207 | + "## Create a corpus {:#create-corpus}\n", |
208 | 208 | "\n", |
209 | 209 | "The Semantic Retriever API lets you define up to 5 custom text corpora per project. You can specify either of the following fields while defining your corpora:\n", |
210 | 210 | "\n", |
|
218 | 218 | "metadata": { |
219 | 219 | "id": "AaPZiXVwEDHZ" |
220 | 220 | }, |
221 | | - "outputs": [], |
| 221 | + "outputs": [ |
| 222 | + { |
| 223 | + "name": "stdout", |
| 224 | + "output_type": "stream", |
| 225 | + "text": [ |
| 226 | + "name: \"corpora/google-for-developers-blog-dqrtz8rs0jg\"\n", |
| 227 | + "display_name: \"Google for Developers Blog\"\n", |
| 228 | + "create_time {\n", |
| 229 | + " seconds: 1713497533\n", |
| 230 | + " nanos: 587977000\n", |
| 231 | + "}\n", |
| 232 | + "update_time {\n", |
| 233 | + " seconds: 1713497533\n", |
| 234 | + " nanos: 587977000\n", |
| 235 | + "}\n", |
| 236 | + "\n" |
| 237 | + ] |
| 238 | + } |
| 239 | + ], |
222 | 240 | "source": [ |
223 | 241 | "example_corpus = glm.Corpus(display_name=\"Google for Developers Blog\")\n", |
224 | 242 | "create_corpus_request = glm.CreateCorpusRequest(corpus=example_corpus)\n", |
|
739 | 757 | "Since a low `answerable_probability` indicates that the GenerateAnswerResponse.answer is likely wrong or ungrounded, **it is highly recommended to further process the response by inspecting `answerable_probability`**.\n", |
740 | 758 | "\n", |
741 | 759 | "When `answerable_probability` is low, some clients may wish to:\n", |
742 | | - "* Display a message to the effect of \"We couldn't answer that question\" to the end user.\n", |
| 760 | + "* Display a message to the effect of \"couldn't answer that question\" to the end user.\n", |
743 | 761 | "* Fall back to a general-purpose LLM that answers the question from world knowledge. The threshold and nature of such fallbacks will depend on individual use cases. A value of `answerable_probability` <= 0.5 is a good starting threshold.\n" |
744 | 762 | ] |
745 | 763 | }, |
|
934 | 952 | "id": "9YGv4x9ehLba" |
935 | 953 | }, |
936 | 954 | "source": [ |
937 | | - "## Appendix: Setup OAuth with user credentials\n", |
| 955 | + "## Appendix: Setup OAuth with user credentials {:#user-oauth}\n", |
938 | 956 | "\n", |
939 | 957 | "Follow the steps below from the [OAuth Quickstart](https://ai.google.dev/docs/oauth_quickstart) to setup OAuth authentication.\n", |
940 | 958 | "\n", |
|
977 | 995 | "id": "lybTOlN9gz0I" |
978 | 996 | }, |
979 | 997 | "source": [ |
980 | | - "Initialize the client library and re-run the notebook starting from [Create a corpus](#scrollTo=4EQJD2PWD56T)." |
| 998 | + "Initialize the client library and re-run the notebook starting from [Create a corpus](#create-corpus)." |
981 | 999 | ] |
982 | 1000 | }, |
983 | 1001 | { |
|
998 | 1016 | ], |
999 | 1017 | "metadata": { |
1000 | 1018 | "colab": { |
1001 | | - "name": "semantic_retriever.ipynb", |
| 1019 | + "name": "semantic_retrieval.ipynb", |
1002 | 1020 | "toc_visible": true |
1003 | 1021 | }, |
1004 | 1022 | "google": { |
|
0 commit comments