A Super Easy Way to Try Similarity Search using Vald

5 min readJun 21, 2021


How to deploy Vald on your k3d within 5 minutes

Photo by Sebastian Unrau on Unsplash

In this post, we’ll show a quick and easy way to perform a similarity search using Vald.


Before we start, we need to install 4 tools.

If you have Homebrew installed, you can install them by the following command.

$ brew install helm
$ brew install jq
$ brew install k3d
$ brew install kubectl

Setting up a k3d cluster

Create a k3d cluster by executing the following command. It creates a cluster with 4 nodes (1 server + 3 agents).

$ k3d cluster create vald --api-port 6550 -p "8080:80@loadbalancer" --agents 3 --image=docker.io/rancher/k3s:v1.20.9-k3s1

Please ensure that kubectl cluster-info returns a proper result.

$ kubectl config use-context k3d-vald
$ kubectl cluster-info
Kubernetes master is running at
CoreDNS is running at
Metrics-server is running at

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Deploy Vald using Helm

Use Helm to deploy Vald to your k3d cluster.

$ helm repo add vald https://vald.vdaas.org/charts
$ helm install vald-cluster \
--version v1.1.0 \
--set defaults.image.tag=v1.1.0 \
--set gateway.backup.enabled=false \
--set gateway.meta.enabled=false \
--set gateway.lb.minReplicas=1 \
--set gateway.lb.hpa.enabled=false \
--set gateway.lb.ingress.enabled=true \
--set gateway.lb.ingress.host=localhost \
--set gateway.lb.ingress.annotations."ingress\.kubernetes\.io/protocol"=h2c \
--set gateway.lb.ingress.annotations."ingress\.kubernetes\.io/ssl-passthrough"="\"true\"" \
--set gateway.lb.ingress.annotations."traefik\.protocol"=h2c \
--set gateway.lb.ingress.annotations."kubernetes\.io/ingress\.class"=traefik \
--set gateway.lb.gateway_config.index_replica=3 \
--set agent.minReplicas=3 \
--set agent.resources.requests.cpu=100m \
--set agent.resources.requests.memory=100Mi \
--set agent.ngt.auto_index_check_duration=1m \
--set agent.ngt.auto_index_duration_limit=30m \
--set agent.ngt.dimension=300 \
--set agent.ngt.distance_type=l2 \
--set agent.ngt.object_type=float \
--set manager.compressor.enabled=false \
--set manager.backup.enabled=false \
--set meta.enabled=false \

Please wait until all components are ready on the k3d cluster. It’s ready if kubectl get pods returns Running status on all pods.

$ kubectl get pods
vald-agent-ngt-0 1/1 Running 0 70s
vald-agent-ngt-1 1/1 Running 0 54s
vald-agent-ngt-2 1/1 Running 0 41s
vald-discoverer-7f9d49dc54-zfl5s 1/1 Running 0 70s
vald-manager-index-5dd6d78d7c-qxvkq 1/1 Running 0 70s
vald-lb-gateway-6cf4548687-nqccd 1/1 Running 0 70s

Similarity Search

In this section, we’re going to try a similarity search of the common English words.

Install valdcli

valdcli is a useful application to send requests to Vald cluster. You can install it from the repository vdaas/vald-client-clj. The binaries for macOS and Linux are available.

For macOS,

$ curl -LO https://github.com/vdaas/vald-client-clj/releases/download/v1.1.0/valdcli-macos.zip
$ unzip valdcli-macos.zip

For Linux,

$ curl -LO https://github.com/vdaas/vald-client-clj/releases/download/v1.1.0/valdcli-linux-static.zip
$ unzip valdcli-linux-static.zip

Please put the executable valdcli in your PATH and confirm it shows help.

$ valdcli --help

Insert word vector data

Get an example JSON data from GitHub.

$ curl -O https://raw.githubusercontent.com/rinx/word2vecjson/master/data/wordvecs10000.json

It contains the word vectors for the 10000 most common English words. These vectors are generated using word2vec. Also, you can get 1000, 5000, and 25000 words datasets from the same repository.

Let’s try to insert the word vectors using valdcli stream-insert. wordvecs10000.json is a JSON file that has 10000 vectors (the format is like [{"id": "mac", "vector": [0.000001, 0.000002, ...]}]). Print the JSON by cat command and pass it to valdcli using pipe. valdcli stream-insert --json reads JSON data from stdin and inserts them into the Vald cluster.

$ cat wordvecs10000.json | valdcli -h localhost -p 8080 stream-insert --json

After insertion, the index manager will detect the uncommitted vectors and send requests to the agents to create indexes. It may take a few minutes. (depending on the duration of the auto_index_check_duration)

Search similar words

After creating indexes, the agents will be ready to receive search requests. Now we’ll try to use two types of methods to search for similar words.

Search by vector

Using valdcli, you can send your requests from JSON-formatted vector data. Let’s send a search request with a vector in wordvecs10000.json file. Using jq command, you can extract a vector of the word "mac".

$ cat wordvecs10000.json | jq -c '.[] | select(.id == "mac") | .vector'

This is a 300-dimensional vector. It represents the feature of the word “mac”.

Using this vector, a search request can be created like the following.

$ cat wordvecs10000.json | jq -c '.[] | select(.id == "mac") | .vector' | valdcli -h localhost -p 8080 search -n 5 -e 0.1 --json | jq
"id": "mac",
"distance": 0
"id": "windows",
"distance": 0.9622495
"id": "apple",
"distance": 0.9877319
"id": "leopard",
"distance": 1.0445662
"id": "computer",
"distance": 1.1087651

It returns the 5 most similar words of “mac”.

Search by ID

You can send a search request about a specific word in the index.

$ valdcli -h localhost -p 8080 search-by-id -n 10 -e 0.1 snow
[{:id "snow", :distance 0.0}
{:id "snowing", :distance 0.838368}
{:id "rain", :distance 0.86527264}
{:id "icy", :distance 0.93737966}
{:id "fog", :distance 0.95259696}
{:id "ice", :distance 0.9600457}
{:id "weather", :distance 0.98229766}
{:id "rains", :distance 0.9843779}
{:id "winter", :distance 1.0100114}
{:id "wet", :distance 1.0111399}]

It returns the 10 most similar words of “snow”.

(valdcli returns EDN formatted results by default. If you set — json option, it returns JSON formatted results.)


Please delete the cluster by the following command.

$ k3d cluster delete vald

In this article, we’ve introduced an example to perform similarity search using Vald.
For more information, please visit our website.




A highly scalable distributed fast approximate nearest neighbor dense vector search engine.