Fields such as dates filter results exactly; zones are free-text parts such as title and body. Weighted zone scoring gives each zone a weight $g_i \in [0, 1]$, the weights summing to 1, and scores a document by $\sum_i g_i s_i$, where $s_i$ is 1 if the query matches zone $i$ under a Boolean condition. This ranks Boolean matches on at most $2^\ell$ levels for $\ell$ zones. The weights can be learned from relevance judgments by least squares. With two zones, the best title weight is the share of the zones' disagreements that the title gets right ($5/7$ on the article's ten examples). With more zones it is a regression through the origin, restricted to the allowed weights when the unrestricted fit goes negative.
A paper with retrieval in its title is very likely about retrieval. One that mentions retrieval once on page twelve may not be. A Boolean query cannot tell the two apart: both documents contain the word, so both match. Documents have structure, such as titles, authors, abstracts and dates. A query word found in the title can be made to count for more than the same word found in the body, and how much more can be learned from examples of relevance.
This article does both in two steps, following Manning, Raghavan, and Schütze (2008, §6.1). A retrieval system can let users search particular parts of a document, and it can score documents higher when the query matches more important parts. The second idea is weighted zone scoring: each part of a document gets a weight, and a document's score adds up the weights of the parts that match.
Here is the route. First we separate fields from zones and see how each is indexed. Then we score documents by their matching zones and trace the merge. Next we learn the zone weights from relevance judgments. Finally we see how zones combine with term weights, and solve three problems on the article's data. The article assumes the inverted index, and it ends with the first scoring function in the course whose parameters are learned from data.
Fields and parametric search
Many documents carry metadata: structured attributes such as author, title, publication date, language and format. Each attribute is a field with a limited set of values. Fields support parametric search, which restricts results by field values: articles by a particular author, published after 2020, in English. A digital library's advanced search form, with a box for each field, is the familiar interface.
A field is indexed separately from the text, in a structure suited to its values. Dates and numbers need range queries, so they are typically indexed in a search tree such as a B-tree. Such a tree can return every document dated between two values. A parametric query combined with a text query is evaluated as an intersection: the documents that satisfy the field conditions, intersected with those that match the text. This is the Boolean filtering that survives inside ranked search engines.
Fields hold short values. The parts of a document that hold free text are handled as zones.
Zones
Zones are like fields, except that their content is free text: a title, an abstract, a section heading, the body. A query can be restricted to a zone, for example retrieval in the title. Zones can be indexed in two ways:
- Separate dictionaries. Build a separate inverted index for each zone, or equivalently qualify each term with its zone in a single dictionary:
william.author,william.title,william.body, each with its own postings list. - Zones in the postings. Keep one dictionary entry per term and record, in each posting, which zones of the document contain the term:
william → 2.author, 2.title, 3.author, 4.title, ....
The second encoding keeps the dictionary small. It also puts all of a term's zone information for a document in one place. That is exactly what a scoring function needs when it combines evidence from several zones (Manning, Raghavan, and Schütze, 2008, §6.1).
Weighted zone scoring
Here is the idea in one sentence: give each zone a share of a total score of 1, and award a document the shares of the zones where the query matches.
The formal version. A document has $\ell$ zones, with weights $g_1, \dots, g_\ell$. Each weight lies between 0 and 1, and the weights sum to 1. For a query $q$ and document $d$, let $s_i$ be 1 if the query matches zone $i$ of $d$ and 0 otherwise. "Matches" is defined by some Boolean condition, for example that the zone contains all the query terms. The score is
$$\text{score}(d, q) = \sum_{i=1}^{\ell} g_i \, s_i.$$
The score lies between 0 and 1. It is 1 when the query matches every zone and 0 when it matches none. Because each $s_i$ is a Boolean match, the method is sometimes called ranked Boolean retrieval: it ranks the documents that a Boolean query retrieves.
Manning, Raghavan, and Schütze (2008, Example 6.1) use the example weights author 0.2, title 0.3 and body 0.5. With them, four documents would score:
| Document | Zones matching the query | Score |
|---|---|---|
| $d_1$ | title, body | 0.3 + 0.5 = 0.8 |
| $d_2$ | author | 0.2 |
| $d_3$ | body | 0.5 |
| $d_4$ | author, title, body | 0.2 + 0.3 + 0.5 = 1.0 |
The ranking is $d_4$, $d_1$, $d_3$, $d_2$. A match in the body counts for more than a match in the author field here only because the weights say so. Choosing the weights is the hard part, and we return to it below.
When a zone matches only if it contains all the query terms, the scores can be computed in one pass over the postings. Intersect the query terms' postings document by document, and add $g_i$ for every zone in which all the terms occur. This is a small extension of the merge algorithm when zones are encoded in the postings.
A traced example
Manning, Raghavan, and Schütze (2008, Figure 6.4) give this procedure as ZoneScore. Here it is applied to the two-word query william shakespeare, with the weights above. The postings record, for each document, the zones that contain the term:
| Term | Postings: document (zones) |
|---|---|
| william | 1 (author, title), 2 (author), 3 (title, body), 4 (body), 5 (author, body) |
| shakespeare | 1 (title, body), 2 (author, body), 3 (title, body), 5 (body), 6 (title) |
Example (document 1). Document 1 contains both words, each in two zones, and it scores only 0.3. The merge walks both lists in docID order and passes over documents 4 and 6, which appear in only one list. For each document in both lists, a zone matches when both terms occur in it:
| Document | Zones with william | Zones with shakespeare | Zones with both | Score |
|---|---|---|---|---|
| 1 | author, title | title, body | title | 0.3 |
| 2 | author | author, body | author | 0.2 |
| 3 | title, body | title, body | title, body | 0.3 + 0.5 = 0.8 |
| 5 | author, body | body | body | 0.5 |
The ranking is 3, 5, 1, 2. Document 1 has both words together only in the title, so it collects only the title's weight. Its william in the author field and its shakespeare in the body are separate pieces of evidence that this scoring ignores. Document 2 has both words in the author field, perhaps a book by an author named William Shakespeare, and gets the author weight.
Whether a match "in a zone" should require all the query terms, as here, or count the terms separately, is a design choice. The second option leads toward the term-weighted scores of the rest of this topic, and the second worked problem below scores the same postings that way. The weights 0.2, 0.3 and 0.5 were simply given. The next section derives them from data instead.
Learning the weights
Weights could be set by intuition, but they can also be learned from examples of relevance. This is a simple instance of machine-learned relevance, which the course meets again in learning to rank (Manning, Raghavan, and Schütze, 2008, §6.1.2).
Suppose there are two zones, title and body, so the score is
$$\text{score}(d, q) = g \cdot s_T(d, q) + (1 - g) \cdot s_B(d, q),$$
with a single weight $g$ to learn. Here $s_T$ and $s_B$ are the Boolean matches in the title and the body. The training data is a set of examples. Each consists of a query, a document, the two match values $s_T$ and $s_B$, and a human judgment $r$ that is 1 if the document is relevant to the query and 0 if not. A good $g$ makes the scores close to the judgments, so choose $g$ to minimize the total squared error
$$\varepsilon(g) = \sum_{\text{examples}} \big(r - \text{score}(d, q)\big)^2.$$
Deriving the optimal weight
Here is the plan of the derivation. Sort the examples by their pattern of matches, write the error of each pattern as a function of $g$, and find the lowest point of the resulting parabola.
Examples in which both zones match score $g + (1 - g) = 1$, and examples in which neither matches score 0. In both cases the score does not depend on $g$, so those examples do not affect the choice. Only two kinds of example matter:
- Title matches, body does not ($s_T = 1$, $s_B = 0$): the score is $g$. The error is $(1 - g)^2$ if the document is relevant and $g^2$ if it is not.
- Body matches, title does not ($s_T = 0$, $s_B = 1$): the score is $1 - g$. The error is $g^2$ if the document is relevant and $(1 - g)^2$ if it is not.
Let $n_{10r}$ and $n_{10n}$ count the relevant and nonrelevant examples of the first kind, and $n_{01r}$ and $n_{01n}$ those of the second. Grouping terms with the same error,
$$\varepsilon(g) = (n_{10r} + n_{01n})(1 - g)^2 + (n_{10n} + n_{01r})\, g^2 + \text{constant}.$$
The first group is the examples that would be scored perfectly by putting all the weight on the title. The second is those that would be scored perfectly by putting it all on the body. The error is a parabola in $g$, and the two groups pull its lowest point in opposite directions.
Setting the derivative to zero gives $-2(n_{10r} + n_{01n})(1 - g) + 2(n_{10n} + n_{01r})\, g = 0$. Collecting the terms in $g$ gives $(n_{10r} + n_{01n} + n_{10n} + n_{01r})\, g = n_{10r} + n_{01n}$, so
$$g = \frac{n_{10r} + n_{01n}}{n_{10r} + n_{10n} + n_{01r} + n_{01n}}.$$
The second derivative, $2(n_{10r} + n_{01n} + n_{10n} + n_{01r})$, is positive whenever there is at least one example in which the zones disagree. So this point is a minimum, not a maximum. It also lies between 0 and 1 automatically, since the numerator is part of the denominator. If the zones never disagree, the denominator is zero and the training data says nothing about $g$.
The formula can be read directly. The numerator counts the examples in which trusting the title gives the right answer: the title matched and the document was relevant, or only the body matched and the document was not. The denominator counts all examples in which the two zones disagree. The optimal weight on the title is the fraction of disagreements that the title gets right.
A worked example
Take ten training examples:
| $s_T$ | $s_B$ | Relevant? | Count |
|---|---|---|---|
| 1 | 1 | yes | 2 |
| 1 | 0 | yes | 2 |
| 1 | 0 | no | 1 |
| 0 | 1 | yes | 1 |
| 0 | 1 | no | 3 |
| 0 | 0 | no | 1 |
Here $n_{10r} = 2$, $n_{10n} = 1$, $n_{01r} = 1$, and $n_{01n} = 3$, so
$$g = \frac{2 + 3}{2 + 1 + 1 + 3} = \frac{5}{7} \approx 0.714.$$
Evaluating the error at several values of $g$ confirms the minimum:
| $g$ | 0 | 0.25 | 0.5 | 0.714 | 0.75 | 1 |
|---|---|---|---|---|---|---|
| $\varepsilon(g)$ | 5.000 | 2.938 | 1.750 | 1.429 | 1.438 | 2.000 |
In this training data, a title match is the more reliable signal, and the learned weight puts more than two-thirds of the score on it.
Here the constant is 0. The two examples in which both zones matched were relevant, and the one in which neither matched was not, so the score was exactly right for all three whatever $g$ is. With other data the constant can be positive, which raises the whole curve without moving its minimum.
Example (an eleventh example). Suppose an eleventh example arrives in which the title matches, the body does not, and the document is relevant. Then $g$ rises from $5/7$ to $6/8 = 0.750$. The new example is a disagreement that the title gets right, so it adds 1 to both the numerator and the denominator: $(5 + 1)/(7 + 1)$.
What the learned weight means
A common reading of $g$ is "how important the title is". The weight means something more specific, and the scores it produces show what. With $g = 5/7$, the scoring function gives four possible scores, one for each pattern of matches:
| Title matches | Body matches | Score | Fraction relevant in training |
|---|---|---|---|
| yes | yes | 1 | 2 of 2 |
| yes | no | $g \approx 0.714$ | 2 of 3, 0.667 |
| no | yes | $1 - g \approx 0.286$ | 1 of 4, 0.250 |
| no | no | 0 | 0 of 1 |
For any group of examples given the same score, squared error is minimized by setting that score to the group's fraction of relevant examples. Here is the proof. Let the group have $m$ examples, $k$ of them relevant, and write $p = k/m$. Giving every example the score $c$ costs $k(1 - c)^2 + (m - k)c^2$. Expanding, this is $mc^2 - 2kc + k = m(c - p)^2 + mp(1 - p)$, since $mp^2 + mp(1 - p) = mp = k$. The second term does not depend on $c$, and the first is zero only at $c = p$. For the title-only group ($k = 2$, $m = 3$) the minimum is at $2/3$, and for the body-only group ($k = 1$, $m = 4$) at $1/4$.
If the title-only and body-only scores could be chosen separately, least squares would therefore set them to 0.667 and 0.250, the last column. They cannot, because both depend on the single weight $g$. Title-only examples want $g = 0.667$, and body-only examples want $1 - g = 0.250$, that is, $g = 0.75$.
The learned weight is the compromise: the average of the two wishes, weighted by how many examples hold each, $(3 \times 0.667 + 4 \times 0.75) / 7 = 5/7$. This is the same formula as before, rewritten. It shows what the scores approximate: the probability that a document with a given pattern of matches is relevant.
The same result as a regression
Two zones gave a closed form. The method extends to three or more zones once the derivation is redone as a regression. Substitute $1 - g$ for the body weight and rearrange the error of one example:
$$r - \big(g\, s_T + (1 - g)\, s_B\big) = (r - s_B) - g\,(s_T - s_B).$$
With $x = s_T - s_B$ and $y = r - s_B$, this is $y - g x$. So minimizing the total squared error is fitting a straight line through the origin, $y = g x$, by least squares. The answer is the familiar $g = \sum x y / \sum x^2$.
Examples in which the zones agree have $x = 0$ and drop out. A title-only example has $x = 1$ and $y = r$, and a body-only example has $x = -1$ and $y = r - 1$. So $\sum xy = n_{10r} + n_{01n}$, and $\sum x^2$ is the number of disagreements, which is the formula again. In the worked example, $\sum xy = 5$ and $\sum x^2 = 7$.
Three zones
With author, title and body zones, the weights are $g_A$, $g_T$ and $g_B = 1 - g_A - g_T$. The same substitution gives
$$r - s_B = g_A (s_A - s_B) + g_T (s_T - s_B) + \text{error}.$$
This is a linear regression of $y = r - s_B$ on two variables, $x_1 = s_A - s_B$ and $x_2 = s_T - s_B$, again through the origin. Take twenty training examples:
| $s_A$ | $s_T$ | $s_B$ | Relevant? | Count |
|---|---|---|---|---|
| 1 | 1 | 1 | yes | 2 |
| 0 | 1 | 1 | yes | 3 |
| 0 | 1 | 0 | yes | 2 |
| 0 | 1 | 0 | no | 1 |
| 0 | 0 | 1 | yes | 2 |
| 0 | 0 | 1 | no | 4 |
| 1 | 0 | 0 | yes | 1 |
| 1 | 0 | 0 | no | 2 |
| 1 | 0 | 1 | no | 1 |
| 0 | 0 | 0 | no | 2 |
The least-squares weights solve the normal equations $\left(\sum \vec{x}\,\vec{x}^{\mathsf{T}}\right) \vec{g} = \sum y\, \vec{x}$, with sums taken over the examples with their counts. They come from setting to zero the two partial derivatives of $\sum (y - g_A x_1 - g_T x_2)^2$. The derivative with respect to $g_A$ is $-2\sum x_1 (y - g_A x_1 - g_T x_2)$, which vanishes when $g_A \sum x_1^2 + g_T \sum x_1 x_2 = \sum x_1 y$. The derivative with respect to $g_T$ gives $g_A \sum x_1 x_2 + g_T \sum x_2^2 = \sum x_2 y$ in the same way, with $x_2$ in the place of the leading $x_1$. The five sums are built row by row, each row multiplied by its count $n$:
| $s_A$ | $s_T$ | $s_B$ | $r$ | $n$ | $x_1$ | $x_2$ | $y$ | $n x_1^2$ | $n x_1 x_2$ | $n x_2^2$ | $n x_1 y$ | $n x_2 y$ |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 3 | −1 | 0 | 0 | 3 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 0 | 2 | 0 | 2 |
| 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 2 | −1 | −1 | 0 | 2 | 2 | 2 | 0 | 0 |
| 0 | 0 | 1 | 0 | 4 | −1 | −1 | −1 | 4 | 4 | 4 | 4 | 4 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 0 | 0 | 2 | 1 | 0 | 0 | 2 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 | 0 | −1 | −1 | 0 | 0 | 1 | 0 | 1 |
| 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Sum | 12 | 6 | 10 | 5 | 7 |
The column sums are the entries of the equations:
$$\begin{pmatrix} 12 & 6 \\ 6 & 10 \end{pmatrix} \begin{pmatrix} g_A \\ g_T \end{pmatrix} = \begin{pmatrix} 5 \\ 7 \end{pmatrix}.$$
The determinant is $12 \times 10 - 6 \times 6 = 84$. So $g_A = (5 \times 10 - 6 \times 7)/84 = 2/21 \approx 0.095$ and $g_T = (12 \times 7 - 6 \times 5)/84 = 9/14 \approx 0.643$, which leaves $g_B = 11/42 \approx 0.262$.
The total squared error is 3.024. The weights 0.2, 0.3 and 0.5 used earlier give 3.900, and equal thirds give 3.778. A search over a grid of all weight triples summing to 1, in steps of 0.005, finds the same minimum. In this data an author match is weak evidence of relevance: only one of the three examples in which just the author matched was relevant. The learned weights nearly ignore it.
Here the solution happened to fall inside the allowed region, with every weight between 0 and 1. With other data, unconstrained least squares can return a negative weight, and the weights must then be found by least squares subject to the constraints.
Example (a negative weight). For the thirteen examples below, unconstrained least squares gives the author zone the weight $-1/27$, and the best allowed weights are author 0, title 0.8 and body 0.2.
| $s_A$ | $s_T$ | $s_B$ | Relevant? | Count |
|---|---|---|---|---|
| 1 | 0 | 0 | no | 3 |
| 0 | 1 | 0 | yes | 3 |
| 0 | 1 | 0 | no | 1 |
| 0 | 0 | 1 | yes | 1 |
| 0 | 0 | 1 | no | 2 |
| 1 | 0 | 1 | no | 2 |
| 1 | 1 | 0 | yes | 1 |
Building the sums as in the table above gives the normal equations $7 g_A + 4 g_T = 3$ and $4 g_A + 10 g_T = 8$. The determinant is $70 - 16 = 54$, so $g_A = (30 - 32)/54 = -1/27$ and $g_T = (56 - 12)/54 = 22/27$, which leaves $g_B = 6/27$. The error there is $43/27 \approx 1.593$. An author match is never followed by relevance in this data unless the title matches too, so the fit pushes the author weight below zero.
A negative weight is not allowed, so the minimum must be found inside the triangle $g_A \ge 0$, $g_T \ge 0$, $g_A + g_T \le 1$. The error is a convex function of $(g_A, g_T)$, being a sum of squares of linear expressions. Its unconstrained minimum $\vec{g}^*$ is unique, since the determinant is not zero, and lies outside the triangle. So the minimum over the triangle lies on the boundary. Suppose instead it were at an interior point $\vec{z}$. Then $\varepsilon(\vec{g}^*) < \varepsilon(\vec{z})$, and for $0 < t \le 1$ convexity gives
$$\varepsilon\big(\vec{z} + t(\vec{g}^* - \vec{z})\big) \le (1 - t)\,\varepsilon(\vec{z}) + t\,\varepsilon(\vec{g}^*) < \varepsilon(\vec{z}).$$
For small $t$ the point $\vec{z} + t(\vec{g}^* - \vec{z})$ is still inside the triangle and has a smaller error, a contradiction. Each edge of the triangle sets one weight to zero and leaves a two-zone problem, which the closed form solves:
| Edge | Best weights (author, title, body) | Error |
|---|---|---|
| author weight 0 | 0, 4/5, 1/5 | 8/5 = 1.600 |
| title weight 0 | 3/7, 0, 4/7 | 47/7 ≈ 6.714 |
| body weight 0 | 1/9, 8/9, 0 | 17/9 ≈ 1.889 |
On the first edge, for instance, the author column is ignored and only title and body remain. The title then matches alone in five examples, four of them relevant (rows 2, 3 and 7), and the body matches alone in five, one of them relevant (rows 4, 5 and 6). The closed form gives $g_T = (n_{10r} + n_{01n})/10 = (4 + 4)/10 = 4/5$. No example has both of these zones matching, and the three examples with neither (row 1) are not relevant, so the constant is 0 and the error is $8(1 - g_T)^2 + 2g_T^2 = 8/25 + 32/25 = 8/5$.
With the title weight zero, only author and body remain. The author matches alone in four examples, one of them relevant (rows 1 and 7), and the body alone in three, one relevant (rows 4 and 5), so $g_A = (1 + 2)/7 = 3/7$. The constant is 5: rows 2 and 3 match neither zone and three of their four examples are relevant, and the two examples of row 6 match both and are not relevant. The error is $3(1 - g_A)^2 + 4g_A^2 + 5 = 12/7 + 5 = 47/7$.
With the body weight zero, the author matches alone in five examples, none relevant (rows 1 and 6), and the title alone in four, three relevant (rows 2 and 3), so $g_A = (0 + 1)/9 = 1/9$. Row 7 matches both and is relevant, an error of 0, and rows 4 and 5 match neither, with one of their three examples relevant, an error of 1. The error is $(1 - g_A)^2 + 8g_A^2 + 1 = 8/9 + 1 = 17/9$.
The smallest of the three errors is 1.600, on the edge where the author weight is zero. A search over a grid of all allowed weight triples, in steps of 0.005, finds the same minimum. The constrained error, 1.600, is only slightly above the unconstrained 1.593.
The approach generalizes further. With features that are not Boolean, such as a TF-IDF score per zone, the same regression applies unchanged. Replacing the squared error with measures closer to ranking quality, and the linear combination with richer models, leads to modern learned ranking functions. Their inputs keep the zones: the LETOR benchmark computes each of its term frequency, IDF, BM25 and language model features separately for streams such as the title, the body and the anchor text (features for ranking).
Zones in ranked models
Weighted zone scoring uses only whether each zone matches. The rest of this topic develops scores based on how often each term occurs and how informative it is, beginning with TF-IDF. The two ideas combine naturally, in two ways:
- Score each zone, then combine. Compute a TF-IDF score per zone and add the zone scores with weights.
- Combine the counts, then score. As in BM25F (Robertson, Zaragoza, and Taylor, 2004), weight and sum the term frequencies from different zones before computing a single score.
Web search engines weight the title and the anchor text of incoming links separately from the body (see how a web search engine answers a query). Enterprise and product search engines commonly weight titles and other fields.
Worked problems
The three problems are posed on this article's own data: its weights, its postings for william shakespeare, and a new set of judged examples. Their numbers are computed by tools/experiments/vsm/zones.py.
Problem 1 (every possible score). With the weights author 0.2, title 0.3 and body 0.5, find every score a document can receive, and the patterns of matching zones that produce each.
Solution. There are seven distinct scores from the eight patterns. Each zone either matches or not, so there are $2^3 = 8$ patterns, and the score of a pattern is the sum of the weights of its matching zones:
| Matching zones | Score |
|---|---|
| none | 0 |
| author | 0.2 |
| title | 0.3 |
| body | 0.5 |
| author, title | 0.2 + 0.3 = 0.5 |
| author, body | 0.2 + 0.5 = 0.7 |
| title, body | 0.3 + 0.5 = 0.8 |
| author, title, body | 1.0 |
The values are 0, 0.2, 0.3, 0.5, 0.7, 0.8 and 1.0. The score 0.5 arises twice: a match in the body alone ties with a match in both the author and the title, because $0.2 + 0.3 = 0.5$. Weighted zone scoring can rank at most $2^\ell$ levels for $\ell$ zones, and fewer when sums of weights coincide.
Problem 2 (a looser match). Score the postings of the traced example for william shakespeare again, with the same weights, when a zone matches if it contains at least one of the two terms. Rank the documents.
Solution. The ranking is 1, 3, then 2 and 5 tied, then 4, then 6. Under this rule a document needs only one of the terms, so all six documents in either list are scored, and a document's matching zones are the union of the zones recorded in its two postings:
| Document | Zones with william | Zones with shakespeare | Zones with either | Score |
|---|---|---|---|---|
| 1 | author, title | title, body | author, title, body | 1.0 |
| 2 | author | author, body | author, body | 0.7 |
| 3 | title, body | title, body | title, body | 0.8 |
| 4 | body | none | body | 0.5 |
| 5 | author, body | body | author, body | 0.7 |
| 6 | none | title | title | 0.3 |
Document 1, which scored 0.3 when both terms had to share a zone, now has the maximum score, since between them its two terms cover every zone. The merge is a union of the two lists and no longer an intersection. Requiring every term in a zone made documents 4 and 6 unscored; the looser rule ranks them last.
Problem 3 (learning one weight). Fifteen judged examples have these patterns. Find the title weight $g$ that minimizes the squared error, and the error there, at $g = 0$, at $g = 1/2$ and at $g = 1$.
| $s_T$ | $s_B$ | Relevant? | Count |
|---|---|---|---|
| 1 | 1 | yes | 3 |
| 1 | 1 | no | 1 |
| 1 | 0 | yes | 1 |
| 1 | 0 | no | 3 |
| 0 | 1 | yes | 4 |
| 0 | 1 | no | 1 |
| 0 | 0 | no | 2 |
Solution. The best weight is $g = 2/9 \approx 0.222$, with error $23/9 \approx 2.556$. The counts of the disagreements are $n_{10r} = 1$, $n_{10n} = 3$, $n_{01r} = 4$ and $n_{01n} = 1$, so
$$g = \frac{n_{10r} + n_{01n}}{n_{10r} + n_{10n} + n_{01r} + n_{01n}} = \frac{1 + 1}{9} = \frac{2}{9}.$$
The error is $\varepsilon(g) = (n_{10r} + n_{01n})(1 - g)^2 + (n_{10n} + n_{01r})\,g^2 + \text{constant} = 2(1 - g)^2 + 7g^2 + 1$. The constant is 1, from the one example in which both zones matched and the document was not relevant: its score is 1 whatever $g$ is, so its error is always 1. The three relevant examples with both zones matching and the two nonrelevant ones with neither contribute 0. Then:
| $g$ | $2(1 - g)^2$ | $7g^2$ | $\varepsilon(g)$ |
|---|---|---|---|
| 0 | 2 | 0 | 3 |
| 2/9 | 98/81 | 28/81 | 23/9 ≈ 2.556 |
| 1/2 | 1/2 | 7/4 | 13/4 = 3.25 |
| 1 | 0 | 7 | 8 |
At $g = 2/9$ the first two terms add to $126/81 = 14/9$, and $14/9 + 1 = 23/9$. In this data the body is the more reliable zone: it is right in 7 of the 9 disagreements, so the title receives the remaining $2/9$ of the weight. The regression form gives the same value, $\sum xy / \sum x^2 = 2/9$.
What we have learned
Fields support exact filtering, and zones let a score reward matches in the parts of a document that matter most. Weighted zone scoring adds the weights of the matching zones. With two zones, the best title weight is the fraction of disagreements the title gets right; with more, it is a least-squares regression, restricted to the triangle of allowed weights when the unrestricted answer falls outside it.
Every match here is still all or nothing. A document that says insurance five times scores the same as one that says it once, and a match on a common word counts as much as one on a rare word. The next article, TF-IDF Weighting, brings a term's count and its rarity into the score.
The worked examples are computed by tools/experiments/vsm/zones.py in the site repository, and the figure by tools/figures/zones-and-weighted-zone-scoring.py.
References
- Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, section 6.1. Cambridge University Press. record · 102 pages
- Robertson, S., Zaragoza, H., and Taylor, M. (2004). Simple BM25 extension to multiple weighted fields. In Proceedings of CIKM 2004, 42–49. record · 3 pages
Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 10 revisions