Skip to main content
Information Retrieval

IR Models: Boolean, Vector, and Probabilistic Retrieval

Published: 2026-09-13
Level: undergraduate
Audience: Undergraduate students studying Information Retrieval

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • Logical views and text preprocessing — covered in Lecture 1 (From Raw Document to Ranked Output)
  • Term weights with TF-IDF — covered in Lecture 1 (From Raw Document to Ranked Output)
  • Cosine similarity and ranking — covered in Lecture 1 (From Raw Document to Ranked Output)
  • Boolean and vector models at a glance — covered in Lecture 1 (What Information Retrieval Is)

2.1 How IR Models Arise: Index Terms, Premises, and Term Weights

2.1.1 Index terms and the premises behind ranking

Why do three smart systems rank the same documents in three different orders? The answer is that each one starts from a different bet about what ranking means.

Traditional information retrieval starts from index terms, which are the cleaned vocabulary units that survive preprocessing. An index term (a word or word-like token kept for indexing, written for the -th vocabulary term) becomes the bridge between a document and a query. Two preprocessing steps produce these terms. Stemming (crude suffix chopping, such as mapping running to run) strips endings with rules. Lemmatization (full morphological analysis that maps each word to its dictionary base form, its lemma) uses vocabulary knowledge to return the true base form. The session names stemming plus a second step sounding like limitization; the reference text confirms the pair is stemming and lemmatization, where the lemmatizer does full morphological analysis to identify the lemma for each word while the stemmer applies language-specific suffix rules with less knowledge.

These index terms label each document, and retrieval then ranks documents against a user query. The ranking always rests on a fundamental premise, and each distinct premise gives rise to a distinct IR model. Three premises shape the three classical models. The first premise says documents can share a common set of index terms, with presence or absence deciding membership. That premise leads to the Boolean model. The second premise says documents can share weighted terms, where each term carries a weight that records how telling it is. That premise leads to the vector space model. The third premise says documents can carry a likelihood of relevance, a probability that the document serves the query. That premise leads to the probabilistic model.

A quick recap anchors the session. Earlier ground covered preprocessing and stemming, retrospective versus prospective retrieval, how IR differs from data retrieval, the logical view of documents, and the IR process flow diagram. Retrieval, unlike browsing, always includes ranking. Within retrieval, the retrospective style, also called ad hoc retrieval, returns a ranked list of relevant documents for a one-off query. The prospective style, also called filtering, keeps responding as data and user queries change over time. A person who searches once for Chandrayaan-3 photos uses retrospective retrieval. A person who sets an alert for every new paper on Chandrayaan-3 uses prospective filtering.

An index term (a kept vocabulary unit used to label documents, written ) is the atom of all three classical models. A premise (the core bet about what makes a document relevant) picks the model. Shared set membership gives Boolean logic. Shared weighted terms give vector angles. Likelihood of relevance gives probabilistic ranking.

Picture a spice shelf as an everyday analogy. Each jar label is an index term. The Boolean cook asks only whether the jar is on the shelf or not. The vector cook weighs how much of each spice each dish needs. The probabilistic cook asks how likely each dish is to please the guest. The mapping is direct: jar presence maps to the Boolean bit, spoonful size maps to the term weight, and chance of pleasing maps to the relevance probability. The analogy breaks where cooking stops: spices blend in fixed dishes, while index terms interact with queries that change every time.

2.1.2 From noun-only indexing to full-text indexing

The earliest traditional systems indexed only nouns. The reason given was that nouns carry independent meaning, so a noun-only index looked like a compact record of what each document is about. A document about the Moon mission would then be filed under Moon and mission, while verbs such as launched and small words such as on were dropped.

That choice misses real signal, because the rest of the words also carry weight. Verbs separate launch from landing. Adjectives separate crewed from robotic. Names such as Chandrayaan-3 separate one mission from all others. Modern practice moved on to full-text representation, where every surviving word becomes an index term rather than a hand-picked set of important words. Stop-word removal still drops the least telling tokens, and stemming plus lemmatization still merge variants, but no word class is barred at the door.

Classical models in this session (Boolean, vector, probabilistic) sit on top of that full-text idea: they consider all index terms, and then they go one step further by asking whether every term deserves the same say. The Boolean model keeps the full text but gives each term one vote. The vector model keeps the full text and weights each vote. The probabilistic model keeps the full text and asks how each vote shifts the odds of relevance.

2.1.3 Rare terms deserve extra weight

Not all index terms matter equally. Take the sentence "India launched Chandrayaan-3 on the Moon." Its index terms include India, launched, Chandrayaan-3, on, and Moon. The term India appears in thousands of documents, so it says little about which document is wanted. The term Chandrayaan-3 is rare and highly informative, so it should count for more when documents are ranked.

A term weight (how telling one index term is inside one document) turns raw presence into graded evidence. Let be the -th vocabulary term, let be the -th document, and let be the weight of index term in document . Then:

Here runs over the vocabulary, , and runs over the collection. A large means the term points strongly at the document. A small means the term is common and weak. The term weight of an index term in a document is the single number that lets rare terms outvote common ones.

Worked mini-example: why Chandrayaan-3 outvotes India. Suppose a collection holds documents. The word India occurs in 4,000 of them. The word Chandrayaan-3 occurs in 12 of them. A plain inverse-document-frequency weight reads , where is the number of documents holding term . Then while (base 10). The rare term scores about seven times higher. Sense-check: the numbers agree with intuition, since a term found in only 12 documents narrows the hunt far more than one found in 4,000.

This single idea, nouns first, then all terms, then weighted terms, motivates the whole move from early practice into the three classical models. The session states the weight verbally as the weight associated with the term in the document , and the display above records that phrasing in symbols.

Scope: Term weights help only when term statistics mirror meaning. Assumption: terms occur independently enough that counting them one by one is fair, and the collection is fixed while weights are computed. When the collection drifts every second, or when meaning lives in phrases rather than single words, raw weights understate the truth and later models must take over.

Imagine a plot with term rarity on the horizontal axis and weight on the vertical axis. Common words such as on sit near the left with near-zero height. Mid words such as launched rise modestly. Rare names such as Chandrayaan-3 spike high on the right. The curve climbs steeply then flattens on a log scale. The takeaway in one line: rarity buys height, and the log keeps one freak term from buying the whole chart.

Two traps catch beginners here. One trap is treating every surviving word as equal, which hands common words the same vote as rare names and buries the best match. A second trap is reading the weight as a fact about the word alone, when it is always a fact about the word inside one document inside one collection: move the same document to a new collection and its weights shift.

2.1.4 Student Questions and Answers

Q: IR means ranking relevant information, but on shopping and marketing sites a seller who pays for premium membership jumps to the top whenever a keyword matches. Is that ranking still unbiased IR, or does the paid premium membership drive the match we see on these shopping sites?

A: The paid layer sits on top of information retrieval rather than inside it. IR supplies the match-based ranking of relevant items, and the marketplace adds a promotion layer above that core. The promotion layer above the marketplace membership match-based ranking reorders or annotates results for business reasons. Real-world products are clubs of many components, and IR is the building block inside them. Search engines keep the sponsored placement separate from the relevance ranking, and the exact mechanics of any one commercial site were left as something to check and report back on.

Real-world: paid placement and premium membership boosts on shopping sites sit above the IR match layer instead of replacing it. The same split appears in web search, where sponsored links sit apart from organic ranked results.

Recap: index terms label documents, three premises split IR into Boolean, vector, and probabilistic models, and rare terms earn larger weights. Bridge: the next step tests the simplest premise first, exact Boolean match, and shows why presence bits alone cannot rank.

Exam note: be ready to define an index term, name the three premises with their models, and explain with the India versus Chandrayaan-3 contrast why rare terms get larger weights.

2.2 The Boolean Model: Exact Match With Logic Operators

2.2.1 Mathematical Formulation

What if retrieval behaved like a bouncer with a guest list: you are in only when your name plus your logic check out exactly?

The Boolean model treats retrieval as logic plus set theory. Documents and queries meet through three operators: AND, OR, and NOT. The session states them as truth tables over presence bits, where 1 means a term is present and 0 means it is absent. AND returns 1 only when both bits are 1:

OR returns 0 only when both bits are 0, and 1 in every other case:

NOT negates its input:

