What is a vector search engine?
Tags: webdev, beginners, tooling, searchengine
Published: 2022-05-01 16:21:33

You might have come across the term **Search engine** a lot. In fact you do use search engines on daily basis to search through loads of data on the internet. A search engine is a piece of software that helps people find the information they need online by using *keywords* or *phrases*.

When you want to search a term online, you start with entering a term in the search engine. The search engine examines the website's title, keywords, content, basically all the meta content and employs algorithms to generate a list of sites.  

## So, what are Vector search engines? 

Traditional search engines are fantastic, but they are limited to keyword matching and cannot capture context. A single word can have multiple meanings; for example, if you search for the word *right*, there are several meanings associated with this. It can be *morally right*, *direction right*, or *human right*. Because the search engine does not understand why you typed that word in the first place, it will return results/sites that contain the word *right*.

<figure>
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbzvdznycd4rtcbome51.png">
  <figcaption>Image source: Google Cloud</figcaption>
</figure> 

How do we solve this issue? This is where **Vector Search Engines** come into play. In vector search, the text is encoded in such a way that semantically similar texts are near each other in the vector space, while dissimilar texts are far apart. To encode data sets into meaningful vector representations, vector search employs deep learning models.

In mathematical words, vector search allows us to represent unordered objects in a high-dimensional vector space as vectors. By comparing the distances and similarities between vectors, you can find similar content.

<figure>
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qmbwjuc8laziwv638oc.png">
  <figcaption>Image source: Google Cloud</figcaption>
</figure> 

In order to search, instead of comparing vectors one by one, i.e. using [KNN algorithm](https://www.javatpoint.com/k-nearest-neighbor-algorithm-for-machine-learning), which would take a lot of time to display search results, search engines use [ANN algorithm](https://erikbern.com/2015/10/01/nearest-neighbors-and-vector-models-part-2-how-to-search-in-high-dimensional-spaces.html) with the help of machine learning models. Many ANN algorithms divide the vector space into many groups, assign tags to each group, and search just for the tags assigned to that group. This method improves query times substantially.

<figure>
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ifdh9fyx8314onsodjt.png">
  <figcaption>Image source: erikbern.com</figcaption>
</figure>
 
To get clear idea on how ANN works, refer to this [video](https://youtu.be/DRbjpuqOsjk) and an [article](https://erikbern.com/2015/10/01/nearest-neighbors-and-vector-models-part-2-how-to-search-in-high-dimensional-spaces.html) written by the creator of ANN algorithm.

## Advantages of Vector Search

* **More relevant results:** Because vector search employs vector functions to locate similar content, the user can receive more relevant results. While the result cannot always be accurate, it does display more refined results rather than none at all.

* **Error handling:** Because vector search does not rely on keywords directly, it handles a wide range of issues out of the box. Misspelled queries and phrases are not an issue because it tries to return similar results. Long-tail keywords are keyword phrases that receive a small number of searches. They are very specific keywords aimed at a specific audience. Vector search engines can easily handle this as well.

* **Recommender System:** Because vector search produces similar results, it is an excellent recommender system. Based on their searched keywords, users are presented with a plethora of options available on the internet. This also assists businesses in reaching out to more customers and expanding their product.

* **Easily available trained models:** Many trained models are readily available on the internet, from which we can start implementing a vector search engine. To improve the relevancy, more specific models can be trained. 

* **Trained models work efficiently:** The collected queries are used to improve and train the underlying model of a vector search engine. As a result, users are presented with more refined and accurate results. 

Modern search engines like Google Search, Bing, Yahoo, DuckDuckGo, etc. all use vector search engines to provide users with best relevant results as possible. All the search results from billions of documents are **displayed within milliseconds** with the help of vector search. Vector search can be used in a variety of applications, including text, multimedia, image, and recommendation searches.

> Vector search basically makes searching a lot more natural and intuitive and you search by the concept rather than by the keywords. 
(Source: [Microsoft AI](https://www.microsoft.com/en-us/ai/ai-lab-vector-search))

<figure>
  <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mkygo6jeo9q9351p5g6i.png">
  <figcaption>Image source: Microsoft AI</figcaption>
</figure>

There are a few vector search engines which are Open Source, so that other people can actually use it in their products and help improve by contributing back to the vector search project. These are some popular standalone vector search services.  

* [**Weaviate Vector Search Engine**](https://weaviate.io/)  
* [**Milvus Vector Database**](https://milvus.io/)
* [**Qdrant Neural Search Engine**](https://qdrant.tech/)

If you want a proper curated list of various libraries and standalone services of vector search engines, refer to this awesome [GitHub repository](https://github.com/currentsapi/awesome-vector-search) by [Currents API](https://currentsapi.services/en).

If you want to experience vector search's capabilities, you can do it right now!! Two best resources I was able to find was:

* [**Microsoft's Vector Search**](https://vectorsearch.azurewebsites.net/) where you can choose or upload any images of your choice and see the similar results popping up.

* [**Google Lens**](https://lens.google/) on your phone, where you can point to anything, text or object, and it will scan and display relevant results.

If you want to learn more about how vector search works and how algorithms display relevant results, check out the resources listed below:

* [**Introducing the Weaviate Vector Search Engine! by Henry AI Labs**](https://youtu.be/AS_2U_INpKk)

* [**Google's vector search technology**](https://cloud.google.com/blog/topics/developers-practitioners/find-anything-blazingly-fast-googles-vector-search-technology)

* [**Microsoft's AI Lab Vector Search**](https://www.microsoft.com/en-us/ai/ai-lab-vector-search)

* [**How modern search engines work by Letitia**](https://youtu.be/Yl1XPoL48ZQ)

This was a basic explanation of what vector search engine is and how it works. If you like this blog, do give it a like and connect with me on [social media platforms](https://asmit.bio.link/).

## Happy Searching!! 🔍💻