Compare commits

...
Author SHA1 Message Date
Andrew Ferlitsch 6c66e36e23 fix: rebrand 2023-10-05 23:14:00 +00:00
@@ -24,7 +24,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "JAPoU8Sm5E6e"
@@ -50,11 +49,10 @@
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td> \n",
"</table>"
"</table>\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "tvgnzT1CKxrO"
@@ -62,11 +60,10 @@
"source": [
"## Overview\n",
"\n",
"This example demonstrates how to use Vertex AI Matching Engine. It is a high scale, low latency solution, to find similar vectors (or more specifically \"embeddings\") for a large corpus. Moreover, it is a fully managed offering, further reducing operational overhead. It is built upon [Approximate Nearest Neighbor (ANN) technology](https://ai.googleblog.com/2020/07/announcing-scann-efficient-vector.html) developed by Google Research."
"This example demonstrates how to use Vertex AI Vector Search. It is a high scale, low latency solution, to find similar vectors (or more specifically \"embeddings\") for a large corpus. Moreover, it is a fully managed offering, further reducing operational overhead. It is built upon [Approximate Nearest Neighbor (ANN) technology](https://ai.googleblog.com/2020/07/announcing-scann-efficient-vector.html) developed by Google Research."
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "56e5f9699c6c"
@@ -78,16 +75,15 @@
"\n",
"The steps performed include:\n",
"\n",
"* Create a Vertex AI Matching Engine Index and Brute Force Index\n",
"* Create a Vertex AI Vector Search Index and Brute Force Index\n",
"* Create an IndexEndpoint with VPC Network\n",
"* Deploy a Vertex AI Matching Engine Index and Brute Force Index\n",
"* Deploy a Vertex AI Vector Search Index and Brute Force Index\n",
"* Perform online queries\n",
"* Submit batch queries\n",
"* Compute recall metric"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "0aaef374550b"
@@ -99,7 +95,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "5e2eba58ad71"
@@ -120,7 +115,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "S5zc4kbEiYCm"
@@ -142,7 +136,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "4700b0e39c5d"
@@ -165,7 +158,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "cf00462144f7"
@@ -221,7 +213,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "249da91c1011"
@@ -250,7 +241,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "3fbfae3ff12a"
@@ -261,7 +251,7 @@
"You can also change the `REGION` variable used by Vertex AI. Learn more about [Vertex AI regions](https://cloud.google.com/vertex-ai/docs/general/locations).\n",
"* **WARNING:** \n",
" * **Make sure to [choose a region where Vertex AI services are available](https://cloud.google.com/vertex-ai/docs/general/locations#available_regions).**\n",
" * **If you use Vertex Workbench, the Notebook instance needs to be in the same region where your Vertex AI Matching Engine is deployed.** (for example, if you set `REGION = \"us-central1\"` as same as the tutorial, the notebook instance has to be in `us-central1`)."
" * **If you use Vertex Workbench, the Notebook instance needs to be in the same region where your Vertex AI Vector Search is deployed.** (for example, if you set `REGION = \"us-central1\"` as same as the tutorial, the notebook instance has to be in `us-central1`)."
]
},
{
@@ -279,7 +269,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "60c5a0f69ad8"
@@ -291,7 +280,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "d118c95af93f"
@@ -302,7 +290,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "3035286fcdda"
@@ -323,7 +310,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "5097f3233d53"
@@ -345,7 +331,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "fcdbb8929927"
@@ -356,7 +341,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "7c6eef70dfdb"
@@ -364,10 +348,10 @@
"source": [
"### Prepare a VPC network\n",
"\n",
"To reduce any network overhead that might lead to unnecessary increase in overhead latency, it is best to call the Vertex AI Matching Engine endpoints from your VPC via a direct [VPC Peering](https://cloud.google.com/vertex-ai/docs/general/vpc-peering) connection. The following section describes how to setup a VPC Peering connection if you don't have one. This is a one-time initial setup task. You can also reuse existing VPC network and skip this section.\n",
"To reduce any network overhead that might lead to unnecessary increase in overhead latency, it is best to call the Vertex AI Vector Search endpoints from your VPC via a direct [VPC Peering](https://cloud.google.com/vertex-ai/docs/general/vpc-peering) connection. The following section describes how to setup a VPC Peering connection if you don't have one. This is a one-time initial setup task. You can also reuse existing VPC network and skip this section.\n",
"\n",
"* **WARNING:** The match service gRPC API (to create online queries against your deployed index) has to be executed in a Google Cloud Notebook instance that is created with the following requirements:\n",
" * **Make sure you select the VPC network you created for Vertex AI Matching Engine service** (instead of using the \"default\" one). That is, you will have to create the VPC network below and then create a new notebook instance that uses that VPC. \n",
" * **Make sure you select the VPC network you created for Vertex AI Vector Search service** (instead of using the \"default\" one). That is, you will have to create the VPC network below and then create a new notebook instance that uses that VPC. \n",
" * If you run it in the colab or a Google Cloud Notebook instance in a different VPC network or region, the gRPC API will fail to peer the network (InactiveRPCError)."
]
},
@@ -408,7 +392,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "ddbace09fe81"
@@ -430,7 +413,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "zgPO1eR3CYjk"
@@ -661,7 +643,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "QuVl8DrWG8NS"
@@ -706,7 +687,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "mglUPwHpJH98"
@@ -716,13 +696,12 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "qhIBCQ7dDSbW"
},
"source": [
"### Create Vertex AI Matching Engine index (for production usage)"
"### Create Vertex AI Vector Search index (for production usage)"
]
},
{
@@ -739,7 +718,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "14e1ed031d66"
@@ -762,13 +740,12 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "svLYiDf0OD2G"
},
"source": [
"#### Create the Vertex AI Matching Engine index configuration\n",
"#### Create the Vertex AI Vector Search index configuration\n",
"\n",
"Please read the [documentation](https://cloud.google.com/vertex-ai/docs/matching-engine/configuring-indexes) to understand the various configuration parameters that can be used to tune the index"
]
@@ -810,7 +787,7 @@
"\n",
"matching_engine_index = {\n",
" \"display_name\": DISPLAY_NAME,\n",
" \"description\": \"Glove 100 Vertex AI Matching Engine Index\",\n",
" \"description\": \"Glove 100 Vertex AI Vector Search Index\",\n",
" \"metadata\": struct_pb2.Value(struct_value=metadata),\n",
"}"
]
@@ -859,7 +836,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "kSsqZuyoA1SG"
@@ -949,7 +925,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "mglUPwHpJH98"
@@ -1020,7 +995,7 @@
"matching_engine_index = {\n",
" \"name\": INDEX_RESOURCE_NAME,\n",
" \"display_name\": DISPLAY_NAME,\n",
" \"description\": \"Glove 100 Vertex AI Matching Engine Index\",\n",
" \"description\": \"Glove 100 Vertex AI Vector Search Index\",\n",
" \"metadata\": struct_pb2.Value(struct_value=metadata),\n",
"}"
]
@@ -1067,7 +1042,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "qV2xjAnDDObD"
@@ -1152,7 +1126,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "np2cgVuuIe9k"
@@ -1162,13 +1135,12 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "8Ew1UgcIIiJG"
},
"source": [
"### Deploy a Vertex AI Matching Engine index"
"### Deploy a Vertex AI Vector Search index"
]
},
{
@@ -1198,7 +1170,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "cb6d956d7419"
@@ -1249,7 +1220,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "RNZnXmO5AhDO"
@@ -1326,7 +1296,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "6LCGvBNvBd8D"
@@ -1528,7 +1497,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "8wXTSgz1Bl0x"
@@ -1699,7 +1667,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "_mNwdU9_B_Ez"
@@ -1964,7 +1931,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "_mNwdU9_B_Ez"
@@ -1972,7 +1938,7 @@
"source": [
"### Compute the recall metric\n",
"\n",
"Use the deployed brute force index as the ground truth to calculate the recall of the Vertex AI Matching Engine index:"
"Use the deployed brute force index as the ground truth to calculate the recall of the Vertex AI Vector Search index:"
]
},
{
@@ -2003,21 +1969,20 @@
"# This will take 5-10 min\n",
"\n",
"recall = sum(\n",
" [\n",
" \n",
" len(\n",
" set(get_neighbors(test[i], DEPLOYED_BRUTE_FORCE_INDEX_ID)).intersection(\n",
" set(get_neighbors(test[i], DEPLOYED_INDEX_ID))\n",
" )\n",
" )\n",
" for i in range(len(test))\n",
" ]\n",
" \n",
") / (1.0 * len(test) * k)\n",
"\n",
"print(\"Recall: {}\".format(recall))"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "TpV-iwP9qw9c"
@@ -2032,13 +1997,12 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "390c331dc7d9"
},
"source": [
"### Delete the Vertex AI Matching Engine resources"
"### Delete the Vertex AI Vector Search resources"
]
},
{
@@ -2065,7 +2029,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "ff14a85c85fb"