WRITE · TRACE · UNDERSTAND
Diversify retrieved evidence with maximal marginal relevance
Documents contain unique string id and finite vector matching a nonempty finite query vector.
Read lesson: Diversify retrieved evidence with maximal marginal relevance →
Your experiment
Documents contain unique string id and finite vector matching a nonempty finite query vector. Require integer k>=0 and relevance_weight in [0,1]. Greedily maximize weight*cos(query,document)-(1-weight)*maximum cosine to an already selected document, using zero redundancy for the first choice. A zero vector has cosine zero. Break score ties by smaller id. Return selected IDs, never repeating a document.
Python runs in your browser. Your draft stays on this device.
What to look for
Review the embedding metric, relevance weight, duplicate policy and tie behavior. Permission filtering must happen before these candidates reach the reranker.
Watch your code work
Ready to experimentWrite a solution or load the worked answer, then choose Trace & check.
Step through arrays, variables and training curves produced by your own Python.
