{VPC_NETWORK}-allow-rdp --network {VPC_NETWORK} --priority 65534 --project {PROJECT_ID} --allow tcp:3389 gcloud compute firewall-rules create {VPC_NETWORK}-allow-ssh --network {VPC_NETWORK} --priority 65534 --project {PROJECT_ID} --allow tcp:22    # Reserve IP range gcloud compute addresses create {PEERING_RANGE_NAME} --global --prefix-length=16 --network={VPC_NETWORK} --purpose=VPC_PEERING --project={PROJECT_ID} --description="peering range"    # Set up peering with service networking    # Your account must have the "Compute Network Admin" role to run the following. gcloud services vpc-peerings connect --service=servicenetworking.googleapis.com --network={VPC_NETWORK} --ranges={PEERING_RANGE_NAME} --project={PROJECT_ID}# Creating bucket. gsutil mb -l $REGION -p $PROJECT_ID $BUCKET_URIUsing Tensorflow Universal Sentence Encoder as an Embedder‚Äã# Load the Universal Sentence Encoder modulemodule_url = "https://tfhub.dev/google/universal-sentence-encoder-multilingual/3"model = hub.load(module_url)# Generate embeddings for each wordembeddings = model(["banana"])Inserting a test embedding‚Äãinitial_config = {    "id": "banana_id",    "embedding": [float(x) for x in list(embeddings.numpy()[0])],}with open("data.json", "w") as f:    json.dump(initial_config, f)gsutil cp data.json {EMBEDDING_DIR}/file.jsonaiplatform.init(project=PROJECT_ID, location=REGION, staging_bucket=BUCKET_URI)Creating Index‚Äãmy_index = aiplatform.MatchingEngineIndex.create_tree_ah_index(    display_name=DISPLAY_NAME,    contents_delta_uri=EMBEDDING_DIR,    dimensions=DIMENSIONS,    approximate_neighbors_count=150,    distance_measure_type="DOT_PRODUCT_DISTANCE",)Creating Endpoint‚Äãmy_index_endpoint = aiplatform.MatchingEngineIndexEndpoint.create(    display_name=f"{DISPLAY_NAME}-endpoint",    network=VPC_NETWORK_FULL,)Deploy Index‚Äãmy_index_endpoint = my_index_endpoint.deploy_index(    index=my_index,
This notebook shows how to use functionality related to the GCP Vertex AI MatchingEngine vector database.
This notebook shows how to use functionality related to the GCP Vertex AI MatchingEngine vector database. ->: {VPC_NETWORK}-allow-rdp --network {VPC_NETWORK} --priority 65534 --project {PROJECT_ID} --allow tcp:3389 gcloud compute firewall-rules create {VPC_NETWORK}-allow-ssh --network {VPC_NETWORK} --priority 65534 --project {PROJECT_ID} --allow tcp:22    # Reserve IP range gcloud compute addresses create {PEERING_RANGE_NAME} --global --prefix-length=16 --network={VPC_NETWORK} --purpose=VPC_PEERING --project={PROJECT_ID} --description="peering range"    # Set up peering with service networking    # Your account must have the "Compute Network Admin" role to run the following. gcloud services vpc-peerings connect --service=servicenetworking.googleapis.com --network={VPC_NETWORK} --ranges={PEERING_RANGE_NAME} --project={PROJECT_ID}# Creating bucket. gsutil mb -l $REGION -p $PROJECT_ID $BUCKET_URIUsing Tensorflow Universal Sentence Encoder as an Embedder‚Äã# Load the Universal Sentence Encoder modulemodule_url = "https://tfhub.dev/google/universal-sentence-encoder-multilingual/3"model = hub.load(module_url)# Generate embeddings for each wordembeddings = model(["banana"])Inserting a test embedding‚Äãinitial_config = {    "id": "banana_id",    "embedding": [float(x) for x in list(embeddings.numpy()[0])],}with open("data.json", "w") as f:    json.dump(initial_config, f)gsutil cp data.json {EMBEDDING_DIR}/file.jsonaiplatform.init(project=PROJECT_ID, location=REGION, staging_bucket=BUCKET_URI)Creating Index‚Äãmy_index = aiplatform.MatchingEngineIndex.create_tree_ah_index(    display_name=DISPLAY_NAME,    contents_delta_uri=EMBEDDING_DIR,    dimensions=DIMENSIONS,    approximate_neighbors_count=150,    distance_measure_type="DOT_PRODUCT_DISTANCE",)Creating Endpoint‚Äãmy_index_endpoint = aiplatform.MatchingEngineIndexEndpoint.create(    display_name=f"{DISPLAY_NAME}-endpoint",    network=VPC_NETWORK_FULL,)Deploy Index‚Äãmy_index_endpoint = my_index_endpoint.deploy_index(    index=my_index,