Relevance Feedback and Query Expansion: Rocchio and RM3
Closing the loop — using the documents you just retrieved to repair the query, and why doing too much of it drifts off topic
Every retrieval model so far has matched a query against documents as written. But a query and the documents that answer it routinely use different words. An analyst searches for rate guidance; the filing that answers the question discusses the company’s outlook and rate forecast and never once writes “guidance.” BM25 and query likelihood cannot match a term that is not there, so the most on-point document sinks beneath worse ones that happen to share the query’s vocabulary. This is the vocabulary mismatch problem, and relevance feedback is the classical fix: use the documents you have already retrieved to repair the query, then search again.
The catch is in the assumption. We rarely have real relevance judgments at query time, so pseudo-relevance feedback simply assumes the top-k retrieved documents are relevant and harvests expansion terms from them. When that assumption holds, feedback bridges the vocabulary gap and recall jumps. When it fails — when an off-topic document sits near the top — its words pollute the query and the results drift away from the user’s intent. The whole topic lives in the tension between those two outcomes.
- 1.10-K · rate guidance + outlook✓ relevant, in top-4
- 2.10-K · rate guidance + forecast✓ relevant, in top-4
- 3.10-K · rate outlook/forecast (synonym)✓ relevant, in top-4
- 4.News · rate forecast/outlook (synonym)✓ relevant, in top-4
- 5.10-K · cost guidance / budget
- 6.10-K · segment guidance
A little feedback (1–2 docs) adds outlook/forecast and surfaces the synonym filings — recall climbs to 1.0. Push the slider higher and off-topic feedback adds budget/costs, the query drifts, and a relevant document drops out.
The laboratory above runs RM3 over a worked corpus for the query rate guidance. Two of the four relevant documents are synonym-only — they say outlook and forecast, never “guidance” — so the no-feedback ranking misses them and recall@4 is only . Slide the feedback size to one or two documents and the relevance model adds outlook and forecast, the synonym filings surface, and recall reaches . Keep sliding: off-topic feedback documents add budget and costs, the query drifts, and a relevant document drops back out.
What we cover
- Relevance feedback and the vocabulary-mismatch problem.
- Rocchio: moving the query toward the relevant centroid.
- The relevance model RM1.
- RM3: interpolating the relevance model with the original query.
- Query drift: the honest failure mode, and a finance case study.
Rocchio: the centroid update
The vector-space answer, due to Rocchio, treats query repair as geometry: push the query vector toward the documents marked relevant and away from those marked non-relevant.
Definition 1 (Rocchio update).
Given sets of relevant documents and non-relevant documents (as tf-idf vectors), the updated query is
with weights . In pseudo-relevance feedback we set and take to be the top retrieved documents, then re-rank by cosine similarity to .
The two averages are the centroids of the relevant and non-relevant sets, so Rocchio is a nearest-centroid construction: it shifts the query toward the middle of what looks relevant. This is not an arbitrary recipe — it is the solution to an optimization.
Proposition 1 (Rocchio maximizes the relevant–non-relevant margin).
Among query vectors of fixed norm, the one that maximizes the difference between the average similarity to the relevant set and the average similarity to the non-relevant set,
points in the direction of the centroid difference . Rocchio’s and terms are exactly this direction; the term anchors the result to the original query.
Proof.
Write the objective as a single inner product. Pulling the sums inside,
where and are the two centroids. Maximizing a linear function over the sphere is the textbook Cauchy–Schwarz problem: with equality iff is parallel to . So the optimal direction is — the centroid difference. Rocchio realizes this direction with separate non-negative weights on and on , and adds so the repaired query does not wander arbitrarily far from what the user actually asked.
∎Because now points toward the relevant centroid, its similarity to those documents — and to their unseen near-neighbors in the same vocabulary — rises. The companion notebook confirms that the Rocchio update strictly increases the query’s mean cosine to the feedback documents and lifts recall@4 on the worked corpus.
The relevance model RM1
The language-model analogue, due to Lavrenko and Croft, is more probabilistic. Instead of moving a vector, it estimates a distribution: a relevance model that we imagine the relevant documents were generated from.
Definition 2 (RM1 relevance model).
Estimate the probability of a word under the relevance model by averaging the document models, weighted by how well each document explains the query:
where is the query likelihood and the document prior is taken uniform over the feedback set.
The intuition is a sampling story: if we believe the query was drawn from the relevant class, then documents that generate the query well ( large) are our best proxies for that class, and the words they contain are the words the relevant class favors. Summing each feedback document’s model weighted by its query likelihood produces a genuine probability distribution over the vocabulary — the notebook verifies — whose highest-probability terms are the expansion terms. On the worked corpus with clean feedback, those top terms are exactly forecast and outlook, each at weight : the relevance model has discovered the synonyms the literal query lacked. This is a point estimate of the expanded query from a small sample of documents, and — as we will see — its bias when that sample is contaminated is precisely query drift.
RM3: interpolating with the original query
A pure relevance model can wander, so RM3 anchors it to the original query, exactly as Rocchio’s term does.
Definition 3 (RM3).
Interpolate the relevance model with the original (maximum-likelihood) query model and re-score by cross-entropy:
The re-scoring is the KL / cross-entropy view from the query-likelihood topic, with the thin empirical query model swapped for the richer . The mixing weight interpolates between two familiar endpoints.
Proposition 2 (RM3 limits).
At , and the ranking is exactly the original query-likelihood ranking — no expansion. At , , the pure relevance model. Intermediate blends the two.
The proof is immediate from the definition — substitute and — but the content is real: is the dial between trusting the user’s words and trusting the feedback. The notebook confirms that at the RM3 ranking equals the unexpanded query-likelihood ranking (recall ), while a moderate with a little feedback bridges the vocabulary gap to recall .
Query drift: the honest failure
Everything above assumed the feedback documents are relevant. Pseudo-relevance feedback assumes it by fiat — it trusts the top-k of the initial ranking — and that is where it can fail.
Finance case study
Implementation
The companion notebook implements both relevance-feedback families from scratch over the worked finance corpus — Rocchio on tf-idf vectors and RM1/RM3 on language models, with the query likelihood supplying the feedback weights — and turns each claim into an assertion. It verifies that the RM1 relevance model is a proper distribution, that the Rocchio update equals times the feedback centroid and raises the query’s mean similarity to it, and that RM3 recovers the unexpanded query-likelihood ranking at .
The two headline numbers are the gain and the drift, measured on the same curve. For the query rate guidance, whose four relevant documents include two synonym-only filings, recall@4 starts at with no feedback, rises to once one or two feedback documents inject forecast and outlook (each weighted in the relevance model), and falls back to as the feedback set grows to four and off-topic terms enter — the query-drift failure, reproduced exactly. The full recall-versus-feedback curve and the expansion terms at each feedback size are printed by the harness so the page, the notebook, and the laboratory read one set of numbers.
Connections
- RM3 is the relevance-model generalization of query likelihood: it replaces the empirical query model with a feedback-estimated relevance model and re-scores by the same KL/cross-entropy, and it weights feedback documents by their query likelihood P(q|d) query-likelihood-language-models
- the initial ranking that feedback documents are drawn from is produced by BM25; pseudo-relevance feedback treats its top-k as relevant bm25-binary-independence-model
- Rocchio operates on the tf-idf vectors of the vector space model, moving the query vector toward the centroid of the feedback documents vector-space-model-tfidf
References & Further Reading
- paper Relevance-Based Language Models — Lavrenko & Croft (2001) The RM1 relevance model
- paper A Comparative Study of Methods for Estimating Query Language Models with Pseudo Relevance Feedback — Lv & Zhai (2009) RM3 and a systematic comparison of PRF estimation methods
- paper Improving Retrieval Performance by Relevance Feedback — Salton & Buckley (1990) The definitive treatment of Rocchio relevance feedback in the vector space model
- book Introduction to Information Retrieval — Manning, Raghavan & Schütze (2008) Chapter 9: relevance feedback and query expansion
- documentation Pyserini / Anserini: reproducible RM3 pseudo-relevance feedback Reference RM3 implementation over Lucene