HNSW for Vector Search Explained and Implemented with Faiss (Python)

Поделиться
HTML-код
  • Опубликовано: 4 янв 2025

Комментарии • 45

  • @jamesbriggs
    @jamesbriggs  3 года назад +21

    *Correction to the skip-list logic, if we hit the end block or overshoot the target, we move down a layer to the previous value directly (not the start), they'll be an updated visual in the article **www.pinecone.io/learn/hnsw/** as soon as possible*

  • @f.b.1311
    @f.b.1311 9 месяцев назад +2

    Men, I have been sleeping on this channel, your stuff is awesome!

  • @banbiossa
    @banbiossa 2 года назад +4

    Tried to read the paper, was super perplexed, this was awesome!!!

  • @parthshah7371
    @parthshah7371 3 года назад +5

    I was trying to read and understand the paper as I have to use HNSW KNN in one of my project. Demystifying topics through videos help me understand the paper more easily. Thanks for this video!

  • @banxt
    @banxt Месяц назад

    21:19 Why in the lowest level there aren't 1.000.000 values since the dataset is 1 million? What happened to the rest?

  • @kristoferkrus
    @kristoferkrus 2 года назад +8

    Good video overall, but at 3:07 you don't go to the start block again (that would yield O(N) average search time complexity). You instead go down the last column that wasn't higher than the search key (which in this case is the 5 column), and this gives you O(log(N)) average search time complexity.

    • @rabomeister
      @rabomeister Год назад

      lol, came here for the exact comment , stopped the video at 3.09

  • @gerardorosiles8918
    @gerardorosiles8918 Год назад +1

    Looking at the C++ code in the video, the defaults are set to efSearch=16 and efConstruction=40 which is in line with what is shown in the graphs. M between 32 and 50 seems to be the sweet spot to maximize recall, minimize search time and have a memory usage below 1GB. Maybe efSearch can be pushed to 50-60 to increase recall with a small hit on search time. Thanks for the great video.

  • @EvgeniyDolzhenko
    @EvgeniyDolzhenko Месяц назад

    So it's basically skip list but in vector space?

  • @xuantungnguyen9719
    @xuantungnguyen9719 9 месяцев назад

    Sir, I have a question. Why nodes in the top layer has higher degree? "During the search, we enter the top layer, where we find the longest links. These vertices will tend to be higher-degree vertices (with links separated across multiple layers), meaning that we, by default, start in the zoom-in phase described for NSW." I found this in the doc, don't understand why

  • @vanguard5021
    @vanguard5021 Год назад

    Is it possible to identify which combination of elements caused the outlier? I am using the HNSW algorithm on Github.

  • @lewis_chan
    @lewis_chan 6 месяцев назад

    “if you need it to be faster,, you can use an ivf index on top of HNSW to improve search time”, I don't understand this statement. Any article that can refer to ?

  • @davidtindell950
    @davidtindell950 5 месяцев назад +1

    thank you yet again !!!!

  • @deepaksaini4158
    @deepaksaini4158 9 месяцев назад

    is it not the case that when we move from layer 3 to layer 2, we do not need to go to the very beginning, it goes to the node 5 in layer 2. and from node 19, when it jumps to layer 1, it should go to node 11 instead of again going back to the start node. otherwise, it search efficiency again goes back the O(n)

  • @vanguard5021
    @vanguard5021 Год назад

    I would like to draw contour lines based on the degree of anomaly when representing the plot on a two-dimensional graph. If there is a method, please instruct me.

  • @meirgoldenberg5638
    @meirgoldenberg5638 Год назад

    If I understood correctly, the size of the graph does not depend on the number of dimensions, i.e. 128-dimensional vectors would result in the same space cost as 1024-dimensional vectors. For reasonable M, this space should probably be smaller than the space used by the vectors themselves. However, I saw threads (unfortunately, I didn't keep the links) where they complain that using HNSW results in using several times more space than the space used by the original vectors and hence requires a lot of RAM and disk space. How could that be explained?

  • @yinghaohu8784
    @yinghaohu8784 5 месяцев назад

    Um, how to build the index. Is there any explanation step by step ?

  • @鹏程李-w8z
    @鹏程李-w8z 3 года назад +2

    what is the python editor you use

    • @jamesbriggs
      @jamesbriggs  3 года назад

      VS Code with Python and Jupyter plugins + the Night Owl theme :)

    • @鹏程李-w8z
      @鹏程李-w8z 3 года назад

      @@jamesbriggs thanks !

  • @julian3154
    @julian3154 8 месяцев назад

    Great Video. Thank you.

  • @atomscott425
    @atomscott425 2 года назад

    Can this method be used for searching non-vector data in a non-metric space? I'm thinking of variable length timeseries with dynamic time warping as a distance measure.

    • @jamesbriggs
      @jamesbriggs  2 года назад

      I don't believe so, but could be wrong

    • @atomscott425
      @atomscott425 2 года назад

      @@jamesbriggs Thanks for your reply. Btw are you aware of any other search method that can be used in this scenario?

  • @Data_scientist_t3rmi
    @Data_scientist_t3rmi 2 года назад

    Hello, what is faiss to pinecone? is pinecone a cloud indexing method that can be based on faiss?

    • @jamesbriggs
      @jamesbriggs  2 года назад +2

      Hi Faiss is like a vector index without data management, infrastructure, optimisation etc - Pinecone is a vector index with data management, managed infrastructure, custom (and very good) search algorithms, metadata filtering, etc :)

    • @Data_scientist_t3rmi
      @Data_scientist_t3rmi 2 года назад

      @@jamesbriggs Thank you James

  • @Data_scientist_t3rmi
    @Data_scientist_t3rmi 2 года назад

    I have a question, if i have BM25 + Cross Encoder architecture for information retrieval, how can i do my indexing ?

    • @jamesbriggs
      @jamesbriggs  2 года назад +1

      With BM25 you are doing sparse search and so would not use faiss, if you wanted to use faiss you need to do dense search and that requires sentence transformer models

    • @Data_scientist_t3rmi
      @Data_scientist_t3rmi 2 года назад

      @@jamesbriggs Thank you for your answer, do you have any video where you explain how to do hybrid indexing? using BM25 for ranking, index BM25 then using Cross Encoder for the result?

    • @jamesbriggs
      @jamesbriggs  2 года назад +1

      ​@@Data_scientist_t3rmi this wouldn't be hybrid indexing, it would be sparse search followed by reranking -- hybrid inxexing would require something like sentence transformer with Faiss and BM25 as two separate indexes, then you could rerank the results based on some "merge" of the results at the end
      My most recent video talks about hybrid search in Pinecone:
      ruclips.net/video/0cKtkaR883c/видео.html
      Other than this I don't have anything else but I will focus on hybrid methods and reranking over the next few weeks, so hopefully that will help :)

    • @Data_scientist_t3rmi
      @Data_scientist_t3rmi 2 года назад

      @@jamesbriggs thank you

    • @Data_scientist_t3rmi
      @Data_scientist_t3rmi 2 года назад

      @@jamesbriggs I have one more question, if i have 8 books for example and i want to conduct research, how can i do it ? do you have article or key words to search that type of search ? i konw when we have one text file or 8 text file we simply concatinate these files then transform them into embedding matrix then conduct a neural search, however, when we have 5000 documents, i do not think so that it would be the same. for now i built a dictionary per document, in wich you can find , document name, page number,, text and embedding, but i found it quit difficult to conduct my search on lists of dictionary rather then on simple text. the idea is when we find the document id, we can say that this id belongs to that odcument wich is belong to that book.

  • @vaibhav_haibatrao_patil
    @vaibhav_haibatrao_patil Год назад

    Excellent thanks !

  • @murphp151
    @murphp151 2 года назад

    this is brilliant!

  • @vanguard5021
    @vanguard5021 Год назад

    Please teach me omost simplest knn c# code with HNSW if you like.

  • @wilfredomartel7781
    @wilfredomartel7781 3 года назад

    Any idea of how to add ids to the vector for a posterior integration with database? Excellent explanation!

    • @jamesbriggs
      @jamesbriggs  3 года назад +2

      You can use ‘add_with_ids’ rather than ‘add’ when adding vectors to the index, and you pass both ids and vectors, although it is a lot of effort to get it working when you’re adding, deleting, overwriting etc - so be prepared 😅

    • @wilfredomartel7781
      @wilfredomartel7781 3 года назад

      @@jamesbriggs so what do you propose ?

    • @jamesbriggs
      @jamesbriggs  3 года назад +2

      @@wilfredomartel7781 if you're using Faiss you need to build a framework around it to handle addition/deletion/overwrites, definitely use add_with_ids rather than add because that will be useful later on when needing to overwrite vectors, however add_with_ids doesn't allow any alphanumeric combo for IDs, I don't remember what it requires but in the past I resorted to something like '0', '1', '2', etc and then mapping this 'Faiss IDs' to the IDs in a database with an external mapping file.
      If you want to get something good up and running quick, use Pinecone www.pinecone.io - it's also free up to 1M vectors

    • @wilfredomartel7781
      @wilfredomartel7781 3 года назад

      @@jamesbriggs thank you so much for your tipos , i really appreciate them.

    • @SolidBuildersInc
      @SolidBuildersInc Год назад

      Thanks for the presentation. Totally new subject for me. Can you direct me to the docs? Also, "You can use 'add with ids' rather
      than 'add ' when adding vectors to
      the index, and you pass both ids and
      vectors, although it is a lot of effort
      to get it working when you're adding,
      deleting, overwriting etc - so be
      prepared " If you have a Self fulfilling ID that would land on a default layer for all vectors and then be archived within it's own file like ID.sqlite you could then recall the data in a decentralized way and with 0 latency. These are my thoughts. Appriciate your feedback.

  • @pratik6447
    @pratik6447 5 месяцев назад

    Requires lot of improvement on how topic is covered. Skip list and HNSW is better explained by showing running examples.

  • @StevenAkinyemi
    @StevenAkinyemi 5 месяцев назад

    Reminds me of a skip ratchet