From the course: Vector Databases in Practice: Deep Dive

Vector searches

From the course: Vector Databases in Practice: Deep Dive

Vector searches

- Let's take a look at vector searches. As we talked about before, vector searches are all about similarity between meaning as represented by vectors. Recall that we talked about analogies to colors with similar RGB values. Vector databases allow us to capture meaning as vectors, which are just a series of numbers, and then perform fast, accurate searches based on how close they are in meaning to each other. This probably still seems a little bit abstract, so let's turn that into something more concrete by exploring examples of vector search. This query here will search our vector database for objects most similar in meaning to this search string. For example, if we run this query and look at the results, at a first glance, they all look relevant to query and probably quite similar to what we saw before with keyword search. But something interesting is happening here. Let's do another vector search this time for the word amorous. You'll see that we can do that with the same code as before, just with a different search string. And interestingly, when we look at the results, they are very similar. Even though the word amorous doesn't appear in any of the results. How did that happen? Well, the answer is vectors. Because vectors represent meaning, the vector database was able to follow the intent of the query regardless of the actual word that was used. In fact, these models that produce vectors can do a lot more than understand individual words. When we perform vector searches for queries like adventure movies set in outer galaxy and look at the results. These search results are very much relevant to our query. The title and the description of the top results match our search query criteria almost perfectly. Even though, as before, the exact words don't really appear anywhere. It's pretty amazing, right? And that's just a small flavor of what you can do with vector search. Some vectorizing models can even vectorize across multiple languages. So you could search Japanese text with a French query or vice versa. Others can work with data in multiple modalities. For example, with images and text. In those cases, a search using images might be able to fetch text that best matches its description and again, vice versa. The key idea, again, is that vector searches allows to search these objects by their key concepts or meanings. You can try out vector searches yourself using the included code example. Try varying the search term here and note how the results change. You can try using individual words or longer queries, like sentences or even paragraphs. I think trying these out will improve your feel for how vector search works.

Contents