<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: PLABAN NAYAK</title>
    <description>The latest articles on DEV Community by PLABAN NAYAK (@plaban1981).</description>
    <link>https://dev.to/plaban1981</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1241005%2Fc4b39df0-ea4a-472c-b2c7-2043d4ab6dd3.jpeg</url>
      <title>DEV Community: PLABAN NAYAK</title>
      <link>https://dev.to/plaban1981</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/plaban1981"/>
    <language>en</language>
    <item>
      <title>How to use FiftyOne and Qdrant to Search through Billions of Images in Computer Vision Applications</title>
      <dc:creator>PLABAN NAYAK</dc:creator>
      <pubDate>Tue, 30 Jan 2024 02:23:47 +0000</pubDate>
      <link>https://dev.to/plaban1981/how-to-use-fiftyone-and-qdrant-to-search-through-billions-of-images-in-computer-vision-applications-2oie</link>
      <guid>https://dev.to/plaban1981/how-to-use-fiftyone-and-qdrant-to-search-through-billions-of-images-in-computer-vision-applications-2oie</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqn37nra2ojwpea78vdxx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqn37nra2ojwpea78vdxx.png" alt="Image Search Workflow Implementation" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Enhancing Computer Vision Workflows with Multi-Modal Search: A Deep Dive into CLIP Integration
&lt;/h2&gt;

&lt;p&gt;Machine learning has witnessed a remarkable evolution in recent years, with one of the most exciting developments being the significant strides in multi-modal AI. This progress has fostered a synergistic relationship between computer vision and natural language processing, catalyzed by breakthroughs such as OpenAI’s CLIP model. Employing a contrastive learning technique, CLIP seamlessly embeds diverse multimedia content — ranging from language to images — into a unified latent space.&lt;/p&gt;

&lt;p&gt;The unparalleled capabilities of multi-modal models like CLIP have propelled advancements in various domains, including zero-shot image classification, knowledge transfer, synthetic data generation, and semantic search. In this article, our focus will be on the latter — leveraging the power of CLIP for natural language image search.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unveiling the Integration
&lt;/h2&gt;

&lt;p&gt;Traditionally, vector search tools and libraries have stood as independent entities, providing glimpses into the potential of cross-domain searches. Today, however, we present a groundbreaking approach to seamlessly incorporate natural language image search directly into your computer vision workflows. Our integration involves three key components: the open-source computer vision toolkit FiftyOne, the vector database Qdrant, and the powerful CLIP model from OpenAI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding CLIP’s Role
&lt;/h2&gt;

&lt;p&gt;At the heart of our integration lies OpenAI’s CLIP model, which acts as the bridge between textual and visual domains. CLIP’s contrastive learning methodology allows it to encode textual descriptions and corresponding images into a shared latent space. This intrinsic capability forms the foundation for our natural language image search.&lt;/p&gt;

&lt;p&gt;OpenAI’s CLIP (Contrastive Language-Image Pre-training) model is a powerful and innovative deep learning model designed for understanding and processing both natural language and images in a unified framework. Developed by OpenAI, CLIP leverages a contrastive learning approach to learn a shared representation space for text and images, enabling it to understand the relationships between the two modalities. The model was introduced in a research paper titled “CLIP: Connecting Text and Images for Zero-Shot Learning.”&lt;/p&gt;