Here and are presence bits for two index terms in one document. The symbol (logical AND) means intersection of document sets. The symbol (logical OR) means union of document sets. The symbol (logical NOT) means the complement within the collection, the disjoint remainder left after removing the term set.

Boolean operators with intersection union truth tables decide retrieval by set membership. AND keeps the intersection of the two document sets. OR keeps the union. NOT keeps the complement. A document either satisfies the logical expression or it does not. No score, no partial credit, and no ordering among the documents that satisfy it.

In set language, AND is intersection of document sets, OR is union, and NOT is the complement. A query such as India AND Moon is the set of documents holding both terms. India OR Moon is the set holding either term. India AND NOT Moon is the set holding India minus the set holding Moon. The model views each document as just a set of words, and each query as a Boolean expression of terms.

Think of airport security trays as an analogy. Each tray is a document. Each required item, laptop out and liquids out, is a term. AND means every required item must be present. OR means at least one suffices. NOT means the banned item must be absent. The mapping is exact: tray contents map to presence bits, and the gate decision maps to retrieval. The analogy breaks where travel stops: trays hold a handful of items, while documents hold thousands of terms whose absence is the norm rather than a red flag.

2.2.2 Worked Examples

Worked example: India AND Moon, launch versus festival. Consider the user query "India AND Moon." The model keeps only documents that contain both words. Suppose document one describes launching a satellite to the Moon from India, with details on what to buy, what to arrange, and how the launch works. Its presence bits are India = 1 and Moon = 1, so and the document is retrieved. Suppose document two describes Indian festivals tied to Moon cycles, with festivals fixed by the presence or absence of the Moon. Its bits are also India = 1 and Moon = 1, so and it is retrieved as well. Both the launch document and the festival document are retrieved, with no ordering between them. Sense-check: the India Moon launch festival Boolean retrieval comparison shows the core limit, since two very different needs look identical as two presence bits both on.

Now change the query to "India OR Moon." The model widens the net to every document holding either word. A document with only India scores . A document with only Moon scores . A document with neither scores and is dropped. The result set grows, and the burden of discarding the wrong ones moves to whoever consumes the retrieval output.

A bare two-word query such as "AI healthcare," with no operator at all, needs a decision: read it as one phrase, as an AND, or as an OR. A Boolean engine needs an explicit operator, so the bare form is ambiguous. Lenient engines widen toward union-like behavior and return more, leaving the user to keep or discard results. Imprecise queries return more, and the user does the filtering.

Picture a Venn diagram with India as the left circle and Moon as the right circle. The overlap lens is the AND set. The full inked area of both circles is the OR set. Everything outside Moon is the NOT Moon set. Landmarks are the lens center (both terms, kept by AND), the lone crescents (one term, kept only by OR), and the outside white field (neither term, dropped by both). The takeaway in one line: logic draws hard borders, and nothing ranks the survivors inside each border.

2.2.3 Why exact match hurts

The strengths are real: the model is simple, easy to build, easy to read, and intuitive. A query means exactly what its logic says. That is why it stayed dominant in demanding database setups, including legal search, for more than 30 years. When a lawyer must find every document with a given clause and no near-miss is acceptable, exact sets are the right contract.

Exact match buys precision of meaning but pays with four blind spots. Synonyms stay invisible, frequency stays invisible, common-term queries overshoot without ranking, and rare-term queries undershoot without rescue.

But four drawbacks follow from presence-or-absence thinking.

First, synonyms are invisible. A query for "salt" never meets a document that writes only "NaCl" or "sodium chloride," because the index term "salt" never occurs there. The salt synonym gap is structural: matching is literal, so no semantic link joins the variants.

Second, frequency is invisible. A document that explains salt making and repeats the word about 500 times ranks no higher than a recipe document that mentions salt 5 times. Both carry the bit 1. The 500 frequency mentions versus 5 frequency mentions change nothing in the model.

Third, the model overshoots. A query like "salt AND sugar" can pull hundreds of documents with no way to order them. Every document with both bits on is equally retrieved.

Fourth, the model undershoots. A rare query such as "Chandrayaan-3" alone, or "Chandrayaan-3 AND Pragyan" (the rover), may return very few documents. When the bits are off, no partial credit saves the near miss.

Scope: Boolean logic fits when the information need is itself logical, such as compliance, legal discovery, or catalog lookup. Assumption: terms are unambiguous and the user can state the exact logic. When needs are vague, graded, or synonym-rich, the premise fails and ranked models must take over.

Beginners often expect AND to mean more results, since and sounds additive in daily speech. In retrieval AND narrows because intersection shrinks. A second trap is expecting frequency to help: repeating salt 500 times feels stronger, but the bit stays 1. A third trap is trusting overshoot lists as ranked, when their order carries no meaning.

Exam note: expect to contrast overshoot on common-term AND queries with undershoot on rare-term queries, since that pair shows both failure directions of unranked retrieval.

2.2.4 Student Questions and Answers

Q: With tokens T1, T2, and T3, does the Boolean model try every permutation such as T1 AND T2, or T2 AND T3? Does one Boolean permutation or combination expression run them all?

A: What is written is what runs. An AND query over all three tokens keeps only documents with all three. An OR query keeps documents with any of them. Each written combination is its own expression, and the written combination expression operator session rules decide the set: AND narrows to the intersection, OR widens to the union. A full later session works through the Boolean model operator by operator.

Real-world: legal databases and patent search still run Boolean cores because every returned item must provably satisfy the stated logic.

Recap: Boolean operators read presence bits as intersection, union, and complement, which makes queries exact but unranked. Bridge: the next step weighs the bits so that launch and festival documents stop looking identical, which is the vector space idea.

2.3 The Vector Space Model: Weights, Angles, and Ranking

2.3.1 Mathematical Formulation

What if documents were arrows in space, and relevance was simply the angle between arrows?

The vector space model turns documents and the query into vectors over the same vocabulary, then measures how close each document vector sits to the query vector. Closeness is read as relevance, and sorting by closeness gives the ranking that the Boolean model lacks. The session builds the idea from a toy collection and names cosine similarity as the textbook measure. Its verbal definition is the ratio of dot product to the magnitude product, built here step by step. Let the document vector be and the query vector be . Let be the vocabulary size. Then cosine similarity as dot product over magnitudes reads:

Here (theta) is the angle between the query and document arrows. (the dot product) measures alignment. and (the Euclidean lengths) normalize for size.

The dot product in the numerator is:

where is the -th entry of the query vector, is the -th entry of the document vector, and is the vocabulary size. Each magnitude in the denominator is:

The numerator measures how the two vectors line up, and the denominator normalizes them so that a long document cannot outscore a short one on length alone. Length normalization converts each raw vector into a unit arrow, so only direction counts.

Cosine similarity as dot product over magnitudes turns ranking into geometry. A vector (an ordered list of term weights, one entry per vocabulary term) points in some direction. A dot product (how much two arrows agree, summed entry by entry) grows with alignment. Dividing by the two magnitudes leaves the cosine of the angle, a pure direction score.

The session states the output range as zero to one. For count-based vectors with no negative entries that range holds: identical vectors give , orthogonal vectors at 90 degrees give , and anything between marks partial similarity such as 0.9 (near duplicate direction), 0.8, 0.6, or 0.3 (weak overlap). A smaller angle means a larger cosine and a more similar document. The range claim needs its qualifier: with general weights that allow negatives, cosine spans minus one to one, but term counts and TF-IDF weights are never negative, so the zero-to-one reading is safe here.

Think of two shopping lists as an analogy. Each list is a vector over the store inventory. The dot product counts how much the two lists agree item by item. Dividing by list lengths stops the family-size list from always beating the single-person list. The mapping is direct: items map to terms, quantities map to weights, and list direction maps to topic. The analogy breaks where pantries stop: shopping lists never hold 50,000 mostly-zero entries, while document vectors do.

2.3.2 Worked Examples

Worked example: document term matrix with query vector ranking. Take the query "India Moon" with three tiny documents: document one holds "India Moon mission," document two holds "India economy," and document three holds "Moon surface." Intuition says document one should come first, since it covers both query words. A strict Boolean AND over the two words would keep only document one, so a looser engine that also admits single-term matches needs ranking to put document one on top.

Preprocessing lowercases everything ("India" becomes "india") and treats every surviving word as a term, with no special preference for nouns. The vocabulary is T1 = india, T2 = moon, T3 = mission, T4 = economy, T5 = surface. The document-term matrix uses documents as rows and terms as columns. Document one contains india once, moon once, mission once, and neither economy nor surface, giving:

