Query Expansion

Adding terms to a query that the searcher did not type. Interactive and automatic expansion, controlled vocabularies, thesauri and query logs, an association thesaurus built from Cranfield and used to expand every query, why global expansion barely helps there while local expansion with relevance models (RM3) helps substantially, and later methods based on embeddings and document expansion. Worked problems on co-occurrence matrices and on a relevance model computed in exact fractions.

Query expansion adds terms the searcher did not type. On Cranfield's 225 queries, global expansion from an association thesaurus built from the collection's own co-occurrences helped little: the best of eighteen settings, ten IDF-weighted terms at weight 0.25, raised BM25's MAP from 0.307 to 0.320, and a setting chosen on development queries gave exactly BM25's 0.297 on the held-out test queries. Local expansion with relevance models (RM3: 10 feedback documents, 10 terms, original-query weight 0.5) raised query likelihood's MAP from 0.284 to 0.330, above BM25 ($p < 0.001$), and kept its gain on held-out queries (0.328 against BM25's 0.297), yet it still harmed 61 queries. The relevance model is the top documents' word distributions averaged with weights $P(q \mid D) / \sum_{D'} P(q \mid D')$.

In the relevance feedback article, a searcher's judgments taught the system that Cranfield query 180, how does scale height vary with altitude in an atmosphere, is well served by orbit, perigee, satellite and density. Pseudo-relevance feedback learned most of the same words from the top-ranked abstracts alone. Both methods learn only after a first retrieval, from documents that the query happened to find. A system can also try to know in advance that satellite goes with orbit and perigee, and add such words to any query before it runs. This article measures how well that works on Cranfield, and sets it beside the methods that learn from the retrieved documents.

Query expansion is the general name for adding terms to a query that the searcher did not type. The methods differ in where the new terms come from. Global methods draw them from a resource prepared before any query is seen: a thesaurus built by editors, one computed from the whole collection, or a log of other searchers' queries. Local methods draw them from the documents retrieved for this query, as relevance feedback and pseudo-relevance feedback do. The two terms are from Xu and Croft (1996), who used global for analysis of the whole collection and local for analysis of the top-ranked documents. The wider grouping here, with manual thesauri and query logs counted as global, follows Manning, Raghavan, and Schütze (2008, §9.2). This article is the canonical home of the global methods. The local methods have their own articles, and here they reappear in the language modeling framework of language models for retrieval.

Here is the route. First we look at why queries need expansion and at the ways a system can offer it. Then we build an association thesaurus from Cranfield, read its neighbor lists, and expand every Cranfield query from it. Next we expand the same queries locally with relevance models, the version of pseudo-relevance feedback built on language models, and compare the two. Finally we survey later methods. The article assumes BM25 and query likelihood.

Why queries need more words

Searchers and authors often use different words for the same thing. The textbook cites an early experiment, from about 1960, in which only 11 of 23 documents properly indexed under the subject toxicity used any word containing the stem toxi (Manning, Raghavan, and Schütze, 2008, §9.3, after Swanson). Blair and Maron concluded that it is "impossibly difficult" for users to predict the words that all (or most) relevant documents use, and only (or primarily) they use (quoted in the same section). This is the problem of vocabulary mismatch. Stemming handles one small part of it, different forms of the same word, and normalization leaves synonyms alone on purpose.

Query expansion attacks the rest from the query side. Its usual effect is to raise recall: documents that use the new words are now matched. Its usual cost is precision: a new word can bring in documents about something else. The textbook's example is a query for interest rate expanded to interest rate fascinate evaluate, where a thesaurus has supplied synonyms for the wrong sense of each word (§9.2.3).

Interactive or automatic

A system can expand a query in two ways (Manning, Raghavan, and Schütze, 2008, §9.2.2):

  • Interactive expansion suggests terms or whole alternative queries and lets the searcher choose. The textbook's example is the related-query suggestions that the Yahoo! web search engine showed in 2006.
  • Automatic expansion rewrites the query without asking. The textbook's example is PubMed, which at the time mapped the query cancer to ("neoplasms"[TIAB] NOT Medline[SB]) OR "neoplasms"[MeSH Terms] OR cancer[Text Word]. A searcher who does not look at the submitted query may never know that expansion happened.

The textbook adds that expansion is "much more understandable to the system user" than relevance feedback, since the added words can be shown and judged directly.

Controlled vocabularies. Editors assign each concept a canonical term and record its synonyms. The Library of Congress Subject Headings are one example, and in medicine the Unified Medical Language System used with MEDLINE is another (Manning, Raghavan, and Schütze, 2008, §9.2.2). The PubMed mapping above uses MEDLINE's Medical Subject Headings (MeSH), and search in professional domains shows MeSH used by hand in a medical search.

Manual thesauri. Editors record synonyms, broader terms and narrower terms without choosing a canonical form. For general English, recent work almost always uses WordNet (§9.3). Voorhees (1994) expanded queries by following WordNet's synonym sets and typed links. Expansion made little difference when the original queries were already relatively complete descriptions, even when the concepts to expand were chosen by hand; less developed queries could be improved significantly by expanding hand-chosen concepts. General thesauri also cover specialist vocabulary poorly, so a domain-specific thesaurus is usually needed (§9.2.3).

Automatic thesauri. Statistics computed over the collection itself can suggest which words are related, at no editorial cost. This is the method built and tested below.

Query logs. Searchers reformulate. When many of them follow one query with a related one, the pair is evidence that the queries are interchangeable. Jones, Rey, Madani and Greiner (2006) generated query substitutions this way. Such methods need very large query volumes, which makes them suited to web search (§9.2.2).

Building a thesaurus from the collection

The simplest automatic thesaurus rests on co-occurrence: words that appear in the same documents are likely to be related (Manning, Raghavan, and Schütze, 2008, §9.2.3). Build a term-document matrix $A$ whose entry $A_{t,d}$ is a weight for term $t$ in document $d$, and normalize each row to length 1. Then

$$C = A A^{\mathsf{T}}, \qquad C_{u,v} = \sum_{d} A_{u,d} A_{v,d},$$

is the cosine similarity between the rows for terms $u$ and $v$. Two terms that occur in the same documents with similar weights score near 1, and two that never share a document score 0. A term's nearest neighbors under $C$ are its thesaurus entry.

For Cranfield, the weight used here is $1 + \log_{10} \mathit{tf}_{t,d}$ for every term that occurs in a document. An IDF factor would make no difference, because it multiplies a whole row and the row normalization removes it. Terms that occur in only one document are left out of the neighbor lists. Some entries, with cosines rounded to three decimals:

Term Document frequency Nearest neighbors
satellit 32 orbit 0.622, perige 0.509, atmospher 0.440, km 0.428, densiti 0.395, eccentr 0.363
nozzl 80 exit 0.466, jet 0.368, exhaust 0.365, diverg 0.324, throat 0.303, mach 0.270
heat 306 transfer 0.786, temperatur 0.589, rate 0.436, laminar 0.430, layer 0.409, boundari 0.407
flutter 56 panel 0.446, piston 0.326, midplan 0.314, aerodynam 0.274, bai 0.267, trend 0.265
model 177 test 0.404, tunnel 0.352, number 0.344, were 0.340, from 0.339, mach 0.332
studi 240 flow 0.362, made 0.359, effect 0.317, which 0.307, from 0.301, experiment 0.301

The first rows are what a thesaurus should offer. The neighbors of satellit include orbit and perige, the terms the searcher's judgments supplied for query 180, now found without any query at all. The neighbors of nozzl are the parts and flows of a nozzle.

The later rows show the method's weaknesses:

  • Generic words. Studi occurs in 240 abstracts, and its neighbors are words that occur everywhere: made, which, from. Cosine rewards frequent co-occurrence, and frequent words co-occur with everything.
  • One sense wins. In Cranfield, model almost always means a wind-tunnel model, so its neighbors are test and tunnel. A query about a mathematical model would be expanded toward wind tunnels. The textbook's version of this problem is a query for Apple computer expanded to Apple red fruit computer (§9.2.3).
  • Redundancy. Flutter and panel are each other's nearest neighbor, and they occur together in 20 abstracts. A neighbor that mostly occurs in documents the query already matches can reorder those documents but brings in few new ones. The textbook makes this point about automatic thesauri in general (§9.2.3).

Bai is the stem of bay, as in a panel bay, and midplan that of midplane. Both are real panel-flutter vocabulary.

Expanding a query as a whole

Expanding each query term separately inherits each term's ambiguity. Qiu and Frei (1993) chose expansion terms by their similarity to the query as a whole rather than to its individual terms. Their score for a candidate is the sum of its similarities to the query's terms, each multiplied by that term's weight in the query. The experiments here apply the same idea to the cosine thesaurus with equal weights: a candidate's score is its average similarity to the query's terms. A candidate that is related to only one of them, in a sense the other terms do not support, scores lower.

For query 185, experimental studies on panel flutter, the ten best candidates by this score are result, effect, number, investig, mach, made, from, pressur, were and theori. The generic words experiment and studi dominate the average. Multiplying each candidate's score by its BM25 IDF demotes the generic candidates and gives midplan, suscept, bai, psf, prone, unstress, aluminium, trend, transtabl and piston. These are much more specific to panel flutter.

Example (the list that looks worse does better). Each list is added to the query with weight 0.5 and scored with BM25. The generic list improves query 185's average precision, which is 0.784 without expansion; the specific list lowers it. With the generic list, average precision rises to 0.818; with the specific list, it falls to 0.721. Words such as pressur and mach occur in nearly all of the nine relevant abstracts (pressur in all nine), so they reinforce documents BM25 already ranked well. The specific words come from particular panel-flutter abstracts, and several of those abstracts are not among the nine judged relevant. A list that looks better to a reader is not necessarily better for a given query. That makes it hard to judge an expansion method from examples. It has to be measured on many queries.

Global expansion on all of Cranfield

The experiment expands every Cranfield query with the $n$ best candidates by similarity to the whole query, with and without the IDF factor. It scores documents with BM25 ($k_1 = 1.2$, $b = 0.75$), multiplying each added term's contribution by an expansion weight $w$. The setup matches comparing ranking models, where BM25 alone has a mean average precision (MAP) of 0.307. Results on all 225 queries, with $p$ from a paired randomization test against BM25 (see significance testing):

Candidates scored by Terms $n$ Weight $w$ MAP Improved Harmed $p$
similarity 10 0.25 0.309 104 102 0.50
similarity 20 0.5 0.287 83 129 0.001
similarity × IDF 5 0.25 0.317 108 101 0.032
similarity × IDF 10 0.25 0.320 121 92 0.006
similarity × IDF 10 0.5 0.317 113 102 0.14
similarity × IDF 20 0.5 0.307 107 112 1.00

Without the IDF factor, no setting helped, and adding many generic terms at a high weight did significant harm. With it, the best setting raised MAP from 0.307 to 0.320.

Expanding each query term separately, with its own nearest neighbors, gave results like those of the plain similarity score. Each query term contributes its one, two or four nearest neighbors, so a query of five distinct terms gains about 5, 10 or 20 terms:

Neighbors per query term Weight $w$ MAP Improved Harmed $p$
1 0.25 0.305 100 113 0.73
1 0.5 0.305 96 120 0.75
2 0.25 0.311 107 103 0.41
2 0.5 0.301 94 123 0.40
4 0.25 0.308 106 109 0.81
4 0.5 0.283 85 134 0.003

No setting differs significantly from BM25 except the last, which does significant harm.

The best row of the first table was picked from eighteen settings (six for each of the three ways of choosing terms, with $n$ of 5, 10 or 20 and $w$ of 0.25 or 0.5), on the same queries it is reported on. To choose fairly, the queries were split as in comparing ranking models into 112 development and 113 test queries. On the development queries, the best IDF-weighted setting ($n = 20$, $w = 0.25$) raised MAP from 0.316 to 0.341. On the test queries it gave 0.297, exactly BM25's 0.297 ($p = 0.93$). On held-out queries, global expansion from this thesaurus gained nothing.

The change in average precision for each of the 225 queries, sorted. Left: ten IDF-weighted thesaurus terms added to BM25 at weight 0.25. Right: RM3 (10 feedback documents, 10 terms, original query weight 0.5) against the query likelihood ranking it starts from. Notice that the left panel is nearly symmetric, with 92 queries harmed for 121 improved, while on the right the improvements dominate, 152 to 61.
The change in average precision for each of the 225 queries, sorted. Left: ten IDF-weighted thesaurus terms added to BM25 at weight 0.25. Right: RM3 (10 feedback documents, 10 terms, original query weight 0.5) against the query likelihood ranking it starts from. Notice that the left panel is nearly symmetric, with 92 queries harmed for 121 improved, while on the right the improvements dominate, 152 to 61.

Local expansion with relevance models

Pseudo-relevance feedback answers the thesaurus's main weakness: it draws terms from documents that the query itself retrieved, so the sense of each word is fixed by the query's context. The pseudo-relevance feedback article measured a term-based version on top of BM25. Here is the version built into the language modeling approach.

The relevance model

Here is the idea in one sentence. If the query words and the words of relevant documents were drawn from the same unknown distribution, then the probability that a word is drawn along with the query words estimates its probability in the relevant documents. Lavrenko and Croft (2001) called the estimated distribution a relevance model, and estimated it with no relevance judgments at all.

The formal version. Let $q_1, \dots, q_k$ be the query words, and let $D$ range over a set $\mathcal{R}$ of document language models, in practice those of the top-ranked documents. Suppose a document model $D$ is picked, and the query words and one more word $w$ are drawn from it independently. Then

$$P(w, q_1, \dots, q_k) = \sum_{D \in \mathcal{R}} P(D)\, P(w \mid D) \prod_{i=1}^{k} P(q_i \mid D).$$

This is the first of the two estimation methods in Lavrenko and Croft's paper, which they call i.i.d. sampling; later work calls the resulting model RM1. Their second method, conditional sampling, draws each query word from a document model chosen given $w$. They found it more robust and used it in their own experiments. RM3 builds on the first method, which is the one used here. The product is the query likelihood $P(q \mid D)$. The relevance model is the conditional probability of $w$ given the query words, which takes three steps.

  1. The probability of the query words alone. Summing the joint probability over every word $w$ in the vocabulary, and using $\sum_w P(w \mid D) = 1$ for each document model, gives $P(q_1, \dots, q_k) = \sum_{D \in \mathcal{R}} P(D)\, P(q \mid D)$.
  2. Divide. $P(w \mid q_1, \dots, q_k) = \frac{P(w, q_1, \dots, q_k)}{P(q_1, \dots, q_k)} = \frac{\sum_{D} P(D)\, P(w \mid D)\, P(q \mid D)}{\sum_{D'} P(D')\, P(q \mid D')}$.
  3. Take the prior to be uniform. With $P(D) = 1/\lvert \mathcal{R} \rvert$ for every document, the prior cancels from the numerator and the denominator.

The relevance model is therefore

$$P(w \mid R) = \sum_{D \in \mathcal{R}} P(w \mid D)\, \frac{P(q \mid D)}{\sum_{D' \in \mathcal{R}} P(q \mid D')},$$

an average of the top documents' word distributions, each weighted by its share of the query likelihood (the form used by Abdul-Jaleel et al., 2004, eq. 2). The weights are positive and sum to 1, and each $P(\cdot \mid D)$ sums to 1 over the vocabulary, so $P(\cdot \mid R)$ is a probability distribution. A document that matches the query strongly contributes most of its vocabulary. The worked problems compute a relevance model in exact fractions for two short documents. The clarity score of Query Performance Prediction measures how far this distribution, estimated from all documents containing a query term, departs from the collection's, to predict how well the query will be answered.

The relevance model replaces the query entirely, so Lavrenko and Croft described it as "a massive query expansion technique." The variant called RM3 keeps the original query (Abdul-Jaleel et al., 2004, §3.1.4). It truncates the relevance model to its $m$ most probable words, renormalizes it, and mixes it with the query's own maximum likelihood model:

$$P(w \mid q') = \alpha\, P_{\mathrm{mle}}(w \mid q) + (1 - \alpha)\, P(w \mid R),$$

where $\alpha$ is the weight of the original query (Abdul-Jaleel et al. write $\lambda$ for the weight of the relevance model, so $\alpha = 1 - \lambda$). Documents are then ranked by $\sum_w P(w \mid q') \log P(w \mid d)$, which is query likelihood with the query's words replaced by a weighted distribution.

With $\alpha = 1$ the expanded model is the query's own, and the ranking is exactly that of query likelihood. The maximum likelihood model of a query of $n$ words gives word $w$ the probability $c(w, q)/n$, where $c(w, q)$ is the number of times $w$ occurs in the query. Then

$$\sum_w P_{\mathrm{mle}}(w \mid q) \log P(w \mid d) = \frac{1}{n}\sum_w c(w, q) \log P(w \mid d) = \frac{1}{n}\sum_{i=1}^{n} \log P(q_i \mid d) = \frac{1}{n} \log P(q \mid d),$$

because a word that occurs $c(w, q)$ times contributes its logarithm that many times to the sum over query positions. Dividing by the constant $n$ does not change the order of the documents. The script confirms it on Cranfield: among the documents that contain a query term, RM3 with $\alpha = 1$ returns the same top 100 as query likelihood for all 225 queries.

Query 185 and query 180

The runs below use Dirichlet smoothing with $\mu = 200$, the setting chosen on the development queries in language models for retrieval, 10 feedback documents, 10 relevance-model terms and $\alpha = 0.5$. For query 185, the relevance model's ten most probable words, with probabilities rounded to four decimals, are panel (0.0421), flutter (0.0277), were (0.0225), effect (0.0146), buckl (0.0145), studi (0.0117), experiment (0.0114), mach (0.0108), 3 (0.0103) and us (0.0102).

The relevance model returns the query's own terms near the top and reorders them: panel and flutter now outweigh experiment and studi, because the top documents use them far more. It also adds buckl (buckling, a related failure of thin panels) and generic words. The ten probabilities sum to 0.1757, so after truncation and renormalization panel holds $0.0421/0.1757 = 0.240$ of the relevance model. Each of the four query words has $1/4$ in the query's own model. After mixing, panel has $0.5 \times 0.25 + 0.5 \times 0.240 = 0.245$ and flutter 0.204, against 0.158 and 0.157 for studi and experiment. Average precision rises from 0.774 under query likelihood to 0.834.

For query 180, the relevance model's top words include h, height, equat, constant, orbit, perige and air, and average precision rises from 0.387 to 0.455. Here the local method finds orbit and perige the way the thesaurus did, but only because the query's top documents are about satellite orbits.

On all of Cranfield

Results on all 225 queries, against query likelihood ($\mu = 200$, MAP 0.284) and against BM25 (MAP 0.307):

Feedback documents Terms $m$ Original weight $\alpha$ MAP Improved / harmed vs. QL $p$ vs. BM25
10 10 0.5 0.330 152 / 61 < 0.001
10 20 0.5 0.333 165 / 50 < 0.001
5 10 0.5 0.331 155 / 60 < 0.001
10 10 0.7 0.321 163 / 49 0.019
10 10 0.3 0.323 139 / 77 0.054

Every setting improved on query likelihood by more than 0.035 ($p < 0.001$ in each case). The first setting, fixed in advance, takes query likelihood from below BM25 to above it, and above the 0.324 of term-based pseudo-relevance feedback in the pseudo-relevance feedback article. Chosen on the development queries ($m = 20$), RM3 reached 0.328 on the test queries, against 0.284 for query likelihood and 0.297 for BM25 ($p < 0.001$ for both). Unlike global expansion, the gain survives on held-out queries.

Example (a larger average gain is not a safe one). RM3 should not replace query likelihood for every query without caution. Even the best setting harmed 50 of the 225 queries, and the figure shows losses as large as 0.2 in average precision. The query drift described in the pseudo-relevance feedback article applies to relevance models as well: if the top documents are about the wrong subject, so is the relevance model. RM3's gains are larger on average, not free of risk.

Why local beat global here

Xu and Croft (1996) compared the two families and concluded that, although global analysis has some advantages, local analysis is generally more effective. Their global method was a phrase-based association thesaurus, and it was compared with the local methods on two TREC collections. The Cranfield results agree, and the traces suggest reasons:

  • Context. A global neighbor list is the same for every query. It cannot tell that model in a query about mathematical models is not the model of a wind tunnel. Local feedback draws from documents that already match the query as a whole.
  • Generality. Cosine over documents ranks frequent words highly, and the IDF correction helps only in part. A relevance model weights words by how strongly the top documents match the query, so words common to the best-matching documents win.
  • Redundancy. Global neighbors tend to co-occur with the query terms in documents already retrieved, as flutter and panel do.

The textbook's overall judgment is consistent with this: query expansion with thesauri "is less successful than relevance feedback, though it may be as good as pseudo relevance feedback" (§9.2.3). Here, on one small collection, an automatic thesaurus did worse than pseudo-relevance feedback. A manual, domain-specific thesaurus, which Cranfield lacks, might do better. Global methods keep real advantages. The textbook notes that thesaurus-based expansion needs no input from the user and is easier for a searcher to understand. It also needs no first retrieval.

Later methods

Two lines of later work kept the problem and changed the source of related words.

  • Word embeddings. Dense word vectors, such as those of word2vec, place words with similar contexts close together, which makes them a natural automatic thesaurus. Diaz, Mitra and Craswell (2016) found that embeddings trained globally underperform embeddings trained on documents related to the query's topic for query expansion. Their result repeats the local-versus-global finding with a newer kind of thesaurus.
  • Document expansion. Instead of adding words to the query, words can be added to documents when they are indexed. Nogueira, Yang, Lin and Cho (2019) trained a sequence-to-sequence model to predict queries that a document is likely to answer, and appended the predicted queries to the document before indexing it. The expansion is paid for once, at indexing time, rather than on every query.

In a conversation the missing words are often in earlier turns, and Rewriting Questions in a Conversation expands or rewrites a follow-up question with them. A language model can also write the added text: HyDE generates a hypothetical answer and averages its dense vector with the query's, which Retrieval in a Loop proves is score fusion of ordinary dense rankings, query expansion by generated text.

Worked problems

Problem 1 is an exercise from chapter 9 of the course text (Manning, Raghavan, and Schütze, 2008), answered in general and then on the four Arctic sentences used elsewhere in the course. Problems 2 and 3 are posed on the two-document collection of the course text's Example 12.3 and on this article's trace of query 185. The script tools/experiments/cranfield/qe_example.py checks every number.

Problem 1 (Exercise 9.7 of the course text). In the thesaurus construction $C = AA^{\mathsf{T}}$, suppose $A$ is Boolean. The course text says "a Boolean cooccurrence matrix"; we read it as the term-document incidence matrix of its §9.2.3: $A_{t,d} = 1$ if term $t$ occurs in document $d$ and 0 otherwise, with no normalization. Find what the entries of $C$ are.

Solution. By the definition of the product, $C_{u,v} = \sum_d A_{u,d} A_{v,d}$. Each summand is 1 when both $u$ and $v$ occur in document $d$ and 0 otherwise. So $C_{u,v}$ is the number of documents in which $u$ and $v$ both occur, and the diagonal entry $C_{u,u}$ is the number of documents containing $u$, its document frequency. $C$ is a matrix of co-occurrence counts.

For a check, take four terms of the Arctic sentences. Arctic occurs in sentences 1, 2 and 4; climat in 1, 2 and 3; seabird in 2 and 4; warm in 1 and 2. Then

$$A = \begin{pmatrix} 1 & 1 & 0 & 1 \\ 1 & 1 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ 1 & 1 & 0 & 0 \end{pmatrix}, \qquad C = AA^{\mathsf{T}} = \begin{pmatrix} 3 & 2 & 2 & 2 \\ 2 & 3 & 1 & 2 \\ 2 & 1 & 2 & 1 \\ 2 & 2 & 1 & 2 \end{pmatrix},$$

with rows and columns in the order arctic, climat, seabird, warm. The diagonal holds the document frequencies 3, 3, 2, 2. The entry for climat and seabird is 1, because only sentence 2 contains both.

Raw counts favor frequent terms: arctic co-occurs twice with each of the other three, and the counts cannot say which of them it resembles most. Normalizing each row to length 1 first, as the article does, turns the counts into cosines. Arctic and warm then score $\frac{2}{\sqrt{3}\sqrt{2}} = 0.816$, and arctic and climat $\frac{2}{\sqrt{3}\sqrt{3}} = 0.667$: warm occurs only where arctic does, so it is the closer neighbor although the raw counts are equal.

Problem 2 (a relevance model in exact fractions). A collection has two documents of eight words each: $d_1$ = xyzzy reports a profit but revenue is down and $d_2$ = quorus narrows quarter loss but revenue decreases further. Document models are smoothed with the collection model in equal parts, $P(w \mid d) = \tfrac12\,\frac{c(w, d)}{8} + \tfrac12\,\frac{c(w, \text{collection})}{16}$. For the query revenue down, compute the relevance model from both documents, and the RM3 query model with $m = 2$ and $\alpha = \tfrac12$.

Solution. Revenue occurs once in each document and twice in the collection, so $P(\text{revenue} \mid d_1) = P(\text{revenue} \mid d_2) = \tfrac12 \cdot \tfrac18 + \tfrac12 \cdot \tfrac{2}{16} = \tfrac18$. Down occurs once, in $d_1$: $P(\text{down} \mid d_1) = \tfrac12 \cdot \tfrac18 + \tfrac12 \cdot \tfrac1{16} = \tfrac{3}{32}$ and $P(\text{down} \mid d_2) = \tfrac12 \cdot 0 + \tfrac12 \cdot \tfrac1{16} = \tfrac1{32}$. The query likelihoods are

$$P(q \mid d_1) = \tfrac18 \cdot \tfrac{3}{32} = \tfrac{3}{256}, \qquad P(q \mid d_2) = \tfrac18 \cdot \tfrac{1}{32} = \tfrac{1}{256},$$

so the documents' weights are $\tfrac{3}{4}$ and $\tfrac14$. Every word falls into one of three cases:

Words $P(w \mid d_1)$ $P(w \mid d_2)$ $P(w \mid R) = \tfrac34 P(w \mid d_1) + \tfrac14 P(w \mid d_2)$
but, revenue (in both documents) $\tfrac18$ $\tfrac18$ $\tfrac18$
the six other words of $d_1$, down among them $\tfrac{3}{32}$ $\tfrac{1}{32}$ $\tfrac{9}{128} + \tfrac{1}{128} = \tfrac{5}{64}$
the six other words of $d_2$ $\tfrac{1}{32}$ $\tfrac{3}{32}$ $\tfrac{3}{128} + \tfrac{3}{128} = \tfrac{3}{64}$

The probabilities sum to $2 \cdot \tfrac18 + 6 \cdot \tfrac{5}{64} + 6 \cdot \tfrac{3}{64} = \tfrac{16 + 30 + 18}{64} = 1$, as they must. The two most probable words are but and revenue, with $\tfrac18$ each, which renormalize to $\tfrac12$ each. The query's own model gives revenue and down $\tfrac12$ each. Mixing with $\alpha = \tfrac12$:

$$P(\text{revenue} \mid q') = \tfrac12 \cdot \tfrac12 + \tfrac12 \cdot \tfrac12 = \tfrac12, \qquad P(\text{down} \mid q') = \tfrac12 \cdot \tfrac12 = \tfrac14, \qquad P(\text{but} \mid q') = \tfrac12 \cdot \tfrac12 = \tfrac14.$$

The expansion term is but, a word with no bearing on the query. It ranks first in the relevance model because it is in both documents, and a relevance model favors what the top documents have in common, whether or not that is their subject. Query 185's relevance model contains words of the same kind, were and us.

Problem 3 (the RM3 weights of query 185). The relevance model's ten most probable words for query 185 are listed above with their probabilities. Compute the weight of flutter, of experiment and of buckl in the RM3 query model with $\alpha = 0.5$.

Solution. The ten probabilities sum to 0.1757, so the truncated and renormalized relevance model gives flutter $0.0277/0.1757 = 0.158$, experiment $0.0114/0.1757 = 0.065$ and buckl $0.0145/0.1757 = 0.083$. The query has four distinct words, each with probability $0.25$ in its own model, and buckl is not one of them. Mixing:

  • flutter: $0.5 \times 0.25 + 0.5 \times 0.158 = 0.204$;
  • experiment: $0.5 \times 0.25 + 0.5 \times 0.065 = 0.157$;
  • buckl: $0.5 \times 0 + 0.5 \times 0.083 = 0.041$.

All of the expanded query's weights sum to 1: the four query words hold $0.245 + 0.204 + 0.158 + 0.157 = 0.764$ and the six added words the remaining 0.236. An added word such as buckl carries about a fifth of the weight of flutter, so the original query still dominates the ranking.

What we have learned

Query expansion adds words the searcher did not type, to reach documents that describe the same thing in other words. Global expansion takes them from a thesaurus. The one built from Cranfield's co-occurrences found orbit and perige for satellit, but also generic and wrong-sense neighbors, and on held-out queries it gained nothing over BM25. Local expansion with relevance models takes words from the query's own top documents, weighted by how well each matches. It raised query likelihood's MAP from 0.284 to 0.330 and kept its gain on held-out queries, while still harming about a quarter of the queries.

Every experiment in this unit, these included, has scored the Cranfield collection thousands of times. Implementing BM25 shows how BM25 is computed efficiently, and how far the formulas that different systems call "BM25" agree.

References

  • Abdul-Jaleel, N., Allan, J., Croft, W. B., Diaz, F., Larkey, L., Li, X., Smucker, M. D., and Wade, C. (2004). UMass at TREC 2004: Novelty and HARD. In Proceedings of TREC 2004. record · 2 pages
  • Diaz, F., Mitra, B., and Craswell, N. (2016). Query expansion with locally-trained word embeddings. In Proceedings of ACL 2016, 367–377. record
  • Jones, R., Rey, B., Madani, O., and Greiner, W. (2006). Generating query substitutions. In Proceedings of WWW 2006, 387–396. record · 2 pages
  • Lavrenko, V., and Croft, W. B. (2001). Relevance-based language models. In Proceedings of SIGIR 2001, 120–127. record · 3 pages
  • Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, chapters 9 and 12. Cambridge University Press. record · 102 pages
  • Nogueira, R., Yang, W., Lin, J., and Cho, K. (2019). Document expansion by query prediction. arXiv:1904.08375. record · 3 pages
  • Qiu, Y., and Frei, H.-P. (1993). Concept based query expansion. In Proceedings of SIGIR 1993, 160–169. record
  • Voorhees, E. M. (1994). Query expansion using lexical-semantic relations. In Proceedings of SIGIR 1994, 61–69. record
  • Xu, J., and Croft, W. B. (1996). Query expansion using local and global document analysis. In Proceedings of SIGIR 1996, 4–11. record · 2 pages

Reviewed: verified, 16 Nov 2026 · checked against sources, 23 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 9 revisions