Overview
Graft provides the option to rerank search results to improve search relevancy. Reranking and using 'relevant results' can be helpful where either the search results are not great or where the answer you require is not a direct semantic or keyword search. For example searches which are in the form of questions "What products are good for the summer" which could be applied to our demo set would provide results which are semantically similar to the question, but would not give us what we really need which is a list of products are best for summer usage.
Rerank is only available for Text Search in English at this time
Enabling reranking to your search query takes the initial search results and passes them to a reranking model which computes a relevance score between the search result item and the search query and then returns those results in rank order. This type of search takes a little longer to return an answer and is configurable through the UI and API.
Enabling Reranking in the UI
By default Graft presents search results with a similarity score and a rank. The similarity score can be helpful to determine at what point to cut off results which you might use in your own application. i.e. similarity scores lower than .65 may be too wide of the mark for your needs. The rank makes it easier to see which is the best fit rather than having to compare the similarity score to 5 decimal places.
Here is a view of the ADHOC search capabilities within the Search try it tab
With this simple query and no reranking we get results as follows (a number of columns have been removed for clarity (indicated by the Red 3 icon by the column filter )...
Enable rerank by clicking on the Rerank slider at the end of the search bar
Clicking Search will generate results ranked by Relevance.
With Rerank enabled the Similarity column is displaying the results Relevance Score
Enabling Reranking for API calls
Enable Reranking by setting the rerank flag within the API request
"rerank": true
This can also be set in the API tab of the Search app found on the lower right hands side of the screen
Either option will modify the current API request as shown in this example.
curl https://sourdough.graft.com/v1/query -H 'Content-Type: application/json' -X POST -d '{
"secret": " ... ENTER YOUR FULL API KEY HERE",
"organization": "docs",
"project": "d75vy",
"output_format": "csv",
"app": "0",
"entity": "desc_search",
"entity_columns": [
"product_id",
"product_category",
"product_subcategory",
"product_title",
"product_description",
"price",
"season",
"image_uri"
],
"embedding_name": "my_config_embedding",
"entity_knn_adhoc": [
{
"product_description": "query text"
}
],
"entity_knn_k": 10,
"rerank": true
}'