Document two gives:

Document three gives:

The query becomes:

Each row is a term vector, and unstructured text has become structured data. Now score with cosine similarity. For document one, , , , so . For document two, , , so . For document three, with the same lengths, so . Document one ranks first at about 0.82, ahead of the tied pair at 0.50. Sense-check: the document term matrix with query vector ranking puts the two-term cover first, exactly as intuition demands.

Worked example: cosine zero angle correction on identical vectors. A classroom slip sharpens the cosine reading. When identical vectors were drawn on top of each other with angle zero, the value was first misspoken as zero and then corrected on the spot: the cosine zero angle correction on identical vectors gives maximum similarity, since , while marks totally dissimilar vectors. Take twice: , , so . Identical direction scores 1, the ceiling. Sense-check: zero angle means full match, so the number must be one rather than zero, and the correction ties the geometry to the numbers.

2.3.3 Term weights and TF-IDF

Raw counts already improve on bits: if "india" occurred twice in document one, its entry would read 2 rather than 1, and frequency would shape the score. Term weights push this further. Each term gets an importance weight, rare terms get larger weights than common ones, and the vectors compared by cosine similarity become weighted vectors. The session names TF-IDF as the weighting of choice and notes that most listeners already know it: TF-IDF builds the weighted vector, and cosine similarity reads the angle between weighted vectors.

TF-IDF (term frequency times inverse document frequency, written ) multiplies what happens inside one document by how rare the term is across the collection. Let be the count of term in document . Let be the number of documents holding . Let be the collection size. Then the base inverse document frequency is:

and the base weight is:

A large means the term matters here. A large means the term is rare elsewhere. Their product rewards terms that are frequent here but rare elsewhere.

Newer practice refines the weights with sublinear term frequency and smoothed inverse document frequency. Sublinear term frequency with smoothed inverse document frequency dampens runaway counts and avoids edge cases. The sublinear form replaces the raw count by its log:

The reference text confirms this exact form: twenty occurrences should not carry twenty times the weight of one, so the log compresses the scale. The smoothed inverse document frequency adds one inside the log:

The base form in the reference is . The smoothed form keeps the same spirit while avoiding a zero weight when a term appears in every document ( gives in the base form, but after smoothing) and softening divisions by small counts. The session named sublinear tf scaling and smooth idf without stating exact forms; the displays above give the standard forms consistent with the reference, with base-10 or natural logs both acceptable since the base does not change the ranking order.

Contextual embeddings from BERT-style models then carry the idea further by weighting and placing terms with context. The session audio garbles the name as bird models; the intended reference is BERT, the transformer encoder whose token vectors shift with surrounding words. Where TF-IDF gives one fixed weight per term per document, BERT gives a context-sensitive placement, so bank near river and bank near money land in different spots.

Other closeness measures are allowed. Euclidean, Manhattan, Mahalanobis-distance, and correlation measures can all compare two vectors; the textbook path simply uses cosine. The guidance given is practical: any proximity measure that fits the data and surfaces similar vectors is acceptable. Distance reads how far apart the endpoints sit, while cosine reads the angle regardless of length.

Scope: cosine ranking fits when topic direction matters more than document length. Assumption: term axes are independent, weights are non-negative, and the query plus documents share one vocabulary. When vocabularies mismatch, when order decides meaning, or when weights turn negative, the angle loses its plain reading.

Picture unit arrows fanning from one origin. The query arrow points northeast. Document one lies almost on top of it with a sliver of a gap, near 35 degrees, cosine near 0.82. Documents two and three splay out at 60 degrees each, cosine 0.50. The horizontal axis is the india direction, the vertical axis is the moon direction, and landmarks are the 0-degree ray (score 1) and the 90-degree ray (score 0). The takeaway in one line: tighter fan means higher score.

Three traps recur. One trap is reading a larger distance as more similar, when larger distance means less similar. A second trap is forgetting length normalization and letting long documents win on bulk. A third trap is trusting the dog bites man versus man bites dog tie: the dog bites man word order case shows independent tokens vanish as order cues, since both sentences share the same tokens dog, bites, and man and look identical as vectors.

2.3.4 Student Questions and Answers

Q: When I build a knowledge agent over a shared drive full of documentation and ask it a plain question, it pulls an answer from ten documents. The shared documentation holds many files, and the agent uses vectors for retrieval. Is it storing knowledge agent vectors like these behind the scenes?

A: Vectors of this kind are the building blocks of that retrieval step, though not the whole pipeline. The agent indexes the documents into a comparable form, matches the question against them, and composes the answer from what matches. The vectors are building blocks, retrieval matches the question to indexed chunks, and the final answer is composed afterward. A peer write-up comparing IR with language-model agents and retrieval-augmented generation was recommended as follow-up reading, with feedback welcome.

Q: Should similarity use cosine, and should magnitude use distance measures such as Euclidean? How do similarity, cosine, magnitude, distance, and Euclidean fit together?

A: Both views agree in spirit. Cosine reads the angle regardless of length, so a long and short document on the same theme still match. Distance measures read how far apart the endpoints sit, so a larger distance means less similar vectors. The cosine angle view factors out length while the distance endpoints view keeps it; the two are compared here as near-versus-far separators, and cosine is favored because length normalization is built in.

2.3.5 Where the model breaks

Four drawbacks survive. First, terms are treated as mutually independent axes, so "dog bites man" and "man bites dog" share the same tokens (dog, bites, man) and look identical. Word order and who-did-what-to-whom vanish. Second, matching stays literal. A query for "car repair" never meets a document about "automobile servicing," even for a shop ten feet away, because the tokens differ and no semantic link joins them. Third, representation turns poor at scale. Real documents hold hundreds or thousands of words, collections hold lakhs of documents, and the matrix fills with zeros. The zeros are non-informative cells that still get stored, so the signal sits buried in a vast sparse grid. Fourth, TF-IDF weights are intuitive counts rather than quantities derived from a strict theoretical model. These gaps motivate probabilistic models, and beyond them semantic, neural, bigram and trigram, relationship-based, and graph approaches that model meaning, context, and word relationships.

Real-world: retrieval-augmented generation and knowledge agents over office document stores reuse this vector machinery as their retrieval core. Web search, shop search, and help-desk search all rank weighted vectors before any language model writes a word.

Recap: vectors turn text into arrows, cosine reads the angle, TF-IDF weights rare terms up, and independence plus literal matching remain the weak joints. Bridge: the next step keeps ranking but grounds scores in probability and user feedback rather than angles.

Exam note: expect a numerical that builds a small document-term matrix and reads cosine values such as 0.9 versus 0.3 as strong versus weak matches. Practice the full chain: matrix, dot product, lengths, division, ranking.

2.4 The Probabilistic Model: Ranking by Likelihood of Relevance

2.4.1 The relevance-feedback loop

What if the system stopped asking how similar the words look and started asking how likely you are to say yes?

The probabilistic model, also called binary independence retrieval (BIR), asks a different question: what is the probability that this document is relevant to this query. Its symbol is , the probability of relevance given document and query , with a matching for the other side. Documents are then ranked by their likelihood of being relevant, which lines up directly with what the user wants.

The probability of relevance ranking likelihood estimate replaces angle with odds. Let mean relevant and mean non-relevant. Let be one document and be the query. Then the score is:

with the companion quantity:

A larger likelihood means a higher rank. The probability of relevance is the ranking signal itself, not a by-product of geometry.

Think of a detective updating a hunch as clues arrive. Each relevance mark is a clue. The prior guess about a document shifts with every yes or no from the user. The mapping is direct: hunches map to probabilities, clues map to feedback marks, and the case board maps to the re-ranked list. The analogy breaks where cases stop: detectives weigh dependent clues together, while binary independence treats terms as if they arrive alone.

The model does not stand alone. It is built on top of a Boolean or vector run. The procedure has numbered steps: first, retrieve an initial document set with the base model; second, have the user mark each returned document as relevant or non-relevant; third, feed those marks back so the system updates its picture of relevance; fourth, re-rank and return the improved list. Each round of marks sharpens the next ranking. Feedback here means the relevance feedback loop that turns user judgments into new term odds, and re-rank means sorting again by the updated likelihood.

