AI Glossary / Graphs and symbolic AI / Intermediate
Rocchio algorithm
Definition
The Rocchio algorithm is a relevance-feedback method that updates a search query's vector using documents judged relevant and nonrelevant. It moves the query toward the average vector of relevant documents and away from the average vector of nonrelevant documents, while retaining a weighted contribution from the original query. The revised vector is then used to retrieve or rank documents again.
What it means
A short query may not express everything the searcher wants. After seeing initial results, the searcher can identify useful examples and misleading ones. Rocchio converts those judgments into a numerical change in the query representation.
The classic method belongs to vector-space information retrieval, often using weighted terms. It does not read the user's mind or automatically understand why a document was rejected. Its effect depends on the document representation, the selected examples, and the weights assigned to original-query, positive-feedback, and negative-feedback contributions.
How it works
Represent the query and documents in the same feature space. Compute the centroid, or component-wise average, of the relevant documents and separately of the nonrelevant documents.
Update the query as q_new = alpha×q_original + beta×centroid_relevant − gamma×centroid_nonrelevant. Alpha, beta, and gamma control the three contributions. A missing feedback group needs explicit handling rather than division by zero. In the classic nonnegative term-weight formulation, negative resulting term weights are set to zero.
Use the updated query with the intended ranking method, such as cosine similarity. Further feedback can support another search iteration. The precise treatment of normalization, term selection, and repeated updates should be specified because those choices affect the results.
Three practical examples
- Document discovery: let an analyst mark useful reports and use their term patterns to refine a broad initial search.
- Archive exploration: shift an ambiguous query toward the subject represented by selected relevant documents and away from an unwanted meaning.
- Search education: demonstrate how relevance judgments alter a vector-space query, making feedback effects visible through small numerical examples.
Think of it this way
Think of moving a marker on a map toward a group of useful examples and away from a group of unsuitable ones. The analogy describes vector movement, but the map's coordinates represent features rather than geography. An average location can also be unhelpful when the useful examples belong to several widely separated groups.
Worked example
Use a three-dimensional term space for an original teaching example. Let the query be q_original = (1, 0, 0). Two relevant document vectors are (1, 2, 0) and (1, 0, 0), so their centroid is (1, 1, 0). One nonrelevant document has vector (0, 1, 2).
Choose alpha = 1, beta = 0.5, and gamma = 0.25 for illustration. Before clipping, the updated query is (1, 0, 0) + (0.5, 0.5, 0) − (0, 0.25, 0.5) = (1.5, 0.25, −0.5). Applying the classic nonnegative-term convention gives (1.5, 0.25, 0).
The first feature remains dominant, the second receives a small positive weight, and the third is excluded after clipping. These weights are feature weights, not probabilities, and need not sum to one.
Compare candidate vectors D = (1, 1, 0) and E = (0, 0, 1) using cosine similarity. The revised query has length sqrt(2.3125), approximately 1.521. Its similarity to D is 1.75/[sqrt(2.3125)×sqrt(2)], approximately 0.814. Its similarity to E is zero. Originally, the query's similarity to D was 1/sqrt(2), approximately 0.707.
This calculation demonstrates a ranking signal for two candidates, not improved search quality across a real collection. The feedback and weights are stipulated, and another representation or normalization policy could change the outcome.
Illustrative case study
Fictional case: Silver Archive Classroom searches for documents about a software platform whose name also appears in unrelated articles. Students mark several relevant technical notes and a few irrelevant uses of the name.
The revised query adds weight to terminology present in the selected technical notes. A reviewer then notices that the feedback examples all concern installation, while the intended search also includes maintenance. The class collects more representative judgments and evaluates new, previously unjudged documents instead of celebrating the return of examples it already selected.
The case illustrates both useful query refinement and the risk of narrowing a broad information need around an unrepresentative feedback set.
Common misconceptions and mistakes
Rocchio feedback does not guarantee better results. Incorrect or narrow judgments can cause query drift, moving the search away from the intended need.
Do not confuse explicit feedback with pseudo-relevance feedback, which assumes some initial results are relevant without asking the user. An error in those assumptions can reinforce the original retrieval mistake.
The centroid model also has limits when relevant documents form several distinct groups. Averaging them may produce a query direction that does not represent any group well. Relevance is a task judgment, not a permanent universal property of a document.
Business use
Rocchio offers an understandable baseline for interactive search refinement. Teams can inspect which features gain or lose weight and explain why a later result differs from the first search.
Evaluate with representative queries, realistic feedback effort, and unjudged documents. Keep document permissions intact when gathering feedback and retrieving expanded results. If feedback is retained across sessions or users, define its scope clearly; a relevance judgment for one task should not silently become a global ranking preference. The method's simplicity makes its assumptions easier to inspect, but those assumptions still need validation.
People also ask
Does Rocchio require negative feedback?
No. A positive-only version can set gamma to zero and use relevant documents alone.
Are the updated weights probabilities?
No. They are coordinates used by the retrieval representation and ranking process.
Is Rocchio a neural-network training algorithm?
No. The classic method updates a query vector from feedback centroids; it does not train neural-network weights.
Check your understanding
Why should a system not divide by the number of nonrelevant documents when that number is zero?
Answer: The centroid would be undefined. The implementation must omit that contribution or follow another explicitly defined empty-feedback policy.
Related terms
- Centroid
- Cosine similarity
- Relevance feedback
- vector-space model
- query expansion
- TF-IDF
- pseudo-relevance feedback
- query drift
Learn next
Recalculate the example with gamma set to zero and compare the result. Then test how a single unrepresentative relevant document changes the centroid. Study evaluation on unseen documents so that improvement is measured beyond simply retrieving the documents already used as feedback.
More in Graphs and symbolic AI
- Reverse-search algorithm - A reverse-search algorithm is an enumeration method that generates objects by traversing an implicitly defined tree.
- Rich Club - A rich club in a network is a set of highly connected nodes that also connect densely to one another.
- Robust control - Robust control is the design and analysis of controllers that maintain specified behavior despite explicitly modeled uncertainty.
- Rough fuzzy hybridization - Rough fuzzy hybridization combines ideas from rough-set theory and fuzzy-set theory to represent different kinds of imprecision together.
- S metric - The s metric is a graph statistic obtained by summing the product of the endpoint degrees over all edges.
- S-set - The S-set is the specific boundary of a version space: the set of maximally specific hypotheses that remain consistent with all observed training examples.
Sources
Manning, Raghavan, and Schütze, The Rocchio Algorithm: https://nlp.stanford.edu/IR-book/html/htmledition/the-rocchio71-algorithm-1.html When Does Relevance Feedback Work?: https://nlp.stanford.edu/IR-book/html/htmledition/when-does-relevance-feedback-work-1.html Author-maintained textbook explanations were read. Vectors, cosine calculations, and fictional archive case are original.
Previous: ROC (receiver operating characteristic) Curve Next: Role-filler extraction