&lt;p&gt;Key characteristics and components of the CLIP model include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unified Embedding Space :CLIP is trained to embed images and corresponding textual descriptions into the same high-dimensional space. This shared space allows for direct comparison and understanding of the relationships between visual and textual concepts.&lt;/li&gt;
&lt;li&gt;Contrastive Learning : The training of CLIP involves contrastive learning, a technique where the model learns by contrasting positive pairs (correct image-text pairs) with negative pairs (incorrect image-text pairs). This process encourages the model to bring similar images and texts closer together while pushing dissimilar pairs apart in the embedding space.&lt;/li&gt;
&lt;li&gt;Vision Transformer (ViT) Architecture : CLIP is built upon the Vision Transformer (ViT) architecture, which has proven effective in image processing tasks. ViT divides images into fixed-size patches and processes them using transformer layers, allowing the model to capture both local and global information in images.&lt;/li&gt;
&lt;li&gt;Text Tokenization : CLIP uses a text tokenization method to convert textual descriptions into a format suitable for input to the model. This ensures that both images and text can be processed consistently.&lt;/li&gt;
&lt;li&gt;Zero-Shot Learning :One of the notable features of CLIP is its ability to perform zero-shot learning. This means the model can generalize to recognize images or understand text related to categories it has not seen during training. This is achieved by leveraging the shared embedding space, allowing the model to make predictions based on semantic similarities.&lt;/li&gt;
&lt;li&gt;Versatility in Tasks : CLIP has demonstrated effectiveness across a wide range of tasks, including image classification, object detection, natural language image retrieval, and even tasks that require understanding nuanced textual prompts.&lt;/li&gt;
&lt;li&gt;Pre-Trained Models : OpenAI provides pre-trained CLIP models in various configurations, allowing users to leverage the model’s capabilities without extensive training. These pre-trained models can be fine-tuned for specific tasks if needed.
Applications of CLIP span various domains, including computer vision, natural language processing, and AI-driven systems that require a unified understanding of both visual and textual information. The model’s versatility and performance make it a valuable tool for developers and researchers working on multi-modal AI applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FiftyOne: Bridging Vision and Language
&lt;/h2&gt;

&lt;p&gt;FiftyOne serves as the glue that seamlessly connects CLIP with your computer vision workflows. This open-source toolkit provides an intuitive interface for exploring, visualizing, and iterating over your multi-modal datasets. We will delve into how FiftyOne facilitates the integration, enabling you to harness the power of CLIP with ease.&lt;/p&gt;

&lt;p&gt;FiftyOne is an open-source Python package designed to facilitate the exploration, visualization, and analysis of computer vision datasets. It provides a user-friendly interface for working with diverse datasets, especially those involving images and annotations. FiftyOne aims to simplify the process of understanding and debugging machine learning models by offering tools for visualizing model predictions, analyzing dataset statistics, and iteratively refining the dataset during the development process.&lt;/p&gt;

&lt;p&gt;Key features of the FiftyOne package include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interactive Exploration : Interactive and customizable UI that allows users to explore images and their associated annotations. This facilitates a deeper understanding of the dataset’s characteristics.&lt;/li&gt;
&lt;li&gt;Visualization Tools : Users can visualize images, ground truth annotations, and model predictions directly within the FiftyOne interface. This is particularly useful for inspecting model outputs and assessing the model’s performance.&lt;/li&gt;
&lt;li&gt;Dataset Statistics : The package offers tools to compute and visualize various statistics about the dataset, such as class distribution, label co-occurrence, and image quality metrics. This aids in gaining insights into the dataset’s composition and potential biases.&lt;/li&gt;
&lt;li&gt;Debugging Models : FiftyOne is designed to help users debug and analyze the outputs of machine learning models. It allows users to visualize model predictions, compare them with ground truth annotations, and identify areas where the model may need improvement.&lt;/li&gt;
&lt;li&gt;Annotation Integration : The package supports various annotation formats commonly used in computer vision tasks, including bounding boxes, segmentation masks, keypoints, and classification labels. This flexibility makes it suitable for a wide range of computer vision applications.&lt;/li&gt;
&lt;li&gt;Iterative Dataset Refinement : Users can iteratively refine datasets by adding or modifying annotations directly within the FiftyOne interface. This supports an agile development process, where datasets can be improved based on insights gained during exploration.&lt;/li&gt;
&lt;li&gt;Compatibility with Deep Learning Frameworks : FiftyOne integrates with popular deep learning frameworks such as TensorFlow and PyTorch. This allows users to seamlessly incorporate it into their machine learning workflows.&lt;/li&gt;
&lt;li&gt;Extensibility :The package is designed to be extensible, and users can build custom plugins and extensions to tailor it to their specific needs.
FiftyOne is a valuable tool for researchers, data scientists, and machine learning practitioners working on computer vision projects. It enhances the efficiency of the data exploration and model development process by providing a unified platform for visualizing and interacting with image datasets.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Qdrant: Powering Vector Search
&lt;/h2&gt;