Picture odds bars for three documents. Round one shows short, tied bars from the base run. The user marks one relevant and one non-relevant. Round two stretches the bar for terms from the relevant document and shrinks the bar for terms tied to the rejected one. The horizontal axis is estimated relevance probability, landmarks are the marked relevant and non-relevant anchors, and the takeaway in one line is that each mark bends the next ranking toward the user's yes pile.

2.4.2 Strengths and weaknesses

Ranking by likelihood is the main strength. Scores now mean something the user cares about, namely the chance of relevance, and the feedback loop lets the system learn from direct judgments instead of guessing. The reference names this the Binary Independence Model, where binary means documents and queries are incidence vectors of presence bits and independence means terms are modeled as occurring on their own. That sparseness keeps estimation practical.

Feedback turns a one-shot guess into a loop. Initial retrieval proposes, the user disposes with yes-or-no marks, and the model re-estimates term odds from the two piles before ranking again.

The weaknesses mirror the design. The first round depends on the base model, so a weak Boolean or vector start caps everything above it. Relevance marks are binary, which squeezes graded usefulness into yes-or-no boxes: a document that is partly helpful must still be filed as fully in or fully out. And learning from the non-relevant set adds only marginally useful signal, since knowing what is wrong helps less than knowing what is right. In short, the model improves relevance but inherits the limits of whatever sits underneath.

Scope: probabilistic re-ranking fits when users will judge results and the base run already contains some relevant items. Assumption: term independence holds well enough for odds to factor per term, and binary marks capture usefulness. When no relevant document reaches the first page, or when usefulness is graded rather than binary, the loop has little to learn from.

Two traps recur. One trap is expecting feedback to rescue a failed base run: marks can only reweight what was retrieved, not summon unseen documents. A second trap is reading the probability as a calibrated real-world chance, when it is mostly a ranking score whose order matters more than its digits.

2.4.3 Method family and road map

Several known methods belong to this family. The binary independence model is the base form. BM25, short for Best Matching 25, is the best-known probabilistic ranker named in the session. BM25 keeps the probabilistic outlook but adds term counts, document-length handling, and saturation so that the twentieth occurrence adds less than the first. Language models with maximum-likelihood estimation and belief (Bayesian network) models extend the same probabilistic outlook: language models score by the chance the document would generate the query, while Bayesian networks propagate beliefs across linked terms and documents.

Think of these as one shelf in a longer journey: the course starts with the Boolean model, moves to the vector model, then the probabilistic model, and later reaches web retrieval, graph-based retrieval, neural retrieval, and multimodal retrieval. The current and next sessions stay with the Boolean model, which gets a full dedicated treatment. The road map matters because each later shelf keeps the earlier machinery: neural rankers still filter with inverted lists, and web engines still seed probabilistic scores from vector runs.

2.4.4 Student Questions and Answers

Q: For a query like "bike repair," a document about "automobile servicing" uses none of the same words. The bike repair versus automobile servicing miss shares no tokens, so can the probabilistic model fix that probabilistic miss?

A: No, and the reason is structural. The probabilistic layer starts from the base retrieval set, so tokens that never matched below never enter the feedback loop. The probabilistic layer over the base retrieval feedback loop only reweights tokens already present, which is why the choice of lower layer matters so much. Whatever the lower layer missed propagates upward. The probabilistic step only sharpens relevance among documents the base layer already surfaced.

Real-world: spam filters, news recommenders, and search engines all run this loop in production: seed with a fast ranker, collect clicks or marks as soft relevance votes, and re-rank by updated likelihood.

Recap: the probabilistic model ranks by estimated relevance probability and learns from binary user marks on top of a base run. Bridge: the next step returns to the Boolean base itself and builds the fast index structures that every later ranker depends on.

Exam note: be ready to write the relevance probability, list the four feedback steps in order, and explain why a synonym miss below cannot be fixed above.

2.5 The Term-Document Incidence Matrix and Boolean Evaluation

2.5.1 Why manual search and grep do not scale

How would you find every Shakespeare play with Brutus and Caesar but not Calpurnia without rereading all 37 plays for each new query?

Pose a concrete task: find every Shakespeare play containing "Brutus" and "Caesar" but not "Calpurnia." By hand, the method is to open each play, check for the two wanted words, and confirm the third is absent. With Unix tools the same idea becomes grep-style queries such as "list files matching Brutus," combined with matches for Caesar and non-matches for Calpurnia. Both paths work on a handful of files. Neither scales to billions of documents, because every query would re-scan the whole collection. The fix is to prepare the data once, in advance, and then answer each query from that prepared structure. That preparation is indexing, and its simplest form is the term-document incidence matrix (also just called the incidence matrix).

An incidence matrix (a table with a 1 where a term occurs in a document and 0 elsewhere) pays an upfront build cost once so that every later query becomes cheap bit work. Grep scans text each time. The matrix scans bits each time, over a far smaller structure.

2.5.2 Mathematical Formulation

Incidence vectors with bitwise AND NOT answer turn a logic query into parallel bit operations. Let each term be a binary vector across documents. Then AND keeps a 1 only where every input has 1, and NOT flips each 1 to 0 and each 0 to 1.

The incidence matrix is the same document-term idea seen through Boolean eyes. Terms run down the rows, documents run across the columns (six Shakespeare plays in the worked session), and each cell holds 1 when the row term occurs in the column document and 0 otherwise. Counts, positions, and weights are all ignored. The six columns in order are Antony and Cleopatra, Julius Caesar, The Tempest, Hamlet, Othello, and Macbeth. Each term is then a binary vector across documents. Reconciled against the reference table, the three term vectors are:

The dictated digits in the session run longer than six entries and mix two examples, so the six-wide forms above follow the reference figure: Brutus appears in Antony and Cleopatra, Julius Caesar, and Hamlet; Caesar appears in those three plus Othello and Macbeth; Calpurnia appears only in Julius Caesar. NOT flips every bit of the Calpurnia vector:

AND takes the bitwise minimum across the three vectors:

In compact bit-string form this is the textbook identity . The verbal rule used throughout is "AND means keep a 1 only where every input has 1; NOT turns each 1 to 0 and each 0 to 1." Reading the 1-entries of the answer vector gives the matching documents.

2.5.3 Worked Examples

Worked example: Shakespeare Brutus Caesar Calpurnia bitwise answer Hamlet. Apply the rule entry by entry over the six Shakespeare columns. Position one (Antony and Cleopatra) has 1 AND 1 AND 1, which stays 1. Position two (Julius Caesar) has 1 AND 1 AND 0, since Calpurnia occurs there and its complement is 0, giving 0. Position three (The Tempest) has 0 AND 0 AND 1, giving 0. Position four (Hamlet) has 1 AND 1 AND 1, giving 1. Positions five and six fail on the Brutus bit and give 0. The walk leaves . The two surviving plays are Antony and Cleopatra and Hamlet: each holds Brutus and Caesar while lacking Calpurnia. Sense-check: the Shakespeare Brutus Caesar Calpurnia bitwise answer Hamlet drill matches the reference result, where the same query returns exactly those two plays, with sample passages from Antony and Cleopatra Act 3 Scene 2 and Hamlet Act 3 Scene 2.

Compared with hand search and grep, the matrix version is fast and routine. Once built, each query is just bit operations over short vectors rather than a fresh scan of a million words of Shakespeare text. The same pattern restates as "NOT Calpurnia, then AND the three together," yielding those two plays.

Picture the matrix as a grid with terms as rows and plays as columns. Ones cluster in the Brutus and Caesar rows; the Calpurnia row is almost all white with a single dark cell under Julius Caesar. The answer row lights only under columns one and four. The horizontal axis is the play order, the vertical axis is the term order, landmarks are the lone Calpurnia cell that kills column two and the empty Tempest column, and the takeaway in one line is that zeros dominate and answers are the rare columns where every required light stays on.

Scope: the incidence matrix fits small, fixed collections where the vocabulary is known. Assumption: one bit per term per document suffices, and the corpus does not change between build and query. When counts, positions, or weights matter, or when billions of documents arrive, the bit grid must give way to postings lists.

Beginners often read the answer vector as ranked, but its order is just column order, not relevance order. A second trap is expecting passage answers: the matrix says Hamlet matches, but not which act or scene holds the lines. A third trap is storing the sparsity zeros outnumber ones signal buried warning too late: most cells carry no information, so the grid wastes space even at six plays.

