Introduction To: Information Retrieval
Introduction To: Information Retrieval
Introduction to
Information Retrieval
CS276
Information Retrieval and Web Search
Christopher Manning and Prabhakar Raghavan
Lecture 1: Boolean retrieval
Introduction to Information Retrieval
Information Retrieval
Information Retrieval (IR) is finding material (usually
documents) of an unstructured nature (usually text)
that satisfies an information need from within large
collections (usually stored on computers).
2
Introduction to Information Retrieval
3
Introduction to Information Retrieval
4
Introduction to Information Retrieval Sec. 1.1
Term-document incidence
Antony and Cleopatra Julius Caesar The Tempest Hamlet Othello Macbeth
Antony 1 1 0 0 0 1
Brutus 1 1 0 1 0 0
Caesar 1 1 0 1 1 1
Calpurnia 0 1 0 0 0 0
Cleopatra 1 0 0 0 0 0
mercy 1 0 1 1 1 1
worser 1 0 1 1 1 0
Incidence vectors
So we have a 0/1 vector for each term.
To answer query: take the vectors for Brutus, Caesar
and Calpurnia (complemented) bitwise AND.
110100 AND 110111 AND 101111 = 100100.
7
Introduction to Information Retrieval Sec. 1.1
Answers to query
Antony and Cleopatra, Act III, Scene ii
Agrippa [Aside to DOMITIUS ENOBARBUS]: Why, Enobarbus,
When Antony found Julius Caesar dead,
He cried almost to roaring; and he wept
When at Philippi he found Brutus slain.
8
Introduction to Information Retrieval Sec. 1.1
9
Introduction to Information Retrieval
SEARCH
ENGINE
Query Results
Corpus
Refinement
Introduction to Information Retrieval Sec. 1.1
11
Introduction to Information Retrieval Sec. 1.1
Bigger collections
Consider N = 1 million documents, each with about
1000 words.
Avg 6 bytes/word including spaces/punctuation
6GB of data in the documents.
Say there are M = 500K distinct terms among these.
12
Introduction to Information Retrieval Sec. 1.1
13
Introduction to Information Retrieval Sec. 1.2
Inverted index
For each term t, we must store a list of all documents
that contain t.
Identify each by a docID, a document serial number
Can we used fixed-size arrays for this?
Inverted index
We need variable-size postings lists
On disk, a continuous run of postings is normal and best
In memory, can use linked lists or variable length arrays
Some tradeoffs in size/ease of insertion Posting
Dictionary Postings
Sorted by docID (more later on why). 15
Introduction to Information Retrieval Sec. 1.2
Tokenizer
Token stream. Friends Romans Countrymen
Linguistic modules
Modified tokens. friend roman countryman
Indexer friend 2 4
roman 1 2
Inverted index.
countryman 13 16
Introduction to Information Retrieval Sec. 1.2
Doc 1 Doc 2
Why frequency?
Will discuss later.
Introduction to Information Retrieval Sec. 1.2
Terms
and
counts Later in the
course:
•How do we
index efficiently?
•How much
storage do we
need?
Pointers 20
Introduction to Information Retrieval Sec. 1.3
21
Introduction to Information Retrieval Sec. 1.3
2 4 8 16 32 64 128 Brutus
1 2 3 5 8 13 21 34 Caesar
22
Introduction to Information Retrieval Sec. 1.3
The merge
Walk through the two postings simultaneously, in
time linear in the total number of postings entries
2 4 8 16 32 64 128 Brutus
2 8
1 2 3 5 8 13 21 34 Caesar
24
Introduction to Information Retrieval Sec. 1.3
25
Introduction to Information Retrieval Sec. 1.4
Boolean queries:
More general merges
Exercise: Adapt the merge for the queries:
Brutus AND NOT Caesar
Brutus OR NOT Caesar
28
Introduction to Information Retrieval Sec. 1.3
Merging
What about an arbitrary Boolean formula?
(Brutus OR Caesar) AND NOT
(Antony OR Cleopatra)
Can we always merge in “linear” time?
Linear in what?
Can we do better?
29
Introduction to Information Retrieval Sec. 1.3
Query optimization
Brutus 2 4 8 16 32 64 128
Caesar 1 2 3 5 8 16 21 34
Calpurnia 13 16
32
Introduction to Information Retrieval
Exercise
Recommend a query
processing order for
Term Freq
(tangerine OR trees) AND eyes 213312
(marmalade OR skies) AND kaleidoscope 87009
(kaleidoscope OR eyes) marmalade 107913
skies 271658
tangerine 46653
trees 316812
33
Introduction to Information Retrieval
34
Introduction to Information Retrieval
Exercise
Try the search feature at
http://www.rhymezone.com/shakespeare/
Write down five search features you think it could do
better
35
Introduction to Information Retrieval
36
Introduction to Information Retrieval
Evidence accumulation
1 vs. 0 occurrence of a search term
2 vs. 1 occurrence
3 vs. 2 occurrences, etc.
Usually more seems better
Need term frequency information in docs
37
Introduction to Information Retrieval
38
Introduction to Information Retrieval
IR vs. databases:
Structured vs unstructured data
Structured data tends to refer to information in
“tables”
Employee Manager Salary
Smith Jones 50000
Chang Smith 60000
Ivy Smith 50000
Unstructured data
Typically refers to free text
Allows
Keyword queries including operators
More sophisticated “concept” queries e.g.,
find all web pages dealing with drug abuse
Classic model for searching text documents
40
Introduction to Information Retrieval
Semi-structured data
In fact almost no data is “unstructured”
E.g., this slide has distinctly identified zones such as
the Title and Bullets
Facilitates “semi-structured” search such as
Title contains data AND Bullets contain search
41
Introduction to Information Retrieval
42
Introduction to Information Retrieval
43
Introduction to Information Retrieval
44
Introduction to Information Retrieval
45
Introduction to Information Retrieval
Course details
Course URL: cs276.stanford.edu
[a.k.a., http://www.stanford.edu/class/cs276/ ]
Work/Grading:
Problem sets (2) 20%
Practical exercises (2) 10% + 20% = 30%
Midterm 20%
Final 30%
Textbook:
Introduction to Information Retrieval
In bookstore and online (http://informationretrieval.org/)
We’re happy to get comments/corrections/feedback on it!
46
Introduction to Information Retrieval
Course staff
Professor: Christopher Manning
Office: Gates 158 manning@cs.stanford.edu
Professor: Prabhakar Raghavan pragh@yahoo-
inc.com
TAs: Andrey Guev, Shakti Sinha, Roshan Sumbaly
In general, don’t use the above addresses, but:
Newsgroup: su.class.cs276 [preferred]
cs276-aut0910-staff@lists.stanford.edu
47
Introduction to Information Retrieval
Any questions?
48