Is it possible to do some tweaking with a KNN search?
For example I have documents with a title, description, country and a category.
I have created the embeddings with the E5 model for the title & description fields (title_embedding, description_embedding).
When I do a KNN search (query_vector_builder) on the two embedding fields I also filter on the country. This works fine.
But now I want to boost the documents for a specific category in the same KNN search query. Is this possible without doing the hybrid search query, just using KNN search?
Hi @Carlos_D, thanks for your reply. I already thought that we should use the hybrid query for this.
Our search solution now uses BM25 with some tweaking via boost and synonyms. This give a pretty good result.
Now we do a pilot with the E5 multilingual model and see that you more or less are dependend on the model. You almost can't tweak it, at least without going into hybrid search queries.
This makes it hard to choose for the KNN search with the E5 model I think at this moment. For simple search queries is fine.
One example. In our synonyms we have (sorry it's in Dutch):
wijzigen, aanpassen, veranderen, instellen
If someone wants to search for "wijzigen limiet", the search is also performed for the other synonyms intead of "wijzigen".
I thought that the E5 small model knows that "wijzigen" is almost the same as "aanpassen". But this wasn't the case in our test. Should we consider to try the E5 large model maybe?
To take into consideration, while you could use the large model, there will be differences in the performance as the small has been optimized to run in Elasticsearch (some additional details that you might find interesting in : elastic/multilingual-e5-small-optimized · Hugging Face)
@JdKock , that is the problem with an imported model - it is already tuned and there is not a straightforward way of tuning specific queries using just the model.
Using a hybrid search approach in which you combine lexical search with vector search using a ML model will give you additional signals that you can tune for exact keyword match, synonyms, etc. That can help obtaining better relevance than just using a ML model.
As @Serena_Chou said, you can use additional tools (like query rules) for additional fine-grained tuning.
Hi @Carlos_D, I'm no trying the hybrid search you suggested.
Is it possible with a hybrid search (BM25 with Vector search) to see from what search method (BM25 or Vector) the result is coming from? So can I do some analysis.
For example if the first 3 results are not that good but result number 4 is better and I know this one is coming from the BM25 search, maybe I need to boost the BM25 search query in the hybrid search a little bit more to fine tune it.
Is it possible with a hybrid search (BM25 with Vector search) to see from what search method (BM25 or Vector) the result is coming from? So can I do some analysis.
If you want to use linear combination by boosting each query differently, you will need to analyze the score as you're mentioning.
If you want to avoid tweaking the boost for each query, you could use Reciprocal Rank Fusion (RRF) as a way of combining hybrid searches. RRF allows combining results taking into account position and not scoring, as scores can be quite different from vector and BM25.
Otherwise, the best way of understanding score for a particular query would be:
Use explain=true query parameter, that will provide a detailed breakdown of the scoring including what score is coming from each, or
Perform separate queries for vector and BM25. That will get the individual score for each result for each query, which will then be combined according to the boosts assigned to each query
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.