<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Asna Shafiq on Medium]]></title>
        <description><![CDATA[Stories by Asna Shafiq on Medium]]></description>
        <link>https://medium.com/@asna.shafiq?source=rss-d076c34b0cc0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*M5vq9QHiA_y9Xuyx5BSiLQ.jpeg</url>
            <title>Stories by Asna Shafiq on Medium</title>
            <link>https://medium.com/@asna.shafiq?source=rss-d076c34b0cc0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 09:57:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@asna.shafiq/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Use FAISS to Build Your First Similarity Search]]></title>
            <link>https://medium.com/loopio-tech/how-to-use-faiss-to-build-your-first-similarity-search-bf0f708aa772?source=rss-d076c34b0cc0------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf0f708aa772</guid>
            <category><![CDATA[similarity-search]]></category>
            <category><![CDATA[search-algorithm]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[faiss]]></category>
            <dc:creator><![CDATA[Asna Shafiq]]></dc:creator>
            <pubDate>Wed, 14 Sep 2022 16:43:26 GMT</pubDate>
            <atom:updated>2022-09-16T14:56:53.485Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UdMNi5G7zlG7wKfx" /><figcaption>Photo by <a href="https://unsplash.com/ja/@impatrickt?utm_source=medium&amp;utm_medium=referral">Patrick Tomasso</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>At Loopio, we use Facebook AI Similarity Search (FAISS) to efficiently search for similar text. Finding items that are similar is commonplace in many applications. Perhaps you want to find products in your store that match the description input by a customer. Or perhaps you want to find related questions within your ‘Frequently Asked Questions’ (FAQ) section to show customers. We therefore thought it would be helpful to show you how to set up your first working prototype for similarity search. Before we get into the implementation, let’s look at some definitions.</p><h4>Word embedding or vector</h4><p>A vector or an embedding is a numerical representation of text data. For example, using an embedding framework, text like <strong>‘name’</strong> can be transformed into a numerical representation like:</p><pre>[-1.12725616e-01 -5.19371144e-02 -6.94938377e-02 2.93748770e-02</pre><pre>-7.56825879e-02 8.83060396e-02 -5.42510450e-02 -1.52141722e-02]</pre><p>As humans, we understand the contextual meaning of words like <strong>‘name’</strong>, but we need a way to represent this meaning to a Machine Learning (ML) model. A vector representation is just that — language the ML model can understand.</p><h4>Euclidean distance (L2)</h4><p>The distance between two points in Euclidean space is called the Euclidean distance. For example, a point in three-dimensional Euclidean space can be located by three coordinates. And the Euclidean distance would account for the distance between all three coordinates.</p><p>Tying into the example vector above, which has a dimension of eight, the Euclidean space is also eight-dimensional. If we were finding the distance between two vectors in this space, then using the Euclidean distance formula below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SnTXp9F-vziX2GeuWtVkNw.png" /></figure><p>We will find the distance between each of the <em>eight</em> coordinates of the two vectors, square each coordinate distance, sum all eight squares together and take the square root of the summation.</p><p>If words like <strong>‘name’</strong> and <strong>‘cat’</strong> were being compared for similarity, a Euclidean distance can be used to determine their <em>closeness</em>. The smaller the distance, the closer in meaning they are. This is just one example of how similarity distance can be calculated. There are other means, such as cosine distance and FAISS even lets you set a custom distance calculator.</p><h4>Normalization</h4><p>Normalization is the process of transforming numerical data so that it uses a common scale. For example, Euclidean distance (L2) normalization scales all vectors to a unit vector, meaning the sum of all elements in that vector equals to 1. This means that the magnitude of the vector caps at 1.0 and the direction is maintained post-normalization.</p><h3>Building your first prototype</h3><p><strong>Problem statement</strong>: Identify which category a new text can belong to by calculating how <strong>similar</strong> it is to all existing texts within that category.</p><p>We are going to build a prototype in python, and any libraries that need to be installed are mentioned in step 0.</p><h4>Step 0: Setup</h4><p>In a terminal, install FAISS and sentence transformers libraries.</p><pre>pip install faiss-cpu</pre><pre>pip install sentence-transformers</pre><h4>Step 1: Create a dataframe with the existing text and categories</h4><p>Here we have a few sentences categorized into 3 unique labels: location, random, and networking.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D824%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%252520pandas%252520as%252520pd%25250Adata%252520%25253D%252520%25255B%25255B%2527Where%252520are%252520your%252520headquarters%252520located%25253F%2527%25252C%252520%2527location%2527%25255D%25252C%25250A%25255B%2527Throw%252520my%252520cellphone%252520in%252520the%252520water%2527%25252C%252520%2527random%2527%25255D%25252C%25250A%25255B%2527Network%252520Access%252520Control%25253F%2527%25252C%252520%2527networking%2527%25255D%25252C%25250A%25255B%2527Address%2527%25252C%252520%2527location%2527%25255D%25255D%25250Adf%252520%25253D%252520pd.DataFrame%2528data%25252C%252520columns%252520%25253D%252520%25255B%2527text%2527%25252C%252520%2527category%2527%25255D%2529&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D824%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%25252520pandas%25252520as%25252520pd%2525250Adata%25252520%2525253D%25252520%2525255B%2525255B%252527Where%25252520are%25252520your%25252520headquarters%25252520located%2525253F%252527%2525252C%25252520%252527location%252527%2525255D%2525252C%2525250A%2525255B%252527Throw%25252520my%25252520cellphone%25252520in%25252520the%25252520water%252527%2525252C%25252520%252527random%252527%2525255D%2525252C%2525250A%2525255B%252527Network%25252520Access%25252520Control%2525253F%252527%2525252C%25252520%252527networking%252527%2525255D%2525252C%2525250A%2525255B%252527Address%252527%2525252C%25252520%252527location%252527%2525255D%2525255D%2525250Adf%25252520%2525253D%25252520pd.DataFrame%252528data%2525252C%25252520columns%25252520%2525253D%25252520%2525255B%252527text%252527%2525252C%25252520%252527category%252527%2525255D%252529&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/86e88a9e1c6f8f7400eeb9f8f3ebc6b1/href">https://medium.com/media/86e88a9e1c6f8f7400eeb9f8f3ebc6b1/href</a></iframe><p>Your dataframe should have this content:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nm_S2iuT-c9dPO2hN74twQ.png" /></figure><h4>Step 2: Create vectors from the text</h4><p>Using the text column of the dataframe, word embeddings or vectors are generated for each row using the <a href="https://www.sbert.net/#">Sentence Transformers</a> framework. This is just one of the libraries available for transformation among others like <em>doc2vec</em>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D824%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dfrom%252520sentence_transformers%252520import%252520SentenceTransformer%25250Atext%252520%25253D%252520df%25255B%2527text%2527%25255D%25250Aencoder%252520%25253D%252520SentenceTransformer%2528%252522paraphrase-mpnet-base-v2%252522%2529%25250Avectors%252520%25253D%252520encoder.encode%2528text%2529&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D824%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dfrom%25252520sentence_transformers%25252520import%25252520SentenceTransformer%2525250Atext%25252520%2525253D%25252520df%2525255B%252527text%252527%2525255D%2525250Aencoder%25252520%2525253D%25252520SentenceTransformer%252528%25252522paraphrase-mpnet-base-v2%25252522%252529%2525250Avectors%25252520%2525253D%25252520encoder.encode%252528text%252529&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/af8265e6b120c7a3717e1e527452712f/href">https://medium.com/media/af8265e6b120c7a3717e1e527452712f/href</a></iframe><h4>Step 3: Build a FAISS index from the vectors</h4><p>Using the dimension of the vector (768 in this case), an L2 distance index is created, and L2 normalized vectors are added to that index. In FAISS, an index is an object that makes similarity searching efficient.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D1500%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D57px%26ph%3D53px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%252520faiss%25250A%25250Avector_dimension%252520%25253D%252520vectors.shape%25255B1%25255D%25250Aindex%252520%25253D%252520faiss.IndexFlatL2%2528vector_dimension%2529%25250Afaiss.normalize_L2%2528vectors%2529%25250Aindex.add%2528vectors%2529&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D1500%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D57px%26ph%3D53px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%25252520faiss%2525250A%2525250Avector_dimension%25252520%2525253D%25252520vectors.shape%2525255B1%2525255D%2525250Aindex%25252520%2525253D%25252520faiss.IndexFlatL2%252528vector_dimension%252529%2525250Afaiss.normalize_L2%252528vectors%252529%2525250Aindex.add%252528vectors%252529&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3437c7a6a06b6574676cfafabb6bb63d/href">https://medium.com/media/3437c7a6a06b6574676cfafabb6bb63d/href</a></iframe><h4>Step 4: Create a search vector</h4><p>Let’s say we now want to search for the sentence that is most similar to our search text <strong>‘where is your office?’</strong>. Using the same method of vectorization from step 2, a search text is transformed. Then the vector is also normalized because all the vectors within the search index are normalized.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D1500%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D57px%26ph%3D53px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%252520numpy%252520as%252520np%25250A%25250Asearch_text%252520%25253D%252520%2527where%252520is%252520your%252520office%25253F%2527%25250Asearch_vector%252520%25253D%252520encoder.encode%2528search_text%2529%25250A_vector%252520%25253D%252520np.array%2528%25255Bsearch_vector%25255D%2529%25250Afaiss.normalize_L2%2528_vector%2529&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D1500%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dfalse%26pv%3D57px%26ph%3D53px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dimport%25252520numpy%25252520as%25252520np%2525250A%2525250Asearch_text%25252520%2525253D%25252520%252527where%25252520is%25252520your%25252520office%2525253F%252527%2525250Asearch_vector%25252520%2525253D%25252520encoder.encode%252528search_text%252529%2525250A_vector%25252520%2525253D%25252520np.array%252528%2525255Bsearch_vector%2525255D%252529%2525250Afaiss.normalize_L2%252528_vector%252529&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6f2ba28d7e37ced18bf08aa05e4e3b4/href">https://medium.com/media/e6f2ba28d7e37ced18bf08aa05e4e3b4/href</a></iframe><h4>Step 5: Search</h4><p>In this case, we want to search for <em>all</em> nearest neighbours, so <strong>k</strong> is set to the total number of vectors within the index.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dk%252520%25253D%252520index.ntotal%25250Adistances%25252C%252520ann%252520%25253D%252520index.search%2528_vector%25252C%252520k%25253Dk%2529&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dk%25252520%2525253D%25252520index.ntotal%2525250Adistances%2525252C%25252520ann%25252520%2525253D%25252520index.search%252528_vector%2525252C%25252520k%2525253Dk%252529&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5275f37775da2aabe8fa6fadf028a08/href">https://medium.com/media/f5275f37775da2aabe8fa6fadf028a08/href</a></iframe><h4>Step 6: Sort search results</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dresults%252520%25253D%252520pd.DataFrame%2528%25257B%2527distances%2527%25253A%252520distances%25255B0%25255D%25252C%252520%2527ann%2527%25253A%252520ann%25255B0%25255D%25257D%2529&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dresults%25252520%2525253D%25252520pd.DataFrame%252528%2525257B%252527distances%252527%2525253A%25252520distances%2525255B0%2525255D%2525252C%25252520%252527ann%252527%2525253A%25252520ann%2525255B0%2525255D%2525257D%252529&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/08ba2643349040472b252b78478c224a/href">https://medium.com/media/08ba2643349040472b252b78478c224a/href</a></iframe><p>In this dataframe, you can see that the distances are sorted in an ascending order. The <em>ann</em> is the <strong>a</strong>pproximate <strong>n</strong>earest <strong>n</strong>eighbour corresponding to that distance, meaning that <em>ann</em> 0 is the vector at position 0 in the index. Similarly, <em>ann</em> 3 is the vector at position 3 in the index — based on the order of text vectors from step 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*Ab69BFxXgTIU-8VtBawcNw.png" /></figure><h4>Step 7: Get category for the search text</h4><p>Similar vectors are defined as those that are nearby in Euclidean space. If we were to pair the distances and <em>ann</em> dataframe with the dataframe in step 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*bhnfOst4vNMX_HMTZLSNYw.png" /></figure><p>Here is what we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bi5Mjj0AQtkaKJj4" /></figure><p>We can see that text “<strong>Where are your headquarters located?</strong>” has the shortest distance of 0.5848729 from our search text “<strong>Where is your office?</strong>”.</p><p>We can thus retrieve the category as the category at the position with the lowest distance:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dlabels%252520%252520%25253D%252520df%25255B%2527category%2527%25255D%25250Acategory%252520%25253D%252520labels%25255Bann%25255B0%25255D%25255B0%25255D%25255D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dauto%26width%3D680%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dlabels%25252520%25252520%2525253D%25252520df%2525255B%252527category%252527%2525255D%2525250Acategory%25252520%2525253D%25252520labels%2525255Bann%2525255B0%2525255D%2525255B0%2525255D%2525255D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2724dae2f44c09d2519faf1a3c59907b/href">https://medium.com/media/2724dae2f44c09d2519faf1a3c59907b/href</a></iframe><p>This will give us the category of location for our search text “<strong>Where is your office?</strong>”.</p><h3>Sequence Diagram</h3><p>The steps above are summarized in this diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ouf0eyQskPeGWIGm" /></figure><h3>Conclusion</h3><p>The <a href="https://mlops.community/vector-similarity-search-from-basics-to-production/">MLOps community</a> talks about brute-force similarity search. This is good for starters but would not scale to a Production environment. This is one where you could be making comparisons between hundreds, millions, or billions of texts. FAISS can definitely facilitate that. There are also performance improvements that can further be made based on your use case and needs, so check out FAISS’ <a href="https://github.com/facebookresearch/faiss/wiki/Faster-search">github wiki</a>. You can also get a deep understanding of <a href="https://engineering.fb.com/2017/03/29/data-infrastructure/faiss-a-library-for-efficient-similarity-search/">How FAISS works under the hood</a>.</p><p>Best of all, if you’re interested in working on this and other meaty problems, check out the <a href="https://bit.ly/3vA3IXg">career opportunities</a> available across Loopio’s Engineering, Product, and Design teams.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf0f708aa772" width="1" height="1" alt=""><hr><p><a href="https://medium.com/loopio-tech/how-to-use-faiss-to-build-your-first-similarity-search-bf0f708aa772">How to Use FAISS to Build Your First Similarity Search</a> was originally published in <a href="https://medium.com/loopio-tech">Loopio Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>