Exam note: expect to construct a small incidence matrix by hand and evaluate an AND-NOT query bit by bit, since that is the exact drill rehearsed here. Hand-trace a small incidence matrix AND-NOT query bit by bit until it runs without notes.

2.5.4 Limits of the matrix view

Two limits already bite with only six plays. First, zeros outnumber ones, so most stored cells carry no information; at web scale that sparsity becomes the dominant fact about the structure. Shakespeare uses about 32,000 distinct terms, so a full matrix would hold roughly 32,000 times 37 cells with ones scattered thinly. Second, answers stop at document level. The matrix says Hamlet matches, but not which act or scene holds the matching lines. For instance, a result such as "Antony and Cleopatra, Act 3, Scene 2" is beyond what was asked for and beyond what the structure records. Newer retrieval layers built above this one can supply passage-level answers.

2.5.5 Student Questions and Answers

Q: Is this matrix built after the query arrives? How would the system know in advance to index Shakespeare words like these for a later matrix query over the Shakespeare corpus?

A: The matrix is built before any query, over the whole corpus, whatever it holds. Indexing creates a logical view of every document once and stores it. The indexing logical view of the corpus is stored ahead of time, and matching runs against that stored view when the query arrives. The Shakespeare words are indexed because every word is indexed, not because anyone predicted the query.

Q: With ten documents of three pages and a thousand words each, are we indexing every possible word? A thousand words per file at web scale sounds impossibly large and sparse.

A: Yes, and the worry is correct. On paper the matrix looks small, but real collections make it humongous and sparse, with billions of entries. The humongous sparse index holds billions of entries and is pre-built before querying, which is why answers return so fast despite the size. Search engines pre-build that index. Sparsity, storage, and update cost are the live issues, and later material takes them up one by one.

Q: If the corpus keeps changing every second, is the index ever finished? The corpus changing all the time seems to fight indexing, and do ranking signals like hits and misses play a role?

A: Theory speaks of a fixed corpus, but practice never stops: new documents keep arriving, term statistics keep shifting, and the index is rebuilt continuously. The fixed corpus is rebuilt continuously in production, while ranking layers sit around the index. Fast lookup comes from the pre-built structure, while ranking refinements sit in layers around it. The session keeps the two ideas apart: indexing for speed of matching, ranking signals for order of results.

Recap: the incidence matrix pre-builds bit vectors so Boolean queries become fast bitwise walks, with Antony and Cleopatra plus Hamlet as the canonical survivors. Bridge: the next step drops the stored zeros and keeps only the ones, which is the inverted index.

2.6 The Inverted Index: From Words to Documents

2.6.1 Flipping the mapping

What if instead of asking each document what words it holds, you asked each word which documents hold it?

The incidence matrix maps documents to words and pays for it in stored zeros. The inverted index flips the direction: it maps each word to the documents holding it, storing only what is present. The session reaches for a textbook analogy: the textbook index entry science report with pages 12, 15, 45 points from a word to its locations, and the analogy holds because an inverted index does the same for a collection, mapping each term to document locations rather than mapping each document to terms.

For the word Brutus the index stores only the identifiers of documents containing Brutus. The same goes for Caesar and Calpurnia. Nothing is stored for documents a word never touches, so the sparse grid collapses into short lists. The repository of 174 documents named in the session belongs to the larger collection figure where Brutus postings run to identifiers 173 and 174; the six-play matrix is a separate small toy over six columns. The two numbers live in different examples: six plays for the bit-matrix drill, 174 documents for the postings illustration.

A dictionary (the sorted vocabulary of indexed terms) plus postings lists (the sorted document identifiers per term) replace the full grid. Only ones are stored. Zeros cost nothing.

Think of a library card catalog as an analogy. Each card names one book title and lists the shelves holding it, instead of listing every shelf for every book with mostly-empty rows. The mapping is direct: cards map to dictionary terms, shelf numbers map to postings, and pulling a card maps to a dictionary lookup. The analogy breaks where cards stop: catalog cards are read by people, while postings are walked by merge code that demands sorted order.

2.6.2 Building one: dictionary, postings, and frequencies

Vocabulary terms on the left are the dictionary; each term's document list on the right is its postings list, held in a plain manageable structure such as a linked list or array. A posting (one document identifier inside a term list, optionally with frequency or position data) is the unit entry. A document frequency (the count of documents holding a term, written ) is stored beside each term and later doubles as the list length and the ranking statistic.

Construction follows numbered steps: first, collect the documents to index; second, tokenize the text into pieces; third, normalize each token (lowercasing, stemming, lemmatization, stop-word removal); fourth, emit term-plus-document-identifier pairs; fifth, drop duplicates such as a doubled "I" or a doubled "killed"; sixth, sort the postings of each term by document identifier; seventh, record each term's document frequency alongside.

Worked example: two-document build from pairs to postings. Take two tiny documents in the textbook style. Doc 1 holds "I did enact Julius Caesar, I was killed in the Capitol, Brutus killed me." Doc 2 holds "So let it be with Caesar, the noble Brutus hath told you Caesar was ambitious." Step one collects the two documents. Step two tokenizes into term plus document pairs such as (I, 1), (brutus, 1), (brutus, 2), (caesar, 1), (caesar, 2), (caesar, 2), (killed, 1), (killed, 1). Step three lowercases and normalizes. Step four emits the raw pairs. Step five merges duplicates: the doubled (killed, 1) collapses to one entry with frequency two, and the doubled (caesar, 2) collapses likewise. Step six sorts by term then by identifier, giving brutus with [1, 2], caesar with [1, 2], killed with [1]. Step seven records document frequency beside each term and keeps the within-document count: brutus frequency list [1, 2] with , killed frequency list [1] with count two. The sparse grid has become short sorted lists with counts. Sense-check: every surviving word appears once as a dictionary entry, every list runs in rising identifier order, and no zero is stored anywhere.

The session stresses that the demo exists only to build intuition for indexing, sorting, and frequency counting; there is nothing else to memorize in it. Real-world: web engines hold billions of such postings, which is the physical reason ordinary queries answer in milliseconds. The dictionary commonly stays in memory while postings live on disk, so both sizes matter and later chapters compress each.

Picture the build as three columns. The left column is the raw pair stream in document order. The middle column is the same pairs sorted alphabetically by term. The right column splits into dictionary terms with pointers plus postings lists. Landmarks are the doubled pairs that merge, the sorted runs that group, and the frequency counts beside each list. The takeaway in one line: sort plus group turns a jumble of pairs into a query-ready map.

Scope: this build fits a fixed collection indexed in one batch. Assumption: tokenization plus normalization settle the vocabulary before sorting, and identifiers sort in one global order. When documents stream in nonstop, or when positions and weights must ride along, the same steps repeat with extra payloads per posting.

2.6.3 Why sort the postings

Sorting by document identifier looks like bookkeeping, yet the session plants it as a pointed question: why should order matter when the same identifiers are stored either way. A participant suggests faster navigation and search, which is confirmed and then proved in the next section: the merge procedure that intersects postings only works in one pass because both lists arrive sorted. Keep that answer attached to this section: sort once at build time so that every later AND can walk forward without ever stepping back.

Sorted postings turn intersection from checking every pair into walking two fingers forward. Without order no pointer can safely skip ahead. With order each step discards a prefix forever.

Without sorting, intersecting two lists of lengths and would need up to checks in the worst case. With sorting, the merge walks both lists once. The dictionary also stores document frequency, which later lets the engine pick the smallest list first before touching disk. That pairing, sort at build plus frequency at query time, is the whole efficiency story in one line.

One trap is sorting postings by frequency or alphabet instead of by identifier: the merge proof needs identifier order, not popularity order. A second trap is skipping the duplicate-merge step, which leaves doubled entries that inflate frequencies and break counts.

Recap: the inverted index keeps the dictionary plus sorted postings with frequencies and drops every zero. Bridge: the next step walks those sorted lists with two pointers and never steps back.

Exam note: expect to build postings for a tiny collection and to justify sorting as the enabler of single-pass intersection. Rehearse the pair, sort, merge-duplicates, split chain until each stage runs from memory.

2.7 The Merge Algorithm: Answering AND With One Forward Pass

2.7.1 Mathematical Formulation

How do you intersect two long sorted lists without ever stepping back?