&lt;p&gt;To augment our natural language image search, we leverage Qdrant — a vector database that excels in handling high-dimensional data efficiently. Qdrant’s ability to index and search vectors at scale is pivotal in making our integration scalable and performant.&lt;/p&gt;

&lt;p&gt;Qdrant “is a vector similarity search engine that provides a production-ready service with a convenient API to store, search, and manage points (i.e. vectors) with an additional payload.” You can think of the payloads as additional pieces of information that can help you hone in on your search and also receive useful information that you can give to your users.&lt;/p&gt;

&lt;p&gt;You can get started using Qdrant with the Python qdrant-client, by pulling the latest docker image of Qdrant and connecting to it locally, or by trying out Qdrant’s Cloud free tier option until you are ready to make the full switch.&lt;/p&gt;

&lt;p&gt;For step by step Implementation please follow the below &lt;a href="https://nayakpplaban.medium.com/how-to-use-fiftyone-and-qdrant-to-search-through-billions-of-images-in-computer-vision-applications-ca1d85ef8cab"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The amalgamation of FiftyOne, Qdrant, and CLIP introduces a new dimension to computer vision workflows. By seamlessly incorporating natural language image search, users can unlock novel applications, ranging from content discovery to interactive exploration of multi-modal datasets. As the landscape of multi-modal AI continues to evolve, this integration stands at the forefront, exemplifying the potential of cross-pollination between computer vision and natural language processing.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://qdrant.tech/documentation/frameworks/fifty-one/"&gt;https://qdrant.tech/documentation/frameworks/fifty-one/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://voxel51.com/"&gt;https://voxel51.com/&lt;/a&gt;&lt;br&gt;
connect with me&lt;/p&gt;

</description>
      <category>fiftyone</category>
      <category>qdrant</category>
    </item>
    <item>
      <title>Building an Application for Facial Recognition Using Python, OpenCV, Transformers and Qdrant</title>
      <dc:creator>PLABAN NAYAK</dc:creator>
      <pubDate>Fri, 29 Dec 2023 05:17:29 +0000</pubDate>
      <link>https://dev.to/plaban1981/building-an-application-for-facial-recognition-using-python-opencv-transformers-and-qdrant-5fah</link>
      <guid>https://dev.to/plaban1981/building-an-application-for-facial-recognition-using-python-opencv-transformers-and-qdrant-5fah</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tvPvrTej--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n8jc4yf04nr9yjbclaqt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tvPvrTej--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n8jc4yf04nr9yjbclaqt.png" alt="Face Regonition Application Workflow" width="800" height="519"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Method 1. Facial Recognition Using Python, OpenCV and Qdrant.&lt;/strong&gt;&lt;br&gt;
Facial recognition technology has become a ubiquitous force, reshaping industries like security, social media, and smartphone authentication. In this blog, we dive into the captivating realm of facial recognition armed with the formidable trio of Python, OpenCV, image embeddings and Qdrant. Join us on this journey as we unravel the intricacies of creating a robust facial recognition system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 1: An Introduction to Facial Recognition&lt;/strong&gt;&lt;br&gt;
In Part 1, we lay the foundation by delving into the fundamentals of facial recognition technology. Understand the underlying principles, explore its applications, and grasp the significance of Python and OpenCV in our development stack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 2: Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
A crucial step in any project is preparing the development environment. Learn how to seamlessly integrate Python, OpenCV, and Qdrant to create a harmonious ecosystem for our facial recognition system. We provide step-by-step instructions, ensuring you have solid groundwork before moving forward.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 3: Implementation of Facial Recognition Algorithms&lt;/strong&gt;&lt;br&gt;
With the groundwork in place, we dive into the core of the project. Explore the intricacies of facial recognition algorithms and witness the magic unfold as we implement them using Python and OpenCV. Uncover the inner workings of face detection, feature extraction, and model training.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 4: Database Integration with Qdrant&lt;/strong&gt;&lt;br&gt;
No facial recognition system is complete without a robust database to store and manage facial data efficiently. In the final installment, we guide you through the integration of Qdrant, to enhance the storage and retrieval capabilities of our system. Witness the synergy between Python, OpenCV, and Qdrant as we bring our project to its culmination.&lt;/p&gt;

