Step-by-Step Guide to Integrate Azure Cognitive’s Vector Search in Your ChatGPT-like App — Part 1 — Introduction

Akshay Kokane
4 min readAug 24, 2023

--

In my previous post, we touched upon methods to ingest data into Azure Cognitive Search. In this post, I’ll delve deeper into the exciting capabilities of Azure Cognitive Search that greatly benefit AI applications, including the intriguing realms of Semantic Search and Vector Search (in preview).

If you want to skip to implementation part, you can go to Part 2: https://medium.com/@akshaykokane09/step-by-step-guide-to-integrate-azure-cognitives-vector-search-in-your-chatgpt-like-app-part-2-7e32155dbf9e

Azure Cognitive Search (formerly known as “Azure Search”) is a cloud search service that gives developers infrastructure, APIs, and tools for building a rich search experience over private, heterogeneous content in web, mobile, and enterprise applications. Out of many capabilities of Azure Cognitive Search, this article focuses on Semantic and Vector Search, which are more relevant to current LLM Powered Apps.

Image Rerfernce : https://azure.microsoft.com/en-us/products/ai-services/cognitive-search

Although Semantic Search and Vector Search provides similar features, but the working is different. Common things are

  • Both provides relevant document based on user query in natural language
  • They can be used in LLM powered app for RAG

Semantic Search:

  1. Semantic search in Azure Cognitive Search make search results better when you search for text-based things.
  2. It works with a process called BM25, which ranks search results. If you interested to learn about BM25, this is great medium post on how BM25
  3. After ranking using BM25, it applies secondary ranking on the result using semantic ranking. Semantic ranking leverages some AI logic using transformer, to rerank the BM25 result.
  4. When you turn on semantic search, it makes search results better in two ways:
  • It re-ranks results: It puts the most related results higher up the list.
  • It gives extra information: It finds and gives back captions and answers that can make searching easier for people.

This cool tech comes from Bing (like the search engine) and Microsoft Research (the super smart people who invent stuff).

They’ve made it part of Cognitive Search, like an extra feature you can use. If you’re curious about the super smart stuff behind this, you can read more about it in the “How AI from Bing is powering Azure Cognitive Search” video from Microsoft Research .

Pros:

  • Easy to integrate, as no overhead of handling embeddings
  • All field is readable as no vectors involved
  • Managed service

Cons:

  • Ranking first uses BM25, the algorithm places significant emphasis on term frequency and document length, possibly disregarding crucial elements such as document structure and relevance feedback and then reranking is applied to this result.

Vector Search:

Vector search is a method to find similar things by converting items into mathematical vectors and measuring their closeness in a multidimensional space.

Vector search works by converting items into numerical vectors, like coordinates in space, and then using mathematical operations like cosine similarity to measure how similar they are. It involves techniques like those used by OpenAI to transform data into meaningful vectors for efficient searching.

  1. Collecting and Saving: It gathers special codes (vectors) from the stuff you want to search through and saves them in a special place called an index.
  2. Finding Similar Stuff: With these vectors, it can find things that are really similar to each other, like finding books that are like the one you really like.
  3. Helping Suggestions: It can also help suggest things you might like or want based on the things you’ve searched for before.
  4. Smart Architecture: It’s used in cool applications that want to find stuff in a smart way, like making smart answers or suggestions based on what you’re looking for.

Azure Cognitive Search doesn’t provide a vector encoder. You need to convert your text into vector representation and then store those vectors in Azure Cognitive Search.

For searching too, you need to convert your query into a vector using the embedding method, and then search using those vector representations

Image Reference : https://learn.microsoft.com/en-us/azure/search/vector-search-overview

In the upcoming parts, I will guide you through the process of creating an app similar to ChatGPT using Azure Cognitive Search. Additionally, I will provide a comparison between Semantic and Vector Search functionalities.

Pros:

  • The search score for Vector Search is bounded between -1 to +1
  • Vector search uses cosine/dotproduct etc similariies, to give us accurate documents relevant to our query context.
  • More relevant use case for AI Powered Apps
  • Managed service

Cons:

  • Overhead of embedding the data and query into vector.
  • Document Chunking is necessary, if document cannot fit in the vector dimensions.

Part 2: Shows implementation of Vector Search

References:

Disclaimer : This blog is not affiliated with, endorsed by, or sponsored in any way by Microsoft Corporation or any of its subsidiaries. Any references to Microsoft products, services, logos, or trademarks are used solely for the purpose of providing information and commentary. The views and opinions expressed on this blog are the author’s own and do not necessarily reflect the views or opinions of Microsoft Corporation

--

--

Akshay Kokane

Software Engineer at Microsoft | Microsoft Certified AI Engineer & Google Certified Data Engineer