From the course: LLM Foundations: Vector Databases for Caching and Retrieval Augmented Generation (RAG)

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Build an index

Build an index

We added data to the collection in the previous video, but before we can use it for semantic search, we need to create an index on the vector field. To create an index, we first need to set some parameters for the index. The metric type is used to indicate the distance measure that should be used to compare the vectors. This can be L2 or IP or cosine. Do note that the same metric type should be used when doing queries on this vector field. The index_type is set to IVF_FLAT. We discussed the options here in the previous chapter, and list indicates the number of clusters or buckets to create in this index. Higher values of this parameter can lead to better efficiency but lower search effectiveness. To create the index, we use the same collection object. We specify the field on which to create the index and the index parameters. We can check on the index creation process by using the index_building_process method as shown here. Let's run this code now. We can see that the index has been…

Contents