AI Wiki中文/EN

Retrieval feedback: learning from a judgment, not a rank

检索反馈与相关性反馈

Run Rocchio and mixture EM, distinguish explicit labels from pseudo feedback, and evaluate on unseen documents.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

A click is not the same as “this answers my question”

The first result is an engine manual. A reader opens it, notices the wrong sense of “jaguar,” and returns immediately. Treating that click as a positive relevance judgment would send the next search in precisely the wrong direction.

Relevance feedback updates a query using information about retrieved documents. Explicit feedback asks for a judgment. Pseudo feedback assumes high-ranked results are relevant. Implicit feedback uses behavior, which can reflect exposure, curiosity or interface position as well as relevance. IIR separates these mechanisms; their signals should not share an unqualified “positive” label. IIR, sections 9.1.6–9.1.7

This topic concentrates on the update and its evaluation. Query expansion concentrates on supplying additional vocabulary or representations. Feedback may expand a query, but it can also reweight existing terms or subtract a misleading direction.

Explicit judgments and wrong pseudo positives move the query in different directions.
Explicit judgments and wrong pseudo positives move the query in different directions.

Move toward judged examples, then check what moved

Rocchio combines an original query with centroids of judged relevant and nonrelevant document vectors:

q′=max⁡(0,αq+β∣D+∣∑d∈D+d−γ∣D−∣∑d∈D−d).q'=\max\left(0,\alpha q+\frac{\beta}{|D_+|}\sum_{d\in D_+}d-\frac{\gamma}{|D_-|}\sum_{d\in D_-}d\right).

The maximum acts coordinatewise for the nonnegative lexical version described in IIR. An empty judgment group contributes zero here. The weights are nonnegative and control how much to retain, add and subtract. Dense embeddings can have meaningful negative coordinates, so blindly copying this clipping rule into every embedding system changes the method’s meaning. IIR, equation 9.3

Suppose coordinates represent an ambiguous name, animal habitat and engines. With query (1,0,0), one positive vector (1,1,0), one negative vector (1,0,1), and weights 1, 0.75 and 0.25, the pre-clipped third coordinate is negative. Clipping gives (1.5,0.75,0). A wrong pseudo-positive engine vector with weight 2 instead gives (3,0,2).

A language-model approach estimates a feedback distribution over words. Zhai and Lafferty model feedback counts as a mixture of a topic distribution theta and a fixed collection background b. For counts c, its log-likelihood is:

ℓ(θ)=∑wcwlog⁡[(1−λ)θw+λbw],0≤λ<1.\ell(\theta)=\sum_w c_w\log[(1-\lambda)\theta_w+\lambda b_w],\qquad 0\le\lambda<1.

The background mixture weight is fixed; learning everything without constraints can favor the degenerate no-background solution discussed in the paper. The E-step computes the probability that each occurrence came from the topic component:

rw=(1−λ)θw(1−λ)θw+λbw.r_w=\frac{(1-\lambda)\theta_w}{(1-\lambda)\theta_w+\lambda b_w}.

The M-step normalizes expected topic counts:

θwnew=cwrw∑ucuru.\theta_w^{\mathrm{new}}=\frac{c_wr_w}{\sum_u c_ur_u}.

Thus a frequent background word need not dominate the estimated topic. A query distribution can then be interpolated with that feedback distribution:

pQ′(w)=(1−ρ)pQ(w)+ρθw,0≤ρ≤1.p'_Q(w)=(1-\rho)p_Q(w)+\rho\theta_w,\qquad 0\le\rho\le1.

The interpolation weight rho has a different role from the background weight lambda. Rank a smoothed document distribution by negative KL divergence, equivalently the query-weighted log probability after dropping the query-only constant:

