introduction to information retrieval

47
Introduction to Information Retrieval Acknowledgements to Pandu Nayak and Prabhakar Raghavan of Stanford, Hinrich Schütze and Christina Lioma of Stutgart, Lee Giles (and his sources) of Penn State

Upload: lorie

Post on 23-Feb-2016

63 views

Category:

Documents


3 download

DESCRIPTION

Introduction to Information Retrieval. Acknowledgements to Pandu Nayak and Prabhakar Raghavan of Stanford, Hinrich Schütze and Christina Lioma of Stutgart , Lee Giles (and his sources) of Penn State. So far. You have learned to crawl the web - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to Information Retrieval

Introduction to Information Retrieval

Acknowledgements to Pandu Nayak and Prabhakar Raghavan of Stanford, Hinrich

Schütze and Christina Lioma of Stutgart, Lee Giles (and his sources) of Penn State

Page 2: Introduction to Information Retrieval

So far• You have learned to crawl the web

– Being a good citizen and not hurting the servers

– Extracting the kind of information that you want

– Storing the retrieved material locally• Now, what are you going to do with

those materials?– Develop a way to retrieve what you want

from that collection, as you need it.

Page 3: Introduction to Information Retrieval

Finding what you need in a collection of documents

• Information Retrieval:– Given a collection of “documents”– Retrieve

• One or more documents that contain the specific information you want

• Obtain the answer to an information need by querying the document collection

Page 4: Introduction to Information Retrieval

Tonight’s class• Introduce the concepts of Information

Retrieval– Assume you have a collection– How to look into the documents for your

information need– How to do it efficiently

Page 5: Introduction to Information Retrieval

Later

• Tools to build indices– Apache Lucene– Apache Solr

Page 6: Introduction to Information Retrieval

A brief introduction to Information Retrieval

• Recall our primary resource:– Christopher D. Manning, Prabhakar Raghavan and

Hinrich Schütze, Introduction to Information Retrieval, Cambridge University Press. 2008.

• The entire book is available online, free, at http://nlp.stanford.edu/IR-book/information-retrieval-book.html

• I will use some of the slides that they provide to go with the book.

• I will also use slides from other sources and make new ones. The primary other source is Dr. Lee Giles, Penn State. Information Retrieval IST441

Page 7: Introduction to Information Retrieval

Author’s definition• 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).

• Note the use of the word “usually.” We will see examples where the material is not documents, and not text.

Page 8: Introduction to Information Retrieval

Examples and Scaling• IR is about finding a needle in a haystack

– finding some particular thing in a very large collection of similar things.

• Our examples are necessarily small, so that we can comprehend them. Do remember, that all that we say must scale to very large quantities.

Page 9: Introduction to Information Retrieval

Searching Shakespeare• Which plays of Shakespeare contain the words

Brutus AND Caesar but NOT Calpurnia?– See http://www.rhymezone.com/shakespeare/

• One could grep all of Shakespeare’s plays for Brutus and Caesar, then strip out lines containing Calpurnia?

• Why is that not the answer?– Slow (for large corpora)– NOT Calpurnia is non-trivial– Other operations (e.g., find the word Romans near

countrymen) not feasible– Ranked retrieval (best documents to return)

Page 10: Introduction to Information Retrieval

Document match• Go to http://www.rhymezone.com/shakespeare/• Enter, one at a time,

– Caesar– Brutus– Calpurnia

• For each, note the collection of plays that contain the term

• We need to associate one or more plays with each term – Term Incidence

For our example, we will use a subset of the plays

Page 11: Introduction to Information Retrieval

Term-document incidence

Antony and Cleopatra Julius Caesar The Tempest Hamlet Othello Macbeth

Antony 1 1 0 0 0 1Brutus 1 1 0 1 0 0Caesar 1 1 0 1 1 1

Calpurnia 0 1 0 0 0 0Cleopatra 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

Brutus AND Caesar BUT NOT Calpurnia

All the plays

All the terms

First approach – make a matrix with terms on one axis and plays on the other

Page 12: Introduction to Information Retrieval

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.

Reminder: 0 AND 0 = 0, 0 AND 1 =0, 1 AND 0 = 0, 1 AND 1 = 1 The effect of the AND operation is 1 if the items are both 1 and 0 if they are not both 1

Page 13: Introduction to Information Retrieval

Answer to query• Antony and Cleopatra, Act III,