&lt;p&gt;By the end of this blog, you would have gained a comprehensive understanding of facial recognition technology and the practical skills to develop your own system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-by-Step Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download all the pictures of interest into a local folder.&lt;/li&gt;
&lt;li&gt;Identify and extract faces from the pictures.&lt;/li&gt;
&lt;li&gt;Calculate facial embeddings from the extracted faces.&lt;/li&gt;
&lt;li&gt;Store these facial embeddings in a Qdrant database.&lt;/li&gt;
&lt;li&gt;Obtain a colleague’s picture for identification purposes.&lt;/li&gt;
&lt;li&gt;Match the face with the provided picture.&lt;/li&gt;
&lt;li&gt;Calculate embeddings for the identified face in the provided picture.&lt;/li&gt;
&lt;li&gt;Utilize the Qdrant distance function to retrieve the closest matching faces and corresponding photos from the database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This experiment demonstrates the practical implementation of Python OpenCV and advanced AI technologies in creating a sophisticated Facial recognition / Search Application, showcasing the potential for enhanced user interactions and cognitive responses. Since images are sensitive data ,we do not want to rely on any online service or upload them onto the internet. The entire pipeline defined above is developed to work 100% locally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Technology Stack&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Qdrant:&lt;/strong&gt; &lt;em&gt;Vector store for storing image embeddings.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenCV:&lt;/strong&gt; &lt;em&gt;Detect faces from the images. To “extract” faces from the pictures we used Python, OpenCV, a computer vision tool, and a pre-trained Haar Cascade model.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;imgbeddings:&lt;/strong&gt; &lt;em&gt;A Python package to generate embedding vectors from images, using OpenAI’s robust CLIP model via Hugging Face transformers.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;An Overview of OpenCV&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OpenCV, or Open Source Computer Vision Library, is an open-source computer vision and machine learning software library. Originally developed by Intel, OpenCV is now maintained by a community of developers. It provides a wide range of tools and functions for image and video analysis, including various algorithms for image processing, computer vision, and machine learning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key features of OpenCV include:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Image Processing:&lt;/strong&gt; &lt;em&gt;OpenCV offers a plethora of functions for basic and advanced image processing tasks, such as filtering, transformation, and color manipulation.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Computer Vision Algorithms:&lt;/strong&gt; _The library includes implementation of various computer vision algorithms, including feature detection, object recognition, and image stitching.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Machine Learning:&lt;/strong&gt; OpenCV integrates with machine learning frameworks and provides tools for training and deploying machine learning models. This is particularly useful for tasks like object detection and facial recognition._&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Camera Calibration:&lt;/strong&gt; &lt;em&gt;OpenCV includes functions for camera calibration, essential in computer vision applications to correct distortions caused by camera lenses.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-time Computer Vision:&lt;/strong&gt; &lt;em&gt;It supports real-time computer vision applications, making it suitable for tasks like video analysis, motion tracking, and augmented reality.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-Platform Support:&lt;/strong&gt; &lt;em&gt;OpenCV is compatible with various operating systems, including Windows, Linux, macOS, Android, and iOS. This makes it versatile for a wide range of applications.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community Support:&lt;/strong&gt; &lt;em&gt;With a large and active community, OpenCV is continuously evolving, with contributions from researchers, developers, and engineers worldwide.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OpenCV is widely used in academia, industry, and research for tasks ranging from simple image manipulation to complex computer vision and machine learning applications. Its versatility and comprehensive set of tools make it a go-to library for developers working in the field of computer vision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An Overview of imgbeddings&lt;/strong&gt;&lt;br&gt;
Here’s a Python package to generate embedding vectors from images, using OpenAI’s robust CLIP model via Hugging Face transformers. These image embeddings, derived from an image model that has seen the entire internet up to mid-2020, can be used for many things: unsupervised clustering (e.g. via umap), embeddings search (e.g. via faiss), and using downstream for other framework-agnostic ML/AI tasks such as building a classifier or calculating image similarity.&lt;/p&gt;

