Introduction to Information Retrieval

advertisement
Introduction to Information Retrieval
Introduction to
Information Retrieval
Information Retrieval and Web Search
Lecture 1: Introduction and Boolean retrieval
Summer 2013
Introduction to Information Retrieval
Outline
❶
Course details
❷
Information retrieval
❸
Boolean retrieval
2
Introduction to Information Retrieval
Course details
 Course weblog: IR-qom.blogfa.com
 Useful information from previous terms.
 Please check the weblog periodically.
 Useful URL: cs276.stanford.edu
 [a.k.a., http://www.stanford.edu/class/cs276/ ]
 Slides:
 http://nlp.stanford.edu/IR-book/newslides.html
 Edited versions are placed in weblog.
3
Introduction to Information Retrieval
Course details
 Why English?
4
Introduction to Information Retrieval
Course details
 Textbook:
 Introduction to Information Retrieval
 Online (http://informationretrieval.org/)
 And others (http://nlp.stanford.edu/IR-book/informationretrieval.html)
 Translated books?
 Work/Grading (approximately):




Exercises and Projects
Exam
Class activities
Voluntary presentation
25%
70%
5%
5%
5
Introduction to Information Retrieval
 Some other universities that use this book:
 http://ce.sharif.edu/courses/91-92/1/ce324-1/
 http://www.cs.utexas.edu/~mooney/ir-course/
 http://www.cs.jhu.edu/~yarowsky/cs466.html
6/48
Introduction to Information Retrieval
Outline
❶
Course details
❷
Information retrieval
❸
Boolean retrieval
7
Introduction to Information Retrieval
Why information retrieval
 We are drowning in
— John Naisbitt.
and starving for
.
 There are about 1 trillion web pages
 http://googleblog.blogspot.com/2008/07/we-knew-web-was-big.html
 Arbitrary presentation.
 One hour of video is uploaded to YouTube every second,
amounting to 10 years of content every day
 http://www.youtube.com/t/press_statistics.
 Arbitrary presentation.
8
Introduction to Information Retrieval
Data
 Structured data
 Example: databases
 Unstructured data
 Example: free-form texts
 Semi-structured data
 Example: these slides
 Which are related to information retrieval?
9
Introduction to Information Retrieval
Data
• In fact almost no data is “unstructured”.
• This is definitely true of all text data if you count the
latent linguistic structure of human languages.
• But even accepting that the intended notion of
structure is overt structure, most text has structure,
such as headings and paragraphs and footnotes
10
Introduction to Information Retrieval
Search
 Structured
 Typically allows numerical range and exact match (for text)
queries, e.g., Salary < 60000 AND Manager = Smith.
 Unstructured
 Keyword queries including operators
 More sophisticated “concept” queries, e.g.,
 find all web pages dealing with information retrieval
 Semi-structured
 “semi-structured” search such as Title contains data AND
Text contain search
11
Introduction to Information Retrieval
More sophisticated semi-structured
search
 Title is about Object Oriented Programming AND
Author something like stro*rup
 where * is the wild-card operator
 Issues:
 how do you process “about”?
 how do you rank results?
12
Introduction to Information Retrieval
Unstructured (text) vs. structured
(database) data in 1996
13
Introduction to Information Retrieval
Unstructured (text) vs. structured
(database) data in 2009
14
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).
 Example: Find web pages that contains some
information about the university of Qom.
15
Introduction to Information Retrieval
Two aspects of IR systems
 Indexing
 Search
 In which, time is more important?
 In which, space is more important?
16/48
Introduction to Information Retrieval
The classic search model
TASK
Misconception?
Info Need
Mistranslation?
Verbal
form
Misformulation?
Query
SEARCH
ENGINE
Query
Refinement
Results
Corpus
Introduction to Information Retrieval
Outline
❶
Course details
❷
Information retrieval
❸
Boolean retrieval
18
Introduction to Information Retrieval
Boolean retrieval
 The Boolean model is perhaps the simplest model to
base an information retrieval system on.
 Queries are Boolean expressions,
 e.g., University AND Qom
 The search engine returns all documents that satisfy
the Boolean expression.
19
Sec. 1.1
Introduction to Information Retrieval
Term-document incidence
First we collect keywords from each document to avoid
searching over the whole document: some kind of indexing
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
1 if play contains
word, 0 otherwise
Introduction to Information Retrieval
Sec. 1.1
Incidence vectors
Brutus AND Caesar BUT NOT Calpurnia
 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.
21
Introduction to Information Retrieval
Sec. 1.1
What is wrong?
 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.
22
Sec. 1.1
Introduction to Information Retrieval
Can’t build the matrix
 500K x 1M matrix has half-a-trillion 0’s and 1’s.
 But it has no more than one billion 1’s.
Why?
 matrix is extremely sparse.
 What’s a better representation?
 We only record the 1 positions.
23
Sec. 1.2
Introduction to Information Retrieval
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
Brutus
1
Caesar
1
Calpurnia
Dictionary
2
2
2
31
4
11 31 45 173 174
4
5
6
16 57 132
54 101
Postings
Sorted by docID (more later on why).
What happens if the word Caesar is added to document 14?
24
Introduction to Information Retrieval
Sec. 1.2
Can we use fixed-size arrays for postings?
 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
 Linked lists generally preferred to arrays
 Dynamic space allocation
 Insertion of terms into documents easy
 Space overhead of pointers
 Some tradeoffs in size/ease of insertion
Sec. 1.2
Introduction to Information Retrieval
Inverted index construction
Documents to
be indexed
Friends, Romans, countrymen.
Tokenizer
Token stream
Friends Romans
Countrymen
Linguistic
modules
Modified tokens
Inverted index
friend
roman
countryman
Indexer friend
2
4
roman
1
2
countryman
13
16
Introduction to Information Retrieval
Sec. 1.3
The index we just built
 How do we process a query?
27
Sec. 1.3
Introduction to Information Retrieval
Query processing: AND
 Consider processing the query:
Brutus AND Caesar
 Locate Brutus in the Dictionary;
 Retrieve its postings.
 Locate Caesar in the Dictionary;
 Retrieve its postings.
 “Merge” the two postings:
2
4
8
16
1
2
3
5
32
8
64
13
128
21
Brutus
34 Caesar
28
Sec. 1.3
Introduction to Information Retrieval
The merge
 Walk through the two postings simultaneously, in
time linear in the total number of postings entries
2
8
2
4
8
16
1
2
3
5
32
8
64
13
Brutus
34 Caesar
128
21
If list lengths are x and y, merge takes O(x+y) operations.
Crucial: postings sorted by docID.
29
Introduction to Information Retrieval
Intersecting two postings lists
(a “merge” algorithm)
30
Sec. 1.3
Introduction to Information Retrieval
Query optimization
 Consider a query that is an AND of n terms.
 What is the best order for query processing?
Query: Brutus AND Calpurnia AND Caesar
Brutus
2
Caesar
1
Calpurnia
4
2
8
16 32 64 128
3
5
8
16 21 34
13 16
31
Sec. 1.3
Introduction to Information Retrieval
Query optimization example
 Process in order of increasing freq:
 start with smallest set, then keep cutting further.
This is why we kept
document freq. in dictionary
Brutus
2
Caesar
1
Calpurnia
4
2
8
16 32 64 128
3
5
8
16 21 34
13 16
Execute the query as (Calpurnia AND Brutus) AND Caesar.
32
Introduction to Information Retrieval
Sec. 1.3
Boolean queries: Exact match
 The Boolean retrieval model is being able to ask a
query that is a Boolean expression:
 Boolean Queries use AND, OR and NOT to join
query terms
 Views each document as a set of words
 Is precise: document matches condition or not.
 Perhaps the simplest model to build an IR
system on
 Primary commercial retrieval tool for 3 decades.
33
Introduction to Information Retrieval
Boolean queries: Exact match
 Many search systems you still use are Boolean:
 Email, library catalog, Mac OS X Spotlight
 Many professional searchers still like Boolean search
 You know exactly what you are getting
 But that doesn’t mean it actually works better….
34
Introduction to Information Retrieval
Ranking search results
 Boolean queries give inclusion or exclusion of docs.
 Often we want to rank/group results
 Need to measure proximity from query to each doc.
35
Introduction to Information Retrieval
What’s ahead in IR?
Beyond term search
 What about phrases? “Qom University”
 Proximity: Find Gates NEAR Microsoft.
 Need index to capture position information in docs.
 Zones in documents: Find documents with
(author = Ullman) AND (text contains automata).
 Will often index meta-data separately
 data about data, information known that makes it
easy to access and use the data
36
Introduction to Information Retrieval
The web and its challenges
 Unusual and diverse documents
 Unusual and diverse users, queries, information
needs
 Beyond terms, exploit ideas from social networks
 link analysis, clickstreams ...
 How do search engines work?
And how can we make them better?
37
Introduction to Information Retrieval
Sec. 1.3
Boolean queries: More general merges
 Exercise: Adapt the merge for the queries:
Brutus AND NOT Caesar
Brutus OR NOT Caesar
 Can we still run through the merge in time O(x+y)?
 What can we achieve?
38
Introduction to Information Retrieval
Sec. 1.3
Merging
 Exercise: What about an arbitrary Boolean formula?
(Brutus OR Caesar) AND NOT
(Antony OR Cleopatra)
 Exercise: Extend the merge to an arbitrary Boolean query.
 Can we always merge in “linear” time?
 Linear in what?
 Hint: Begin with the case of a Boolean formula query where each term
appears only once in the query.
39
Introduction to Information Retrieval
Query processing exercises
 Exercise: If the query is friends AND romans AND
(NOT countrymen), how could we use the freq of
countrymen?
40
Download