s(Q′,D)=∑wpQ′(w)log⁡pD(w).s(Q',D)=\sum_w p'_Q(w)\log p_D(w).

Document smoothing must prevent zero probabilities for positively weighted query words. The program below implements Rocchio and the feedback EM estimator; the final language-model retrieval stage is explained here but not implemented. Zhai and Lafferty, physical PDF 2–3

A held-out ranking and a purified word distribution

Run this standalone program with Python 3.12 and NumPy 1.26.4. All vectors and counts are authored teaching fixtures. The documents used for judging differ from the three documents used to inspect the resulting rankings. This avoids rewarding the update merely for returning the very document it was given.

"""Rocchio and a fixed-background mixture EM; original finite fixtures."""
import json
import numpy as np


def rocchio(query, relevant, irrelevant, alpha=1., beta=.75, gamma=.25):
    q = np.asarray(query, float)
    if q.ndim != 1 or not np.isfinite(q).all() or not all(np.isfinite(x) and x >= 0 for x in (alpha,beta,gamma)):
        raise ValueError('invalid query or weights')
    out = alpha*q
    for group, weight in [(relevant, beta), (irrelevant, -gamma)]:
        if len(group):
            x = np.asarray(group, float)
            if x.ndim != 2 or x.shape[1] != q.size or not np.isfinite(x).all():
                raise ValueError('invalid feedback vectors')
            out = out+weight*x.mean(axis=0)
    return np.maximum(out, 0.)


def mixture(counts, background, noise=.5, steps=100):
    c = np.asarray(counts, float); b = np.asarray(background, float)
    if c.ndim != 1 or c.shape != b.shape or not np.isfinite(c).all() or not np.isfinite(b).all() or (c < 0).any() or c.sum() <= 0 or (b <= 0).any() or not np.isclose(b.sum(), 1):
        raise ValueError('counts and positive normalized background required')
    if not np.isfinite(noise) or not 0 <= noise < 1 or not isinstance(steps, int) or steps < 0:
        raise ValueError('invalid EM controls')
    theta = np.ones(c.size)/c.size
    positive = c > 0
    def likelihood(t):
        # Zero-count terms contribute zero, including the limit 0 * log(0).
        return float(c[positive]@np.log(((1-noise)*t+noise*b)[positive]))
    history = [likelihood(theta)]
    for _ in range(steps):
        numerator = (1-noise)*theta
        denominator = numerator+noise*b
        responsibility = np.divide(numerator, denominator, out=np.zeros_like(theta), where=denominator>0)
        expected = c*responsibility
        theta = expected/expected.sum()
        history.append(likelihood(theta))
    return theta, history


def ranking(q, docs):
    q = np.asarray(q, float); docs = np.asarray(docs, float)
    denom = np.linalg.norm(q)*np.linalg.norm(docs, axis=1)
    scores = np.divide(docs@q, denom, out=np.zeros(len(docs)), where=denom>0)
    return sorted(range(len(docs)), key=lambda i: (-scores[i], i))


def demo():
    # Coordinates: ambiguous name, animal habitat, engine. Feedback and test docs differ.
    q = np.array([1.,0.,0.]); positive = [[1,1,0]]; negative = [[1,0,1]]
    explicit = rocchio(q, positive, negative)
    wrong = rocchio(q, negative, [], beta=2)
    heldout = [[0,1,0], [0,0,1], [.2,1,0]]
    theta, history = mixture([8,6,6], [.8,.1,.1])
    return dict(original=q.tolist(), explicit=explicit.tolist(), pseudo_wrong=wrong.tolist(),
                heldout_orders=[ranking(x,heldout) for x in [q,explicit,wrong]],
                topic=theta.tolist(), empirical=[.4,.3,.3], likelihood=[history[0],history[-1]])


if __name__ == '__main__':
    print(json.dumps(demo(), allow_nan=False))

On the held-out vectors, the original and explicit-feedback queries both rank document 2 first. Correct feedback does not improve every metric on every collection. The wrong pseudo feedback changes first place to engine document 1. Its direction visibly contains an engine component while the explicit update clips that component to zero.

For word counts (8,6,6), background (0.8,0.1,0.1), noise weight 0.5 and 100 EM steps, the estimated topic is about (0.00475,0.49762,0.49762), compared with empirical frequencies (0.4,0.3,0.3). Log-likelihood rises from about −22.8966 to −21.7782. These are finite-iteration values, not a claim that the limiting first coordinate is exactly 0.00475. Independent checks verify monotonic likelihood, normalization and the zero-noise empirical solution, including zero-count vocabulary entries.

For vocabulary size V, K EM steps cost O(KV) time and O(V) working space, plus O(K) storage for the returned likelihood history. Rocchio costs O(JV) for J judged dense vectors in this implementation. Sparse lexical vectors permit a different accounting in terms of nonzero entries.

Do not grade the model on its hint

An evaluation over the same judged documents can report spectacular gains simply because the query moves toward known positives. IIR explains why comparing both original and updated queries on a separate collection gives a cleaner comparison. IIR, section 9.1.5 Keep the judgment budget, candidate pool and information need fixed, and disclose whether judged items are excluded.

Rocchio compresses positive evidence into a centroid. Disjoint relevant subtopics can be poorly represented by one center. Pseudo feedback can amplify the wrong topic. A background mixture can suppress common vocabulary, but it does not prove that the supplied feedback is relevant. Behavioral feedback additionally needs an account of what the user was shown; unclicked unseen items are not negative judgments.

Use the original query as a fallback and log why terms changed. If users cannot explain the new results, an apparently better average score may still produce a worse search interaction.

Audit the update

  1. Explain. Why not label every unclicked document irrelevant? Answer: Some documents were never exposed or noticed, and a click can express curiosity rather than relevance. The observation process differs from an explicit content judgment.
  2. Calculate. Compute the Rocchio example’s third coordinate before and after clipping. Answer: It is 0+0−0.25=−0.25 before clipping and 0 afterwards. The other coordinates become 1.5 and 0.75.
  3. Modify. Set the EM noise weight to zero. What distribution follows after one update? Answer: Every responsibility is 1, so normalized counts are returned: (0.4,0.3,0.3). Further updates do not change this empirical solution.
  4. Investigate. How would you compare two feedback rules? Answer: Give both the same initial query and judgments, then compare on the same held-out collection with the same relevance labels. Also measure user effort and instability across small judgment sets; do not count memorized positives as new discovery.

Two representations, one question about evidence

IIR develops geometric feedback and its evaluation pitfalls. Zhai and Lafferty make the query itself a probability model and derive feedback through estimation. The two examples here reproduce small update calculations, not their retrieval benchmarks. Continue with RAG evaluation to separate evidence selection from answer quality.

Make a prediction, then check

Why evaluate feedback on documents not used to update the query?

Choose one answer

Learning objectives

  • Update a query from positive and negative judgments without leaking feedback documents into evaluation.
  • Run the original example, explain its counterexample and identify the untested deployment assumptions.

Prerequisites & connections

Explore related knowledge →

References

  1. An Introduction to Information Retrieval — online draft, April 1, 2009
    Christopher D. Manning; Prabhakar Raghavan; Hinrich Schütze · 2009
  2. Model-based Feedback in the Language Modeling Approach to Information Retrieval
    Chengxiang Zhai; John Lafferty · 2001

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-20 · Single AI author. Recorded source scopes (some exact source objects reused from earlier checks): Viewed physical PDF43/48/78/133/134/158/159/193; read PDF38/44/49/155/189/192 text. Inverted/positional indexes, Boolean merge, variable bytes, lexical vectors and evaluation; not a whole-book review. Read PDF 1 identity and 2–3: query/document distributions, KL ranking, interpolated feedback and fixed-background mixture EM. Viewed PDF 3 equations; no retrieval benchmark reproduction. 6 paired equations and four explained exercises. Checked Rocchio by hand, held-out query drift, fixed-background EM monotonicity, one-step responsibilities and zero-count/zero-noise limit. Preserved the reproduced NaN failure and repair. Additional IIR2009 reading: physical219 equation9.3 and clipping,221 centroid assumptions,223 separate-collection evaluation,224 pseudo/implicit feedback,226 and227 text below figure global vocabulary expansion. Existing Source preserved.

  • Checked Rocchio by hand, held-out query drift, fixed-background EM monotonicity, one-step responsibilities and zero-count/zero-noise limit. Preserved the reproduced NaN failure and repair.
  • Four computed SVG variants per topic;12 numeric/geometry tests and42 responsive cases passed. Fourteen selected final captures directly viewed. Full article acceptance recorded separately.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.