&lt;p&gt;The embeddings generation models are ONNX INT8-quantized — meaning they’re 20–30% faster on the CPU, much smaller on disk, and don’t require PyTorch or TensorFlow as a dependency!&lt;br&gt;
Works for many different image domains, thanks to CLIP’s zero-shot performance.&lt;br&gt;
Includes utilities for using principal component analysis (PCA) to reduce the dimensionality of generated embeddings without losing much info.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vector Store Explained&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;&lt;br&gt;
Vector stores are specialized databases designed for efficient storage and retrieval of vector embeddings. This specialization is crucial, as conventional databases like SQL are not finely tuned for handling extensive vector data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Role of Embeddings&lt;/strong&gt;&lt;br&gt;
Embeddings represent data, typically unstructured data like text or images, in numerical vector formats within a high-dimensional space. Traditional relational databases are ill-suited for storing and retrieving these vector representations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features of Vector Stores&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Efficient Indexing:&lt;/strong&gt; Vector stores can index and rapidly search for similar vectors using similarity algorithms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Retrieval:&lt;/strong&gt; This functionality allows applications to identify related vectors based on a provided target vector query.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;An Overview of Qdrant&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Getting started with Qdrant is seamless. Utilize the Python qdrant-client, access the latest Docker image of Qdrant and establish a local connection, or explore Qdrant’s Cloud free tier option until you are prepared for a comprehensive transition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;High-Level Qdrant Architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2HnP98xQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mhwt8diy2fdrnyp56xwh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2HnP98xQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mhwt8diy2fdrnyp56xwh.png" alt="Image description" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding Semantic Similarity&lt;/strong&gt;&lt;br&gt;
Semantic similarity, in the context of a set of documents or terms, is a metric that gauges the distance between items based on the similarity of their meaning or semantic content, rather than relying on lexicographical similarities. This involves employing mathematical tools to assess the strength of the semantic relationship between language units, concepts, or instances. The numerical description obtained through this process results from comparing the information that supports their meaning or describes their nature.&lt;/p&gt;

&lt;p&gt;It’s crucial to distinguish between semantic similarity and semantic relatedness. Semantic relatedness encompasses any relation between two terms, whereas semantic similarity specifically involves ‘is a’ relation. This distinction clarifies the nuanced nature of semantic comparisons and their application in various linguistic and conceptual contexts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 2. Using Transformers and Qdrant for Image Recognition&lt;/strong&gt;&lt;br&gt;
Apart from OpenCV, we can also use Vision Transformers to perform the same task. &lt;/p&gt;

&lt;p&gt;For detailed code implementation please refer &lt;a href="https://medium.com/@nayakpplaban/building-an-application-for-facial-recognition-using-python-opencv-transformers-and-qdrant-a144871f40d9"&gt;here&lt;/a&gt;&lt;br&gt;
References&lt;br&gt;
&lt;a href="https://qdrant.tech/documentation"&gt;https://qdrant.tech/documentation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/opencv/opencv"&gt;https://github.com/opencv/opencv&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/plaban-nayak-a9433a25/"&gt;connect with me&lt;/a&gt;&lt;/p&gt;

