Guides
Multi-vector search
In some cases, a single vector search may not be sufficient to retrieve the most relevant results.
In TopK, you can run multiple vector searches in a single query. Additionally, you can apply a different ranking score to each individual vector search result.
For example, in a research paper database, you might want to:
- Retrieve documents based on both the summary of the entire paper and summaries of individual paragraphs.
- Rank results by combining scores from multiple embeddings such as:
- 70% weight for entire paper similarity
- 30% weight for paragraph summary similarity
Let’s define a collection with two semantic indexes:
After, we run a multi-vector search by using the fn.semantic_similarity()
function for calculating semantic similarity on the paper_score
field as well as the paragraph_score
field:
Let’s break down the example above:
- Calculate semantic similarity between the query and the full paper summary as well as the paragraph summary.
- Blend the two scores by giving 70% weight to the full paper and 30% weight to the paragraph summary.
- Retrieve the top 10 results ranked by the blended score.