Boolean AND over postings is set intersection, OR is set union, and NOT is the complement within the collection. The session states this three-way mapping directly ("AND implies intersection, OR implies union") and then turns AND into a procedure called the merge algorithm. A merge (a joint walk over sorted lists with interleaved pointer advances) answers AND by moving fingers forward through postings.

Purpose: answer AND queries over postings without pairwise checking. Inputs and outputs: two sorted postings lists of length and of length go in, with current pointers and ; one sorted answer list comes out holding only shared identifiers.

Steps. Given the two sorted inputs:

  1. Start with an empty answer list.
  2. While neither list is exhausted, compare the two current document identifiers.
  3. If they are equal, append the identifier to the answer and advance both pointers.
  4. Otherwise advance only the pointer on the smaller identifier.
  5. Stop when either list runs out, since no further match is possible.

Because each step moves at least one pointer forward and never moves any pointer back, the merge forward pass never steps back and pointers stay sorted throughout. The total work is:

where is the length of the first postings list and is the length of the second. The verbal form given is "the complexity is simply order of M plus N, where M and N are the lengths of the lists." The merge complexity linear in postings lengths holds because every comparison consumes at least one posting forever.

Sorted order is the load-bearing assumption: without it, no pointer could safely skip ahead, and every combination would need checking. Using a numeric sort by document identifier is the standard way to supply that single global order. The intersection operation is asymmetric in production: the intermediate result stays in memory while the next list streams from disk, and the intermediate list stays no longer than the other side.

Picture two combs sliding past each other. The upper comb carries , the lower carries . At each tick the smaller tooth jumps forward; matching teeth click and drop a copy into the answer tray. The horizontal axis is document identifier order, landmarks are equal-tooth clicks versus smaller-tooth jumps, and the takeaway in one line is that forward-only motion guarantees each tooth is touched once at most.

Scope: the linear merge fits sorted postings answered with AND. Assumption: both lists arrive sorted by one global identifier order and fit the walk discipline. When lists are unsorted, or when the query is a general OR-NOT mix, the plain two-pointer walk needs extensions or different structures.

Complexity and cost. Time grows with the sum of list lengths, not the product, so doubling both lists roughly doubles work rather than quadrupling it. Space is the answer list plus two pointers. When to use and alternatives: use the linear walk as the default for AND; when one list dwarfs the other, binary-search each short item in the long list or hash the long list for constant-time membership tests, at the cost of extra structures that compress poorly.

2.7.2 Worked Examples

Worked example one: merge pointer trace over postings intersection. With an inverted index for Brutus and Calpurnia available, the query "Brutus AND Calpurnia" intersects the two postings and returns documents 2 and 31. Those identifiers come from the larger posting example with 174 documents, where Brutus postings are 1, 2, 4, 11, 31, 45, 173, 174 and Calpurnia postings are 2, 31, 54, 101, not from the six-play matrix. The merge pointer trace over this postings intersection walks: compare 1 with 2, advance the first; compare 2 with 2, record 2 and advance both; skip through 4 and 11 against 31; compare 31 with 31, record 31 and advance both; then one side exhausts its matching chances and the walk stops. The answer is the set {2, 31}. Sense-check: only identifiers present in both lists survive, and sorted order lets each loser pointer jump without revisit.

Worked example two: small-list trace step by step. Let and . These four-entry lists are the cleaned toy trace used in the walk-through, matching the dictated fragments in spirit. Iteration one compares 2 with 3: unequal, 2 is smaller, so advance . Iteration two compares 5 with 3: unequal, 3 is smaller, so advance . Iteration three compares 5 with 5: equal, so record 5 and advance both. Iteration four compares 8 with 9: unequal, so advance . Iteration five compares 12 with 9: unequal, so advance . Iteration six compares 12 with 12: equal, so record 12. The answer is {5, 12} after six comparisons, on the order of 4 + 4. Sense-check: pointers are exhausted exactly when one list runs dry, and no pointer ever moves back.

Worked example three: Paris France Japan union intersection exercise result. Given postings Paris = {2, 6, 10, 12, 14}, France containing 2, 12, 14 (among others), Japan = {12, 15}, and a 15-document collection, evaluate "Paris AND NOT France OR Japan" by solving the innermost piece first. NOT France removes the France documents, leaving {6, 10} among the Paris-relevant remainder, as stated in the session. AND with Paris keeps {6, 10}. OR with Japan unions in {12, 15}, giving the final set {6, 10, 12, 15}. The Paris France Japan union intersection exercise result is {6, 10, 12, 15}. Sense-check: the order of operations is the lesson, innermost NOT first, then AND, then OR, and union only ever grows the set.

Third, plain logical-expression queries. "AI AND healthcare" keeps only documents holding both terms (intersection). "AI OR healthcare" keeps documents holding either (union). The model never grades partial relevance: a document matches or it does not.

Two traps catch beginners. One trap is advancing both pointers on a mismatch, which skips live candidates. Only the lagging side moves. A second trap is continuing after one list is exhausted: once pointers are exhausted on either side, no further equal pair can appear, so stopping is safe rather than lazy.

2.7.3 Student Questions and Answers

Q: If I type just "AI healthcare" with no operator, does it count as AND, as OR, or as one single phrase? The bare healthcare single phrase with a vague query and no operator is ambiguous.

A: A Boolean engine needs an explicit operator, so a bare two-word query is ambiguous. The Boolean engine enforces an explicit operator, and lenient engines widen toward union-like behavior, returning more and leaving the user to keep or discard results. Precise operators give precise sets; vague input gives large sets.

Recap: the merge answers AND as sorted intersection in linear time with forward-only pointers. Bridge: the next step spends that linearity wisely by starting with the shortest list and jumping over dead stretches.

Exam note: rehearse the pointer dance aloud until the else-branch (advance only the smaller side) runs without notes, then time yourself on the Paris AND NOT France OR Japan order-of-operations drill.

2.8 Query Optimization and Why Boolean Refuses to Retire

2.8.1 Smallest set first

When three lists have very different lengths, which pair should meet first?