</description>
      <category>qdrant</category>
      <category>opencv</category>
      <category>transformers</category>
    </item>
    <item>
      <title>Building an Ecommerce-Based Search Application Using Langchain and Qdrant’s Latest Pure Vector-Based Hybrid Search</title>
      <dc:creator>PLABAN NAYAK</dc:creator>
      <pubDate>Mon, 25 Dec 2023 11:43:26 +0000</pubDate>
      <link>https://dev.to/plaban1981/building-an-ecommerce-based-search-application-using-langchain-and-qdrants-latest-pure-vector-based-hybrid-search-2ei7</link>
      <guid>https://dev.to/plaban1981/building-an-ecommerce-based-search-application-using-langchain-and-qdrants-latest-pure-vector-based-hybrid-search-2ei7</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7NLjGHTn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a834beo53bkogeesogj7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7NLjGHTn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a834beo53bkogeesogj7.png" alt="Workflow for Image and Text based search using Qdrant’s Vector Based Hybrid Search" width="800" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Keyword Search?
&lt;/h2&gt;

&lt;p&gt;Keyword search, also known as keyword-based search, is a traditional and fundamental method of retrieving information from a database or a search engine. It involves using specific words or phrases (keywords) to search for documents, web pages, or other forms of data that contain those exact terms or closely related variations.&lt;/p&gt;

&lt;p&gt;Here’s how keyword search typically works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User Input:&lt;/strong&gt; The user enters one or more keywords or key phrases into a search box, representing the information they are looking for.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Matching Algorithm:&lt;/strong&gt; The search engine or system uses a matching algorithm to identify documents or content that contain the exact keywords or closely related terms.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ranking:&lt;/strong&gt; The search results are ranked based on relevance, often using algorithms that consider factors like keyword frequency, proximity, and other relevance indicators.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Display of Results:&lt;/strong&gt; The system displays the search results to the user, usually in a list format, with each result containing a title, snippet, and a link to the full content.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The key characteristics of keyword search include:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Explicit Query:&lt;/strong&gt; The user provides a specific query made up of terms they believe are relevant to their information needs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Literal Matching:&lt;/strong&gt; The search system matches the keywords literally with the content available, aiming to find documents that contain those exact words or phrases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Context Analysis:&lt;/strong&gt; Keyword search does not deeply analyze the context or meaning of the keywords; it primarily focuses on matching the terms provided.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Limitations:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Overly Broad or Narrow Results:&lt;/strong&gt; Depending on the keywords used, the search results may be too broad, resulting in irrelevant matches, or too narrow, potentially missing relevant information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Limited Understanding of User Intent&lt;/strong&gt;: Keyword search often struggles to grasp the user’s underlying intent, as it relies solely on the terms input by the user without considering the context or semantics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Difficulty with Synonyms and Variations:&lt;/strong&gt; Keyword search may miss relevant content due to variations in language, synonyms, or different ways of expressing the same concept.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vulnerability to Manipulation:&lt;/strong&gt; The search results can be influenced or manipulated by strategic keyword usage, which can impact the relevancy and trustworthiness of the results.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Is Dense Vector Search ?
&lt;/h2&gt;

&lt;p&gt;Dense vector search, often referred to as vector search or semantic search, is a modern approach to information retrieval that involves representing textual data (such as documents, queries, or other pieces of text) as dense vectors in a high-dimensional vector space. In this approach, words or phrases are mapped to multi-dimensional vectors using techniques like Word2Vec, Doc2Vec, or embeddings from transformer-bas&lt;br&gt;
ed models (e.g., BERT, GPT, etc.).&lt;/p&gt;

&lt;h2&gt;
  
  
  Here’s how dense vector search typically works:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Vector Representation:&lt;/strong&gt; Textual data (e.g., sentences, documents, queries) is converted into dense vectors, where each dimension of the vector represents a different aspect of the semantic meaning of the text.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector Space:&lt;/strong&gt; The dense vectors are placed in a high-dimensional vector space, where similar vectors are close to each other in terms of cosine similarity. Similarity measures, such as cosine similarity, are used to calculate the similarity between vectors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Query Processing:&lt;/strong&gt; When a user submits a query, it is also converted into a dense vector using the same representation model. This vector is then used to search for similar vectors (representing documents) in the vector space.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ranking:&lt;/strong&gt; The system ranks the documents based on their similarity to the query vector, with more similar documents ranked higher.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Display of Results:&lt;/strong&gt; The search results are displayed to the user, typically in order of relevance based on the similarity scores.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Key characteristics of dense vector search include:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Semantic Understanding:&lt;/strong&gt; Dense vector search aims to capture the semantic understanding and meaning of the text, allowing for more accurate and contextually relevant search results.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contextual Analysis:&lt;/strong&gt; The approach considers the context and relationships between words, phrases, and documents, enabling a deeper understanding of the content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Less Reliance on Exact Keywords:&lt;/strong&gt; Unlike keyword search, which relies heavily on exact keyword matches, dense vector search can find relevant information even if the exact keywords are not present.
