Maximal Marginal Relevance retrieval #4396
Replies: 1 comment
-
|
I ran into something similar when I was working on a project where I needed to retrieve context-relevant information efficiently. I was exploring the capabilities of mem0 as well and needed to ensure diverse results without too much repetition. In my case, I didn't find a built-in MMR feature directly within mem0, but I managed to implement it myself. What I did was use the existing reranker option to initially rank my potential memory contexts. Then, to achieve MMR, I manually adjusted the selection by iterating over the ranked results. I computed the similarity of each subsequent memory with the ones already selected and tweaked the choice based on a trade-off between relevance and diversity. This approach let me leverage the reranker to get a strong initial ordering and then apply MMR logic on top for diversity. It worked well for my needs. If you haven’t already, you might want to check if newer versions have additional support for this or if the community has shared any extensions. That's how I got it done! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am building an agent where I want to retrieve relevant memories to context when receiving a new user question. I see there is a search capability to find the most relevant memories. However, I want to make sure that there is minimal duplication in the returned contexts. I saw this technique called Maximal Marginal Relevance (MMR) e.g. https://www.elastic.co/search-labs/blog/maximum-marginal-relevance-diversify-results that is sort of like doing a minimal set cover for context. Is there already an implementation of this in mem0? I saw there is a reranker option but I wasn't sure how that plays into it.
Beta Was this translation helpful? Give feedback.
All reactions