Posting lengths decide the bill. In the running example the Brutus list holds about seven identifiers, the Caesar list about eight, and the Calpurnia list two. The session states the counts once as six, eight, two and once as seven, eight, two; the relative order is stable with Calpurnia shortest, and the optimization lesson is unchanged either way. (The full-collection figure elsewhere lists eight Brutus postings and four Calpurnia postings; the lecture's running counts are its own smaller illustration of the same principle.) An AND between Brutus and Caesar would grind through roughly a dozen comparisons, while starting with Calpurnia needs only about two probes: check each of its two identifiers against the longer list.

Purpose: minimize total comparisons for AND queries. Rule: process terms in order of increasing document frequency, starting with the smallest set first, and stop as soon as any side runs dry. Intermediate results can never outgrow the smallest input, so the early exit on comparisons keeps work low.

Concretely, intersecting Calpurnia with Brutus first yields a single survivor, document 16; the remaining AND against the Caesar list is then one membership test, is 16 present, with early exit the moment the short side is exhausted. The smallest set Calpurnia Brutus survivor optimization leaves that single survivor for one membership test. Because postings are sorted, a match at 16 also proves nothing later in the other list can match the consumed prefix, so the tail (thousands of identifiers in real lists) is never touched. The rule is: for AND, run the smallest list first and stop as soon as any side runs dry. The reference states the same heuristic as sorting terms by increasing frequency and seeding the in-memory result with the least frequent term's list.

OR queries need the mirror image. A union only grows, so estimate each OR's result size from document frequencies first, run the smaller union first, and let the later AND meet the compact set. The session sketches winds: if "wind" occurs in 100 documents and "fire" in 200, their union holds at most 300; if "thunder" occurs in 50 and "lightning" in 30, their union holds at most 80. Process the 80-side first, then combine with the 300-side, and the comparison count stays low. The stated maximum is a worst case, not a promise: overlaps shrink real unions below the sum, so the sum is a conservative size estimate.

Picture three bars for list lengths: Calpurnia shortest at two, Brutus mid at seven, Caesar tallest at eight. Intersecting the two tall bars first builds a wide intermediate slab. Starting from the short bar keeps every intermediate slab no wider than two. The horizontal axis is processing order, landmarks are the survivor document 16 and the early-exit point, and the takeaway in one line is that small-first bounds every later step.

Scope: smallest-first fits conjunctive AND queries over lists with known frequencies. Assumption: dictionary frequencies are fresh and intermediate results stay in memory while the next list streams in. When frequencies are stale, or when NOT and OR dominate, size estimates need care and the plain order can mislead.

2.8.2 Skipping ahead with skip pointers

A second speedup jumps over hopeless stretches. Suppose and with a skip length of 2. These lists reconstruct the dictated fragments as a clean illustration; the pointer logic is what matters, not the exact tail digits. Instead of stepping one by one, compare 1 with 5, find no match, and skip two ahead; compare 5 with 5, record the match, and skip the block between, since sorted order proves no match hides inside it. Later, 8 against 7 mismatches and the window jumps again.

Skip pointers (shortcut links placed at indexing time that jump ahead within one postings list) let the lagging list leap over identifiers proven too small. The usual skip length for postings is:

where is the postings length. The verbal form given is "the skip length would be computed by square root of N," tuned further with domain knowledge. The skip length as square root of postings length balances two costs: more skips mean shorter jumps but more pointer storage and checks, while fewer skips mean longer jumps with fewer chances to leap. The reference phrases the same heuristic as using about evenly spaced skips on a list of length , which gives spans of about each.

Trace in words. Both pointers start at their heads. When the lagging side owns a skip whose landing identifier is still no larger than the other side's current identifier, follow the skip; otherwise step once. Skips exist only on the original stored lists, never on intermediate results, and they help AND queries rather than OR queries. The idea matches the merge theme: sorted identifiers let the procedure prove that whole stretches can go unchecked.

One trap is adding skips to intermediate results, where they do not exist and the check must always fail safe to single steps. A second trap is expecting skips to help unions: OR must drain both lists, so jumps cannot discard tails. A third trap is over-tuning the spacing while ignoring update costs on fast-changing indexes.

2.8.3 Industry Applications

Real-world: Westlaw, the large legal search system, still runs Boolean-style retrieval after decades, because legal work leaves no room for maybe-answers. The retrieved set must be exactly the matching set, trustworthy at face value. The Westlaw legal exact sentence tailored retrieval earns trust in that setting: every hit provably satisfies the stated operators.

Its queries show how far exact matching stretches. A query may combine a wildcard such as "limit!" (matching limit, limits, limitation, where SQL-style systems would write a star), a proximity bound such as "/3" (within three words), a sentence bound such as "/S" (within the same sentence), and offsets such as "/2" (within two words). One worked query chains "limit!" within three words of "statute action," in the same sentence as "federal," within two words of "tort," within three words of "claim," and pulls the sentence "The statute of limitations governing this action under the Federal Tort Claims Act applies." The Westlaw wildcard proximity sentence statute federal retrieval drill is the canonical specimen: read each operator into plain words, then check the sentence word by word. A second query asks for "trade secret" in a sentence with "disclose" plus "prevent" plus "employ," retrieving the sentence about preventing disclosure of trade secrets by employees. This is sentence-tailored exact retrieval, not keyword guessing.

Worked example: smallest-set plus Westlaw operator reading. First the optimization half. Intersect Calpurnia (two postings) with Brutus (about seven) before touching Caesar (about eight): the first meet yields survivor document 16, and the second meet is one membership test on 16. Comparisons stay near a handful instead of a dozen. Second the Westlaw half. Read "limit! /3 statute action /S federal /2 tort /3 claim" as: a word starting with limit within three words of statute plus action, in the same sentence as federal, with tort within two words and claim within three. The retrieved sentence about the statute of limitations under the Federal Tort Claims Act satisfies every bound. Sense-check: the smallest-set half bounds work by the shortest list, and the Westlaw half bounds meaning by explicit operators.

Real-world: modern pipelines (retrieval-augmented generation, neural rankers, knowledge graphs, Elasticsearch-style engines) do not retire Boolean logic; they embed it as a fast first-pass filter and rank what survives. Elasticsearch and related stacks run Boolean pre-filters over inverted lists before any learned scorer sees a document.

Real-world: contact and address lookup, brand-exact shopping search (a named toothpaste brand should return that brand, not synonyms), library catalog lookup by author name, and biomedical search over PubMed and NCBI all favor exact Boolean behavior where synonyms would corrupt the answer. PubMed search for one gene symbol must not drift to a look-alike symbol.

Exam note: read Westlaw operators wildcard proximity sentence bounds into plain sentences. Practice turning !, /3, /S, and /2 into words before touching any answer key, since operator literacy is the fastest way to earn marks on a Boolean question.

2.8.4 Student Questions and Answers

Q: Since postings are sorted, could a binary search or any data-structures list algorithm replace the linear walk? The postings sorted order seems to invite binary search over the linear walk.

A: Yes. Sorted postings invite the full toolbox of list algorithms, and production systems use them. The sorted postings list algorithms used in production include binary search, hashtables, and skip jumps, while the textbook merge stays linear for the syllabus. The session stays with the textbook linear merge because the syllabus and handout do, but faster lookups on sorted postings are legitimate and expected in practice.

Q: With skips, if the wanted document is 7 but a jump lands on 9, do we walk back through both lists? The skips jump seems to overshoot, so which lists walk back on mismatch?

A: At most one list steps back per mismatch, following the same else-branch logic as the merge: only the lagging side moves. The mismatch rule keeps lagging moves on a single side while jumps go forward, so overshoot handling touches one side and the net effect stays far below pairwise checking. Overshoot handling has many fine details beyond one page of notes, but the principle holds: jumps go forward, corrections touch a single side.

Recap: start AND with the shortest list for early exit, jump sorted lists with square-root skips, and keep Boolean exactness where trust matters. Bridge: the next step runs this whole chain in code on a small notebook collection before scaling to real documents.

2.9 From Notebook to Assignment: Boolean Retrieval in Code

2.9.1 The pipeline in miniature

Can the full Boolean chain, from raw lines to ranked-free answers, fit in one short notebook?

A Python notebook replays the whole Boolean path on four short documents about schizophrenia, drugs, treatment, and breakthrough (each line treated as one document). The steps mirror the session: preprocess text with the NLTK library (tokenize, lowercase, reduce to base forms), build the inverted index as a dictionary of sorted terms plus postings, then run Boolean retrieval with AND, OR, and NOT over a typed query. The index output shows alphabetically sorted terms beside the documents holding each one. NLTK supplies the tokenizer and stemmer, so the notebook focuses on index logic rather than string plumbing.

Purpose: make the abstract pipeline concrete on data small enough to check by hand. Inputs and outputs: four short lines go in; a printed dictionary plus postings plus query answers come out. Steps: load lines as documents, preprocess each line, emit and sort term-plus-identifier pairs, merge duplicates, store postings with frequencies, then answer typed Boolean queries with the merge plus complement rules.

Picture the notebook as three panels. The left panel shows raw lines. The middle panel shows tokens per line. The right panel shows the inverted index plus the answer set for the typed query. The uploader demo repeats the same three stages, upload a text file, view tokens, view the inverted index, type a Boolean query, with each uploaded line acting as one document. The takeaway in one line: the same code path serves the toy lines and the uploaded file, only the input changes.

Scope: the miniature fits line-as-document toy data for teaching. Assumption: each line is one document, the vocabulary fits memory, and queries use explicit AND, OR, and NOT. Real collections need file-level documents, disk-backed postings, and ranking on top.

2.9.2 Worked queries and the take-home brief

Worked example: schizophrenia drug treatment breakthrough notebook queries. Two queries show the optimizer at work. "schizophrenia AND drug" returns documents {1, 2}: the drug postings list is shorter than the schizophrenia list, so the AND starts there and stops once the short side is consumed. "drug OR treatment" returns {1, 2, 3} by union with no side preferred, since unions must drain both lists. Further probes behave as the sets predict: "treatment AND drug" returns nothing (disjoint postings, the empty set), while adding "breakthrough" narrows to document one, the breakthrough-for-schizophrenia text. The schizophrenia drug treatment breakthrough notebook queries exercise intersection, union, empty results, and narrowing in four moves. Answers: AND gives {1, 2}, OR gives {1, 2, 3}, disjoint AND gives the empty set, breakthrough narrows to {1}. Sense-check: each answer matches the postings by hand, and the short-list-first order explains the AND path.

The take-home brief converts the demo into real practice. Build an application that loads multiple genuine documents (not one line per document), then carries out preprocessing, inverted-index construction, and Boolean querying over them. The companion interactive demo repeats the three stages with an uploader, and the follow-on assignment follows similar lines. Exploration beyond the brief is encouraged: try vector-side ideas on the same uploader, test with current coding tools, and bring findings back for discussion. The habit matters more than the harness: a good exploration question beats a long program. The session notes that its own demo code was drafted with AI assistance and then verified by hand, modeling exactly that workflow.

Two traps await in code. One trap is treating one line as one document in the real app, which inflates document counts and distorts frequencies; load true files instead. A second trap is forgetting to lowercase or stem before indexing, which splits one term into several dictionary entries and silently empties AND results.

Recap: the notebook plus uploader turn pairs, postings, merge, and optimization into runnable code on four lines before real files. Bridge: the appendices below convert the whole lecture into revision tasks and industry placements.

Exam Guidance Summary

No mark distribution, question pattern, or exempted topic was stated in this session. The signals below are importance cues worth converting into study tasks.

Exam note: the Boolean block (incidence matrix, inverted index, merge trace, optimization) received a full dedicated session plus a promised sequel, so hand-trace every procedure here until each runs without notes. Hand-trace a small incidence matrix AND-NOT query bit by bit until it runs without notes.

Exam note: practice building a document-term matrix and scoring it with cosine similarity, since vector scoring is the natural numerical counterpart to the Boolean drills. Rehearse the dot product, lengths, division, and ranking chain on the India Moon toy until the 0.82 versus 0.50 split comes out cleanly.

Exam note: rehearse reading Westlaw-style operators (!, /3, /S, /2) into plain sentences, because operator literacy is the fastest way to lose or earn marks on a Boolean question. Read Westlaw operators wildcard proximity sentence bounds into plain sentences before checking any answer key.

Exam note: the take-home exercise (four-document incidence matrix plus inverted index, then the multi-document uploader) is the closest thing to a specimen answer set. Solve it on paper first, then check it against code. Structured models were explicitly marked outside this course, so revision time belongs to Boolean, vector, and probabilistic models plus the announced road map (web, graph, neural, multimodal retrieval).

Key Industry Applications

Real-world: Westlaw-style legal search keeps Boolean exactness (wildcards, proximity, sentence bounds) where near-misses are unacceptable, with queries such as limit-plus-proximity chains checked sentence by sentence.

Real-world: retrieval-augmented generation, neural rankers, knowledge graphs, and Elasticsearch-style stacks reuse Boolean matching as a fast filter beneath ranking, so inverted lists prune billions of documents before any learned scorer runs.

Real-world: sponsored placement on shopping and search products layers payments above relevance ranking instead of changing the match core, keeping organic relevance separate from promotion.

Real-world: knowledge agents over office document stores index content into vectors and retrieve before composing answers, repeating the notebook chain of preprocess, index, match, and compose at production scale.

Real-world: contact and address lookup, brand-exact shopping search, library author catalogs, and PubMed plus NCBI biomedical search all prefer exact matching, since one drifted synonym can corrupt a name, brand, or gene symbol.

Real-world: web engines pre-build billion-scale inverted indexes with document frequencies, which is why plain queries return in milliseconds over ever-changing collections that are rebuilt continuously.

IR Lecture 2 notes · IR Models: Boolean, Vector, and Probabilistic Retrieval

Information Retrieval· undergraduate· 2026-09-13

Sections Breakdown

1How IR Models Arise: Index Terms, Premises, and Term Weights

Introduces index terms, the three ranking premises, and why rare terms earn larger weights.

2The Boolean Model: Exact Match With Logic Operators

Reads AND, OR, and NOT as set operations with exact unranked retrieval and its overshoot and undershoot limits.

3The Vector Space Model: Weights, Angles, and Ranking

Turns documents and queries into weighted vectors ranked by cosine similarity with TF-IDF weights.

4The Probabilistic Model: Ranking by Likelihood of Relevance

Ranks by estimated relevance probability and refines the order through a user-marked feedback loop.

5The Term-Document Incidence Matrix and Boolean Evaluation

Pre-builds binary term vectors so Boolean AND-NOT queries reduce to fast bitwise walks.

6The Inverted Index: From Words to Documents

Stores only present postings in sorted dictionary lists with frequencies, dropping every zero.

7The Merge Algorithm: Answering AND With One Forward Pass

Intersects sorted postings with forward-only pointers in linear time.

8Query Optimization and Why Boolean Refuses to Retire

Orders AND by smallest set first with square-root skips and shows Westlaw exactness in practice.

9From Notebook to Assignment: Boolean Retrieval in Code

Replays preprocessing, indexing, and Boolean querying in a small notebook before real files.

Undergraduate students studying Information Retrieval

Exam Revision Notes

Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.

How IR Models Arise: Index Terms, Premises, and Term Weights

Must-know: Three premises split IR into Boolean (shared set), vector (weighted terms), probabilistic (likelihood of relevance); rare terms get larger weights.

Top pitfall: Treating all surviving words as equal, or reading a weight as a property of the word alone rather than word-in-document-in-collection

Self-check: Why does Chandrayaan-3 outvote India in the weight w_ij?

Connects to: 2.2, 2.3

The Boolean Model: Exact Match With Logic Operators

Must-know: AND is intersection, OR is union, NOT is complement; exact match gives no ranking, overshoots on common terms and undershoots on rare terms.

Top pitfall: Expecting AND to widen results or frequency to break ties; Boolean order inside the set carries no meaning

Self-check: Why do the launch and festival documents tie on India AND Moon?

Connects to: 2.1, 2.3, 2.5

The Vector Space Model: Weights, Angles, and Ranking

Must-know: Cosine is dot product over magnitudes; TF-IDF weights rare terms up; cos 0 = 1 is the ceiling and independence kills word order.

Top pitfall: Reading larger distance as more similar, or forgetting length normalization so long documents win on bulk

Self-check: Why does D1 score 0.82 while D2 and D3 tie at 0.50?

Connects to: 2.2, 2.4, 2.5

The Probabilistic Model: Ranking by Likelihood of Relevance

Must-know: Rank by P(relevant | D, Q); loop is retrieve, mark, update, re-rank; base-layer misses propagate upward.

Top pitfall: Expecting feedback to summon documents the base run never retrieved, or reading the score as a calibrated chance rather than a ranking order

Self-check: Why can't the probabilistic layer fix a bike-repair versus automobile-servicing miss?

Connects to: 2.2, 2.3, 2.5

The Term-Document Incidence Matrix and Boolean Evaluation

Must-know: Incidence vectors answer AND-NOT by bitwise ops: 110100 AND 110111 AND 101111 = 100100 gives Antony and Cleopatra + Hamlet.

Top pitfall: Reading answer order as relevance order, or expecting act-and-scene answers from a document-level bit grid

Self-check: Why does Julius Caesar fail the Brutus AND Caesar AND NOT Calpurnia query?

Connects to: 2.2, 2.6, 2.7

The Inverted Index: From Words to Documents

Must-know: Dictionary plus sorted postings with df; build is collect, tokenize, normalize, emit pairs, merge duplicates, sort, record df.

Top pitfall: Sorting postings by frequency instead of identifier, or skipping duplicate-merge so counts inflate

Self-check: Why must postings be sorted by document identifier?

Connects to: 2.5, 2.7, 2.8

The Merge Algorithm: Answering AND With One Forward Pass

Must-know: AND is intersection via forward-only merge in O(M+N); stop when either list is exhausted; innermost NOT first, then AND, then OR.

Top pitfall: Advancing both pointers on mismatch, or continuing after one list is exhausted

Self-check: Why does the merge stop the moment one list runs out?

Connects to: 2.5, 2.6, 2.8

Query Optimization and Why Boolean Refuses to Retire

Must-know: AND smallest-first with early exit; skip length sqrt(N); Westlaw !, /3, /S, /2 read into plain sentences.

Top pitfall: Putting skips on intermediate results, or expecting skips to help OR unions that must drain both lists

Self-check: Why does starting with Calpurnia beat starting with Brutus AND Caesar?

Connects to: 2.6, 2.7, 2.9

From Notebook to Assignment: Boolean Retrieval in Code

Must-know: Notebook chain is preprocess with NLTK, build sorted postings, answer AND/OR/NOT; schizophrenia AND drug gives {1,2}.

Top pitfall: Keeping line-as-document in the real app, or skipping lowercase/stem so one term splits into several entries

Self-check: Why does treatment AND drug return the empty set in the notebook?

Connects to: 2.6, 2.7, 2.8

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.