4.** Flexibility and Adaptability:** Dense vector search is more flexible in handling synonyms, variations, and related terms. It is also adaptable to different languages and domains.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduced Sensitivity to Noise:&lt;/strong&gt; The dense vector representation tends to be more robust against noise or irrelevant terms in the query, improving the overall search experience.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Limitations:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;High Dimensionality and Resource Intensiveness:&lt;/strong&gt;  Dense vector representations often reside in high-dimensional spaces, which can be computationally intensive and require substantial memory and processing power, especially when dealing with large datasets.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Training Data Dependency:&lt;/strong&gt; The quality and effectiveness of dense vectors heavily depend on the availability and quality of training data. If the training data is biased, insufficient, or not representative, it can lead to suboptimal vector representations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Semantic Drift:&lt;/strong&gt; The semantic meaning of words and phrases can change over time, and dense vectors may not always capture these changes accurately. The embeddings may become outdated and not reflect current semantic relationships.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Difficulty Capturing Ambiguity:&lt;/strong&gt; Dense vector representations struggle to capture polysemy (multiple meanings of a word) and homonymy (different words with the same form) effectively. A single vector representation may not accurately capture all possible meanings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Context Sensitivity:&lt;/strong&gt; Dense vector representations may not fully capture context, especially complex contextual understanding that involves understanding long-range dependencies or multiple layers of context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Out-of-Vocabulary Words:&lt;/strong&gt; Words not present in the training data may pose challenges as they lack pre-trained vector representations. Handling previously unseen words (out-of-vocabulary words) requires special techniques.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Difficulty with Domain-Specific Language:&lt;/strong&gt; Pre-trained models might not perform optimally in specialized domains or specific jargon-laden language where the vocabulary and usage are unique.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability Issues:&lt;/strong&gt; As the amount of data grows, maintaining and querying a high-dimensional vector space becomes computationally expensive, potentially affecting the scalability of the search system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lack of Explainability:&lt;/strong&gt; Dense vectors lack inherent interpretability, making it challenging to understand how the model arrived at a particular similarity score or ranking, which can be crucial for certain applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cold Start Problem:&lt;/strong&gt; Initializing the vector space for a new system or domain without pre-existing embeddings can be challenging, especially when there’s limited training data available.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Need for Regular Updating:&lt;/strong&gt; Continuous monitoring and updates to the dense vector models are necessary to ensure that the representations stay relevant and accurate over time.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Understanding these limitations is essential for effectively utilizing dense vector search and considering appropriate strategies to address these challenges in various applications and contexts.&lt;/p&gt;

&lt;p&gt;In summary, keyword search relies on exact keyword matches and is limited in semantic understanding, whereas dense vector search uses vector representations to capture semantic meaning and provide more contextually relevant search results. Dense vector search is flexible in handling synonyms and related terms, making it suitable for a wide range of applications, especially those that require a deeper understanding of user intent and content semantics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hybrid Search
&lt;/h2&gt;

&lt;p&gt;Hybrid vector search is a combination of traditional keyword search and modern dense vector search. It has emerged as a powerful tool for e-commerce companies looking to improve the search experience for their customers.&lt;/p&gt;

&lt;p&gt;By combining the strengths of traditional text-based search algorithms with the visual recognition capabilities of deep learning models, hybrid vector search allows users to search for products using a combination of text and images. This can be especially useful for product searches, where customers may not know the exact name or details of the item they are looking for.&lt;/p&gt;