Scene iiAgrippa [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.

• Hamlet, Act III, Scene iiLord Polonius: I did enact Julius Caesar I was killed i' the Capitol; Brutus killed me.

Page 14: Introduction to Information Retrieval

Spot check• Try another one• What is the vector for the query

– Antony and mercy

• What would we do to find Antony OR mercy?

Page 15: Introduction to Information Retrieval

Basic assumptions about information retrieval

• Collection: Fixed set of documents

• Goal: Retrieve documents with information that is relevant to the user’s information need and helps the user complete a task

Page 16: Introduction to Information Retrieval

The classic search model

Corpus

TASK

Info Need

Query

Verbal form

Results

SEARCHENGINE

QueryRefinement

Ultimately, some task to perform.

Some information is required in order to perform the task.

The information need must be expressed in words (usually).

The information need must be expressed in the form of a query that can be processed.

It may be necessary to rephrase the query and try again

Page 17: Introduction to Information Retrieval

The classic search model

Corpus

TASK

Info Need

Query

Verbal form

Results

SEARCHENGINE

QueryRefinement

Get rid of mice in a politically correct way

Info about removing micewithout killing them

How do I trap mice alive?

mouse trap

Misconception?

Mistranslation?

Misformulation?

Potential pitfalls between task and query results

Page 18: Introduction to Information Retrieval

How good are the results?• Precision: How well do the results

match the information need?

• Recall: What fraction of the available correct results were retrieved?

• These are the basic concepts of information retrieval evaluation.

Page 19: Introduction to Information Retrieval

Size considerations

• 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.

Page 20: Introduction to Information Retrieval

The matrix does not work• 500K x 1M matrix has half-a-trillion

0’s and 1’s.• But it has no more than one billion

1’s.– matrix is extremely sparse.

• What’s a better representation?– We only record the 1 positions.– i.e. We don’t need to know which

documents do not have a term, only those that do.

Why?

Page 21: 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• Can we used fixed-size arrays for this?

Brutus

Calpurnia

Caesar 1 2 4 5 6 16 57 132

1 2 4 11 31 45 173 174

2 31 54 101

What happens if the word Caesar is added to document 14? More likely, add document 14, which contains “Caesar.”

Page 22: Introduction to Information Retrieval

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

22

Postings

Sorted by docID (more later on why).

Posting

Brutus

Calpurnia

Caesar 1 2 4 5 6 16 57 132

1 2 4 11 31 45 173

2 31

174

54 101

Page 23: Introduction to Information Retrieval

TokenizerToken stream.

Friends Romans Countrymen

Inverted index construction

Linguistic modulesModified tokens.

friend roman countryman

IndexerInverted index. friend

roman

countryman

2 4

2

13 16

1

Documents tobe indexed.

Friends, Romans, countrymen.

Sec. 1.2

Stop words, stemming, capitalization, cases, etc.

Page 24: Introduction to Information Retrieval

Indexer steps: Token sequence

Sequence of (Modified token, Document ID) pairs.

I did enact JuliusCaesar I was killed

i' the Capitol; Brutus killed me.

Doc 1

So let it be withCaesar. The noble

Brutus hath told youCaesar was ambitious

Doc 2

Initially, all the tokens from document 1, then all the tokens from document 2, etc., without regard for duplication.

Page 25: Introduction to Information Retrieval

Indexer steps: Sort

Sort by terms docID within terms

Core indexing step

Page 26: Introduction to Information Retrieval

Indexer steps: Dictionary & Postings Multiple

term entries in a single document are merged.

Split into Dictionary and Postings

Doc. frequency information is added.

Number of documents in which the term appears

ID of documents that contain the term

Page 27: Introduction to Information Retrieval

Where do we pay in storage?

27Pointers

Terms and

counts

Lists of docIDs

Page 28: Introduction to Information Retrieval

Storage• A small diversion• Computer storage

– Processor caches– Main memory– External storage (hard disk, other devices)

• Very substantial differences in access speeds– Processor caches mostly used by the operating system

for rapid access to data that will be needed soon– Main memory.

• Limited quantities. High speed access– Hard disk

• Much larger quantities, speed restricted, access in fixed units (blocks)

Page 29: Introduction to Information Retrieval

Some size examples• From the iMac

– Memory• 4GB (two 2GB SO-DIMMs) of 1333MHz DDR3

SDRAM; four SO-DIMM slots support up to 16GB

– Hard drive• 500GB or 1TB 7200-rpm Serial ATA hard drive• Optional 2TB 7200-rpm Serial ATA hard drive

These are big numbers, but the potential size of a significant collection is larger still. The steps taken to optimize use of storage are critical to satisfactory response time.

Page 30: Introduction to Information Retrieval

Implications of size limits

slot 1

slot 2

slot 3

slot 4

slot 5

slot 6

slot 7

slot 8

slot 9

slot 10

slot 11

slot 12

real memory (RAM)

page1

page2

page3

page4 ... ... ... ... ...

... ... ... ... ... ... ... ... ...

... ... ... ... ... ... ... ... ...

b

... ... ... ... ... ... ... ... ...

... ... ... ... ... ... page70

page71

page72

virtual memory (on disk)

reference to page 71

virtual page 71 is brought from disk into real memory

virtual page 2 generates a “page fault” when referencing virtual page 71

Page 31: Introduction to Information Retrieval

How do we process a query?• Using the index we just built, examine

the terms in some order, looking for the terms in the query.

Page 32: 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:

32

128

34

2 4 8 16 32 64

1 2 3 5 8 13 21

Brutus

Caesar

Page 33: Introduction to Information Retrieval

The merge• Walk through the two postings

simultaneously, in time linear in the total number of postings entries

33

34

1282 4 8 16 32 64

1 2 3 5 8 13 21

128

34

2 4 8 16 32 64

1 2 3 5 8 13 21

Brutus

Caesar2 8

If the list lengths are x and y, the merge takes O(x+y) operations.What does that mean?

Crucial: postings sorted by docID.

Sec. 1.3

Page 34: Introduction to Information Retrieval

Intersecting two postings lists(a “merge” algorithm)

34

Page 35: Introduction to Information Retrieval

Spot Check• Let’s assume that

– the term mercy appears in documents 1, 2, 13, 18, 24,35, 54

– the term noble appears in documents 1, 5, 7, 13, 22, 24, 56

• Show the document lists, then step through the merge algorithm to obtain the search results.

Page 36: Introduction to Information Retrieval

Boolean queries: Exact match• The Boolean retrieval model is being able to

ask a query that is a Boolean expression:– Boolean Queries are queries using 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• Primary commercial retrieval tool for 3

decades. • Many search systems you still use are Boolean:

– Email, library catalog, Mac OS X Spotlight36

Sec. 1.3

Page 37: Introduction to Information Retrieval

37

Query optimization

• Consider a query that is an and of n terms, n > 2• For each of the terms, get its postings list, then and them

together• Example query: BRUTUS AND CALPURNIA AND

CAESAR• What is the best order for processing this query?

37

Page 38: Introduction to Information Retrieval

38

Query optimization

• Example query: BRUTUS AND CALPURNIA AND CAESAR

• Simple and effective optimization: Process in order of increasing frequency

• Start with the shortest postings list, then keep cutting further

• In this example, first CAESAR, then CALPURNIA, then BRUTUS

38

Page 39: Introduction to Information Retrieval

39

Optimized intersection algorithm forconjunctive queries

39

Page 40: Introduction to Information Retrieval

40

More general optimization

• Example query: (MADDING OR CROWD) and (IGNOBLE OR STRIFE)

• Get frequencies for all terms• Estimate the size of each or by the sum of its

frequencies (conservative)• Process in increasing order of or sizes

40

Page 41: Introduction to Information Retrieval

Scaling• These basic techniques are pretty simple• There are challenges

– Scaling• as everything becomes digitized, how well do

the processes scale?– Intelligent information extraction

• I want information, not just a link to a place that might have that information.

Page 42: Introduction to Information Retrieval

How much information is there?• Soon most everything will be

recorded and indexed• Most bytes will never be seen

by humans.• Data summarization,

trend detection anomaly detection are key technologies

See Mike Lesk: How much information is there: http://www.lesk.com/mlesk/ksg97/ksg.html

See Lyman & Varian: How much informationhttp://www.sims.berkeley.edu/research/projects/how-

much-info/

Yotta

Zetta

Exa

Peta

Tera

Giga

Mega

Kilo

All books(words)

All Books MultiMedia

EverythingRecorded !

A Photo

24 Yecto, 21 zepto, 18 atto, 15 femto, 12 pico, 9 nano, 6 micro, 3 milli

Gray - Microsoft

Slide source: Lee Giles (modified) A Book

A movie

Page 43: Introduction to Information Retrieval

Getting the required information

• Dependent on – Acquiring information– Storing information– Indexing– Interaction with the information source– Evaluation

Page 44: Introduction to Information Retrieval

Getting the required information

• We have learned about– Acquiring information– Storing information– Indexing (the basics)– Interaction with the information source– Evaluation

Page 45: Introduction to Information Retrieval

Getting the required information

• Still to come– Acquiring information– Storing information– Indexing (more)– Interaction with the information source– Evaluation

Page 46: 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?

46

Page 47: Introduction to Information Retrieval

References• Christopher D. Manning, Prabhakar Raghavan and Hinrich Schütze,

Introduction to Information Retrieval, Cambridge University Press. 2008. – Book available online at http://nlp.stanford.edu/IR-book/information-retrieval-book.html– Many of these slides are taken directly from the authors’ slides from the first chapter of the book.

• C. Lee Giles, Penn State. http://clgiles.ist.psu.edu/• Paging figure from Vittore Carsarosa, University of Parma, Italy