Recommendation diversity: a less repetitive list can still miss the point
推荐多样性与覆盖率
Run MMR, distinguish pair sums from averages and inspect relevance loss, category coverage and candidate limits.
recommendation-diversityThree excellent recommendations can repeat one idea
A list offers three nearly identical space articles. Each looks relevant in isolation, yet the second and third add little variety. Replacing one with a music article may broaden the list; replacing it with unrelated cooking content may simply miss the reader’s interests. “Different” and “useful” are separate judgments.
Recommendation diversity concerns differences among the selected items under a stated representation. Coverage asks how much of a specified universe is reached. Novelty concerns what the user has not encountered or would not ordinarily see; serendipity also requires unexpected usefulness. A single pairwise distance cannot certify all four. Ziegler and colleagues discuss beyond-accuracy evaluation and an intra-list similarity measure. PDF 3
We use maximal marginal relevance (MMR), developed for retrieval and summarization, as an explicit recommendation reranker. It trades a relevance score against similarity to what has already been selected. This transfer is our teaching application, not a claim that the original MMR paper evaluated this six-item recommender. TIPSTER method page, PDF 2
Choose a representation before choosing a tradeoff
Let each candidate have a nonzero feature vector x_i. Our redundancy measure is cosine:
The example uses nonnegative topic features, giving similarities between zero and one. General cosine can be negative. Similarity of topic labels is not identical to duplicate text, author diversity or viewpoint diversity; choose features that match the question being evaluated.
Let r_i be a fixed relevance score, C the eligible candidate set and S the items already selected. MMR repeatedly selects:
The maximum is the worst redundancy with a selected item, not the average redundancy. Relevance and redundancy can use different functions. The displayed weighting follows Goldstein and Carbonell’s TIPSTER formulation. PDF 2 Our empty-list convention sets redundancy to zero; ties prefer higher relevance, then smaller ID. Consequently even lambda=0 starts with the most relevant item.
Lambda=1 returns relevance order. Smaller values give redundancy more weight, on the numerical scales supplied. Rescaling relevance without rescaling similarity changes the tradeoff. Greedy MMR is a sequence of local decisions, not a general guarantee of the globally best subset or monotonically improving utility.
For a list L of length k and symmetric similarity, the original Ziegler intra-list similarity is a sum over unordered pairs:
The factor one half removes double counting. It does not normalize by the number of pairs. PDF 3, equation 5 For comparing different list lengths, this article additionally reports a pair average and its dissimilarity complement:
These averaged quantities are our explicitly declared normalization. For k below 2, they are undefined. Reordering a fixed set does not change either pair metric; the original paper emphasizes this permutation invariance. A position-sensitive utility metric can nevertheless change when the order changes.
Coverage also needs a denominator. In our single-category-per-item example, and for a collection of recommendation lists respectively, two possible definitions are:
Our program reports the first, against all four categories in its fixed catalog. It does not report the second or Ziegler’s separate discussion of coverage as the ability to make predictions. These denominators answer different questions and must not share an unlabeled percentage.
To keep the loss of relevance visible, report the selected scores’ mean alongside diversity:
A relevance score is still a model input, not measured satisfaction. The metric says which supplied scores the reranker retained.
A more diverse list can admit a weaker item
Use Python 3.12 and NumPy 1.26.4. The original fixture has six candidates with relevance scores [0.95,0.94,0.92,0.85,0.8,0.35]. The first three are near-duplicate space vectors; the others represent music, gardening and cooking. These are authored features and scores, not reader-study labels.
"""Original MMR reranking with explicit relevance, pair averages and candidate limits."""
import json
import numpy as np
def similarities(features):
x=np.asarray(features,float)
if x.ndim!=2 or min(x.shape)==0 or not np.isfinite(x).all():raise ValueError('finite nonempty item-feature matrix required')
lengths=np.linalg.norm(x,axis=1,keepdims=True)
if (lengths==0).any():raise ValueError('nonzero item vectors required for cosine')
x=x/lengths;return np.clip(x@x.T,-1,1)
def rerank(relevance,similarity,k=3,weight=.7,eligible=None):
r=np.asarray(relevance,float);s=np.asarray(similarity,float)
if r.ndim!=1 or s.shape!=(len(r),len(r)) or not np.isfinite(r).all() or not np.isfinite(s).all() or not np.allclose(s,s.T) or ((s<-1)|(s>1)).any() or not isinstance(k,int) or k<0 or not np.isfinite(weight) or not 0<=weight<=1:raise ValueError('finite scores, symmetric similarities and valid controls required')
allowed=list(range(len(r))) if eligible is None else list(eligible)
if len(set(allowed))!=len(allowed) or any(not isinstance(i,(int,np.integer)) or not 0<=i<len(r) for i in allowed):raise ValueError('unique valid candidate IDs required')
selected=[];trace=[]
while allowed and len(selected)<k:
# The first item is the most relevant, including at weight zero.
redundancy={i:max(s[i,j] for j in selected) if selected else 0. for i in allowed}
objective={i:weight*r[i]-(1-weight)*redundancy[i] for i in allowed}
chosen=min(allowed,key=lambda i:(-objective[i],-r[i],i));selected.append(int(chosen));allowed.remove(chosen)
trace.append(dict(item=int(chosen),relevance=float(r[chosen]),max_similarity=float(redundancy[chosen]),objective=float(objective[chosen])))
return selected,trace
def measures(selected,relevance,similarity,categories):
r=np.asarray(relevance,float);s=np.asarray(similarity,float);n=len(selected)
if len(set(selected))!=n:raise ValueError('list items must be unique')
pair_sum=sum(float(s[i,j]) for ix,i in enumerate(selected) for j in selected[ix+1:]);pairs=n*(n-1)//2
return dict(mean_relevance=float(np.mean(r[selected])) if n else None,pair_sum=pair_sum,
mean_similarity=pair_sum/pairs if pairs else None,
mean_dissimilarity=1-pair_sum/pairs if pairs else None,
category_coverage=len({categories[i] for i in selected})/len(set(categories)),pairs=pairs)
def demo():
r=np.array([.95,.94,.92,.85,.8,.35]);x=np.array([[1,0,0,0],[.98,.05,0,0],[.96,.1,0,0],[0,1,0,0],[.3,0,1,0],[0,0,0,1]],float)
s=similarities(x);categories=['space','space','space','music','garden','cooking'];rows=[]
for w in [1.,.7,.2]:
chosen,trace=rerank(r,s,weight=w);rows.append(dict(weight=w,selected=chosen,trace=trace,**measures(chosen,r,s,categories)))
restricted,_=rerank(r,s,weight=.2,eligible=[0,1,2]);filtered,_=rerank(r,s,weight=.2,eligible=np.flatnonzero(r>=.75))
return dict(rows=rows,similarity=s.tolist(),relevance=r.tolist(),categories=categories,
restricted=restricted,filtered=filtered,filtered_metrics=measures(filtered,r,s,categories),
reversed_metrics=measures(list(reversed(rows[1]['selected'])),r,s,categories))
if __name__=='__main__':print(json.dumps(demo(),allow_nan=False))
For three output items, lambda values 1, 0.7 and 0.2 produce:
| Lambda | Selected IDs | Mean relevance | Mean dissimilarity | Category coverage |
|---|---|---|---|---|
| 1 | [0,1,2] | 0.936667 | 0.002692 | 0.25 |
| 0.7 | [0,3,4] | 0.866667 | 0.904217 | 0.75 |
| 0.2 | [0,3,5] | 0.716667 | 1 | 0.75 |
The last list has maximal dissimilarity within this nonnegative fixture, yet admits item 5 with relevance 0.35. Category coverage cannot distinguish the second and third lists: both cover three of the four labels. A relevance floor of 0.75 excludes item 5 and returns [0,3,4] even at lambda=0.2. Such a floor is a declared eligibility policy, not a mathematically inevitable choice.
Restrict candidates to [0,1,2], and diversification can only reorder those near-duplicates. It cannot discover music or gardening outside its input set. Reversing [0,3,4] preserves all reported pair and category metrics, illustrating their blindness to position.
The program returns each greedy step’s relevance, largest similarity and combined objective. Tests independently check a hand case where a less relevant but nonredundant item wins, the sum-to-mean factor, negative similarities, candidate restrictions, zero output budget and undefined pair metrics for a singleton.
Computing all N-by-N cosine similarities costs O(N² d) time and O(N²) storage for d-dimensional features. This simple implementation recomputes the maximum against the selected list, so selecting k items costs O(N k²). Maintaining a running maximum can reduce that part to O(N k); with negative similarities, initialize from the first selected item’s similarities rather than silently clipping them to zero. Metrics on the output list require O(k²) pair comparisons. No model training or user utility optimization occurs in this reranker.
A taxonomy decides which differences count
A single coarse category can hide meaningful variation within a topic. A fine taxonomy can inflate coverage merely by splitting labels. Cosine also depends on feature scaling and representation quality. Higher measured diversity can therefore reflect a representation change rather than a better experience.
Ziegler’s diversification algorithm blends relevance and dissimilarity ranks and uses taxonomy-based comparisons; it is not identical to the score-based MMR loop above. PDF 4 Keep the algorithm, similarity function and metric normalization explicit when comparing results.
Evaluate user outcomes separately, stratify by user needs, and report relevance alongside coverage. A reader exploring a field may value breadth; a reader comparing close substitutes may value redundancy. This example makes neither preference universal and does not reproduce either paper’s user study.
Which improvement did you actually measure?
- Does rearranging the same three items change the pairwise mean similarity? Answer: No. The unordered pairs are unchanged. Position-sensitive metrics can still change.
- Three pair similarities sum to 0.6 for a three-item list. What are the mean similarity and mean dissimilarity? Answer: 0.2 and 0.8. Divide by three pairs, not by two or six.
- Why do lambda=0.7 and lambda=0.2 have the same category coverage here? Answer: Each selects three distinct categories from four, even though one includes a much lower-relevance item. Coverage alone cannot express that loss.
- Can reranking a space-only candidate pool return a music item? Answer: No. MMR selects from its supplied eligible candidates. Candidate generation must first provide that option.
Keep sums, averages and user outcomes separate
The cited TIPSTER method page gives the explicit relevance-minus-redundancy weighting; it resolves a parentheses ambiguity in an earlier two-page MMR copy inspected during research. The Ziegler paper supplies the original pair-sum definition, permutation invariance and a different diversification procedure. Our mean normalization, synthetic scores, relevance floor and traces are original teaching choices. No source figure or upstream code was copied. A useful next experiment changes the taxonomy while holding items fixed, then asks whether a changed coverage percentage corresponds to any change in what the user receives.
Make a prediction, then check
Does greater pairwise dissimilarity guarantee more useful recommendations?
Learning objectives
- State the similarity convention and measure what is gained and lost by diversification.
- Run the original computation and explain a counterexample without claiming a public benchmark result.
Prerequisites & connections
Explore related knowledge →References
- Summarization: (1) Using MMR for Diversity-Based Reranking and (2) Evaluating Summaries
Jade Goldstein; Jaime Carbonell · 1998 - Improving Recommendation Lists Through Topic Diversification
Cai-Nicolas Ziegler; Sean M. McNee; Joseph A. Konstan; Georg Lausen · 2005
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-23 · Single AI author. Scoped reading: Read PDF 1 identity and page 2 MMR definition, then viewed page 2. Explicit lambda*relevance minus (1-lambda)*redundancy; resolves parentheses ambiguity in the earlier two-page SIGIR copy. No user-study reproduction. Read PDF 1 identity and 3–4 text; viewed page 3. Original ILS is a pair sum, not normalized mean; permutation invariance and rank-fusion diversification. No benchmark or user-study reproduction. 6 paired equations and four explained exercises. Checked MMR by hand, relevance versus redundancy, pair sum/mean normalization, permutation invariance, negative similarities, candidate limits and undefined singleton metric. TIPSTER resolves earlier formula parentheses; no user-study reproduction.
- Checked MMR by hand, relevance versus redundancy, pair sum/mean normalization, permutation invariance, negative similarities, candidate limits and undefined singleton metric. TIPSTER resolves earlier formula parentheses; no user-study reproduction.
- Four computed SVG variants per topic;10 numeric/geometry tests and30 responsive cases passed. Ten selected final captures directly viewed. Full article acceptance recorded separately.
Source locations checked:
- Summarization: (1) Using MMR for Diversity-Based Reranking and (2) Evaluating Summaries · Read PDF 1 identity and page 2 MMR definition, then viewed page 2. Explicit lambda*relevance minus (1-lambda)*redundancy; resolves parentheses ambiguity in the earlier two-page SIGIR copy. No user-study reproduction.
- Improving Recommendation Lists Through Topic Diversification · Read PDF 1 identity and 3–4 text; viewed page 3. Original ILS is a pair sum, not normalized mean; permutation invariance and rank-fusion diversification. No benchmark or user-study reproduction.
Related topics