How to add scores to Qdrant vectorstore retriever results when MMR is used?

Langchain has documentation on how to add scores to retriever results when similarity_search is used. How to add scores to retriever results | :parrot::link: LangChain

But I want to use MMR (Minimal Marginal Relevance), instead of similarity_search. Can someone please point out how I can do that? The retriever I am using is:

retriever = qdrant.as_retriever(search_type="mmr", search_kwargs={"k": 3, "score_threshold":0.4 })

hi @DLin1

MMR (Maximal Marginal Relevance) is a reranking algorithm that selects items iteratively to balance:

  • relevance to the query, and
  • non-redundancy with already selected items.

Formally, at each step it chooses:
argmax_i [ Ξ» * sim(query, doc_i) βˆ’ (1 βˆ’ Ξ») * max_j sim(doc_i, doc_j) ]
where λ ∈ [0,1] controls the tradeoff between relevance and diversity.

MMR does not produce calibrated or comparable β€œrelevance scores.” It outputs an ordered list of k items. Any intermediate value computed during selection is transient and not meaningful across queries. Implementations typically return the base similarity scores (e.g., cosine similarity) from the vector store.

Possible usage to get scores:

  1. Retrieve a larger candidate pool using base similarity scores.
  2. (Optionally) filter by a score threshold.
  3. Apply MMR to reorder and return the top-k items.
    If you need scores, attach the underlying similarity scores; MMR is designed for selection order, not for scoring.

Makes sense. Thanks, Pawel.

1 Like