/MatchItFast

Primary LanguageTypeScript

MatchIt Fast

MatchIt Fast is the demonstration application with Vertex Matching Engine.

MatchIt Fast demonstrates the blazingly fast similarity search among several million images/articles using the Vertex Matching Engine.

https://matchit.magellanic-clouds.com/

Architecture

Architecture

How it works

See How it works

Preparation

Google Cloud Platform Project

You need to have a Google Cloud Platform project with enabled billing account.

VPC Network

Currently Vertex Matcing Engine index endpoints can be access via only Private Service Access. You need to create a VPC Network to be configured several VPC service components. See the documentation of VPC networks for how to create a VPC network in your Google Cloud Platform Project.

Configure Matching Engine

To create Indexes and deploy them to the Index Endpoints, see the documentation.

MatchIt Fast app requires the two indexes of images and articles deployed to index endpoints and accessible via Private Service Access. The Private Service Access should be configured on the VPC network you created above.

The example command lines to create Matching Engine index for the MatchIt Fast demonstration are shown below.

gcloud --project=gn-match-it-fast beta ai indexes create \
       --display-name=gdelt-gsg \
       --description="GDELT GSG Demo" \
       --metadata-file=metadata/gdelt_gsg_index_metadata.json \
       --region=us-central1
gcloud --project=gn-match-it-fast beta ai indexes create \
       --display-name=wikimedia-images \
       --description="Wikimedia Image Demo" \
       --metadata-file=metadata/wikimedia_images_index_metadata.json \
       --region=us-central1

Serverless VPC Access

To access Matching Engine Index Endpoints via Private Service Access from App Engine, you need to create Serverless VPC Access. The connector of Serverless VPC Access should be created on the VPC network you created above.

GCE instance with container

To retrieve document embedding using the Universal Sentence Encoder, you need to deploy the container on the GCE instance. Be careful to create the instance in the VPC network you created for the demo app.

The container image could be build with Cloud Build. The configuration for Cloud Built trigger is utilities/containers/gsg-encoder/cloudbuild.yaml.

The GCE instance with container is handfull way to deploy container.

gcloud --project=MY-PROJECT-ID compute instances create-with-container INSTANCE-NAME \
    --subnet=MY-VPC-NAME \
    --zone=us-central1-a --machine-type=e2-medium \
    --image-family=cos-dev --image-project=cos-cloud --boot-disk-size=50GB \
    --container-image=gcr.io/MY-PROJECT-ID/universal-sentence-encoder-app:latest

Run Demo Application

Running on the Google App Engine.

1. Configurations

Change the following setting values in app.yaml.

env_variables

environment variable description
MATCHING_ENGINE_DEPLOYED_INDEX_ID The deployed index ID for image search
MATCHING_ENGINE_ENDPOINT_IP The IP address of deployed index for image search
GDELT_GSG_DEPLOYED_INDEX_ID The deployed index ID for news search
GDELT_GSG_ENDPOINT_IP The IP address of deployed index for news search
GDELT_GSG_APP_ENDPOINT 'http://{IP-ADDR}' IP-ADDR should be replaced with the internal IP address of the GCE instance you created.

vpc_access_connector

Specify Serverless VPC Access connector name.

2. Deploy

Perform the following gcloud command to deploy App Engine application in your GCP project.

gcloud --project YOUR-PROJECT-ID app deploy

3. Browse your application

After you deployed to App Engine, you can run the following command to launch your browser and view the app at https://[YOUR-PROJECT-ID].appspot.com:

gcloud app browse