&lt;p&gt;Here we will implement ecommerce chat with fashion products using hybrid search. The components include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Embedding Model: (Sparse + Dense)&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Qdrant :&lt;/strong&gt; for Storage and Retrieval&lt;br&gt;
&lt;strong&gt;LLM: gpt-3.5-turbo :&lt;/strong&gt; Generative Question Answering&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is SPLADE ?
&lt;/h2&gt;

&lt;p&gt;SPLADE leverages a transformer architecture to generate sparse representations of documents and queries, enabling efficient retrieval. Let’s dive into the process.&lt;/p&gt;

&lt;p&gt;The output logits from the transformer backbone are inputs upon which SPLADE builds. The transformer architecture can be something familiar like BERT. Rather than producing dense probability distributions, SPLADE utilizes these logits to construct sparse vectors — think of them as a distilled essence of tokens, where each dimension corresponds to a term from the vocabulary and its associated weight in the context of the given document or query.&lt;/p&gt;

&lt;p&gt;This sparsity is critical; it mirrors the probability distributions from a typical Masked Language Modeling task but is tuned for retrieval effectiveness, emphasizing terms that are both:&lt;/p&gt;

&lt;p&gt;Contextually relevant: Terms that represent a document well should be given more weight.&lt;br&gt;
Discriminative across documents: Terms that a document has, and other documents don’t, should be given more weight.&lt;br&gt;
The token-level distributions that you’d expect in a standard transformer model are now transformed into token-level importance scores in SPLADE. These scores reflect the significance of each term in the context of the document or query, guiding the model to allocate more weight to terms that are likely to be more meaningful for retrieval purposes.&lt;/p&gt;

&lt;p&gt;The resulting sparse vectors are not only memory-efficient but also tailored for precise matching in the high-dimensional space of a search engine like Qdrant.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interpreting SPLADE
&lt;/h2&gt;

&lt;p&gt;A downside of dense vectors is that they are not interpretable, making it difficult to understand why a document is relevant to a query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SPLADE&lt;/strong&gt; importance estimation can provide insights into the ‘why’ behind a document’s relevance to a query. By shedding light on which tokens contribute most to the retrieval score, SPLADE offers some degree of interpretability alongside performance, a rare feat in the realm of neural IR systems. For engineers working on search, this transparency is invaluable.&lt;/p&gt;

&lt;p&gt;Compared to other sparse methods, retrieval with SPLADE is slow. There are three primary reasons for this:&lt;br&gt;
The number of non-zero values in SPLADE query and document vectors is typically greater than in traditional sparse vectors, and sparse retrieval systems are not optimized for this&lt;br&gt;
The distribution of non-zero values deviates from the traditional distribution expected by the sparse retrieval systems, again causing slowdowns.&lt;br&gt;
SPLADE vectors are not natively supported by most sparse retrieval systems. Meaning we must perform multiple pre and post-processing steps, weight discretization, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key idea in SPLADE mechanism is as follows:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The term frequency component measures how often a query term appears within a document, giving more weight to rare terms.&lt;/li&gt;
&lt;li&gt;The inverse document frequency factor considers the overall frequency of a term in the entire collection, penalizing common terms.&lt;/li&gt;
&lt;li&gt;Document length normalization helps to adjust for variations in document length, ensuring fairness in scoring.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: Qdrant supports a separate index for Sparse Vectors. This enables us to use the same collection for both dense and sparse vectors. Each “Point” in Qdrant can have both dense and sparse vectors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hybrid Search Implementation in Qdrant
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SPLADE Implementation for Sparse Vector :&lt;/strong&gt;This is a new feature in Qdrant added in their latest release.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;_For document embedding : naver/efficient-splade-VI-BT-large-doc&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For query embedding : naver/efficient-splade-VI-BT-large-query_&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CLIP MODEL&lt;/strong&gt; for Dense Vector.&lt;/p&gt;

&lt;p&gt;For the complete code implementation please refer :&lt;a href="https://medium.com/@nayakpplaban/building-an-ecommerce-based-search-application-using-langchain-and-qdrants-latest-pure-a60df053066a"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
