Skip to content

Similar Item Recommendations

Search and recommendations are very tightly coupled, especially for vector search. This means that Marqo is also a powerful recommendations tool. In this recipe we will show you how to use Marqo to generate similar item recommendations.

How Similar Item Recommendations work in Marqo

Similar item recommendations are effectively a "reverse document search". Instead of searching with a query, the goal is to search using a document that is already in the index.

Marqo comes with an endpoint for recommendations that allows you to generate similar item recommendations based on a selection of one or more existing documents. Documents used as the query can be represented as a list of document IDs or as a dictionary with the document ID as the key and a weight as the value. There are two included methods for combining the vectors of the documents: slerp and lerp.

  • slerp is a spherical linear interpolation between the vectors of the documents.
  • lerp is a linear interpolation between the vectors of the documents.

Marqo will select this automatically based off the index settings, if you are using normalized embeddings then slerp will be used, otherwise lerp will be used.

Recipe for Similar Item Recommendations

import marqo

recommendations = mq.index("my-first-index").recommend(
    documents=["doc1", "doc5"], limit=10, interpolation_method="slerp"
)